diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-12-23 20:42:25 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-12-24 13:17:27 +0100 |
commit | 4657a397c22a27775823b8f731abdc6477badfea (patch) | |
tree | 824de1197bc46ce022a3edd850654f8d7a93fbaf /lldb/source/Plugins | |
parent | 8131c04836829e7f37f2feaa1d85b4ef62ad092f (diff) | |
download | bcm5719-llvm-4657a397c22a27775823b8f731abdc6477badfea.tar.gz bcm5719-llvm-4657a397c22a27775823b8f731abdc6477badfea.zip |
[lldb][NFC] Remove ClangExternalASTSourceCommon
ClangExternalASTSourceCommon's purpose is to store a map from
Decl*/Type* to ClangASTMetadata. Usually this data is accessed
via the ClangASTContext interface which then grabs the
current ExternalASTSource of its ASTContext, tries to cast it
to ClangExternalASTSourceCommon and then accesses the metadata
map. If the casting fails the setter does nothing and the getter
returns a nullptr as if there was no known metadata for a type/decl.
This system breaks as soon as any non-LLDB ExternalASTSource is added via
a multiplexer to our existing ExternalASTSource (in which case we suddenly
loose all out metadata as the casting always fails with an ExternalASTSource
that is not inheriting from ClangExternalASTSourceCommon).
This patch moves the metadata map to the ClangASTContext. This gets
rid of all the fragile casting, the requirement that every ExternalASTSource in
LLDB has to inherit from ClangExternalASTSourceCommon and simplifies
the metadata implementation to a simple map lookup. As ClangExternalASTSourceCommon
had no other purpose than storing metadata, this patch deletes this class
and replaces all uses with clang::ExternalASTSource.
No other code changes in this commit beside the AppleObjCDeclVendor which
was the only code that did not use the ClangASTContext interface but directly
accessed the ClangExternalASTSourceCommon.
Diffstat (limited to 'lldb/source/Plugins')
3 files changed, 10 insertions, 10 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index 609b182ed61..3149b4266b2 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -12,9 +12,9 @@ #include <set> #include "lldb/Symbol/ClangASTImporter.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Target.h" +#include "clang/AST/ExternalASTSource.h" #include "clang/Basic/IdentifierTable.h" #include "llvm/ADT/SmallSet.h" @@ -29,7 +29,7 @@ namespace lldb_private { /// knows the name it is looking for, but nothing else. The ExternalSemaSource /// class provides Decls (VarDecl, FunDecl, TypeDecl) to Clang for these /// names, consulting the ClangExpressionDeclMap to do the actual lookups. -class ClangASTSource : public ClangExternalASTSourceCommon, +class ClangASTSource : public clang::ExternalASTSource, public ClangASTImporter::MapCompleter { public: /// Constructor @@ -211,7 +211,7 @@ public: /// /// Clang AST contexts like to own their AST sources, so this is a state- /// free proxy object. - class ClangASTSourceProxy : public ClangExternalASTSourceCommon { + class ClangASTSourceProxy : public clang::ExternalASTSource { public: ClangASTSourceProxy(ClangASTSource &original) : m_original(original) {} diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 9a1da40cd6d..c6bed45985e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -38,6 +38,7 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index aca0b8fddcc..063b995ff79 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -10,7 +10,7 @@ #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" #include "lldb/Core/Module.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -18,12 +18,12 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" - +#include "clang/AST/ExternalASTSource.h" using namespace lldb_private; class lldb_private::AppleObjCExternalASTSource - : public ClangExternalASTSourceCommon { + : public clang::ExternalASTSource { public: AppleObjCExternalASTSource(AppleObjCDeclVendor &decl_vendor) : m_decl_vendor(decl_vendor) {} @@ -182,7 +182,7 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) { ClangASTMetadata meta_data; meta_data.SetISAPtr(isa); - m_external_source->SetMetadata(new_iface_decl, meta_data); + m_ast_ctx.SetMetadata(new_iface_decl, meta_data); new_iface_decl->setHasExternalVisibleStorage(); new_iface_decl->setHasExternalLexicalStorage(); @@ -413,7 +413,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { Log *log(GetLogIfAllCategoriesSet( LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? - ClangASTMetadata *metadata = m_external_source->GetMetadata(interface_decl); + ClangASTMetadata *metadata = m_ast_ctx.GetMetadata(interface_decl); ObjCLanguageRuntime::ObjCISA objc_isa = 0; if (metadata) objc_isa = metadata->GetISAPtr(); @@ -577,8 +577,7 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, ast_ctx.getObjCInterfaceType(result_iface_decl); uint64_t isa_value = LLDB_INVALID_ADDRESS; - ClangASTMetadata *metadata = - m_external_source->GetMetadata(result_iface_decl); + ClangASTMetadata *metadata = m_ast_ctx.GetMetadata(result_iface_decl); if (metadata) isa_value = metadata->GetISAPtr(); |