diff options
author | Alex Langford <apl@fb.com> | 2019-06-12 17:47:06 +0000 |
---|---|---|
committer | Alex Langford <apl@fb.com> | 2019-06-12 17:47:06 +0000 |
commit | 5b99928ba88a3331ad4626b401c8f4ffdf3b1b99 (patch) | |
tree | 785753e2bcf6bfbd9bb4abd8a10ffcd838926a32 /lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp | |
parent | 8f4973f57b0cfd35f9ebbe9c48d54274795e04d1 (diff) | |
download | bcm5719-llvm-5b99928ba88a3331ad4626b401c8f4ffdf3b1b99.tar.gz bcm5719-llvm-5b99928ba88a3331ad4626b401c8f4ffdf3b1b99.zip |
[Expression] Add PersistentExpressionState::GetCompilerTypeFromPersistentDecl
Summary:
PersistentStateExpressions (e.g. ClangPersistentVariables) have the
ability to define types using expressions that persist throughout the
debugging session. GetCompilerTypeFromPersistentDecl is a useful
operation to have if you need to use any of those persistently declared types,
like in CommandObjectMemory.
This decouples clang from CommandObjectMemory and decouples Plugins from
Commands in general.
Differential Revision: https://reviews.llvm.org/D62797
llvm-svn: 363183
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp')
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp index 912c9ef2e1b..742a14992dc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -9,6 +9,7 @@ #include "ClangPersistentVariables.h" #include "lldb/Core/Value.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" @@ -52,6 +53,21 @@ void ClangPersistentVariables::RemovePersistentVariable( m_next_persistent_variable_id--; } +llvm::Optional<CompilerType> +ClangPersistentVariables::GetCompilerTypeFromPersistentDecl( + ConstString type_name) { + CompilerType compiler_type; + if (clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>( + GetPersistentDecl(type_name))) { + compiler_type.SetCompilerType( + ClangASTContext::GetASTContext(&tdecl->getASTContext()), + reinterpret_cast<lldb::opaque_compiler_type_t>( + const_cast<clang::Type *>(tdecl->getTypeForDecl()))); + return compiler_type; + } + return llvm::None; +} + void ClangPersistentVariables::RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl) { m_persistent_decls.insert( |