Author: Raphael Isemann Date: 2019-12-30T00:22:23+01:00 New Revision: b1fb07ddbaa539f9173e32dc27110168b165c1fe
URL: https://github.com/llvm/llvm-project/commit/b1fb07ddbaa539f9173e32dc27110168b165c1fe DIFF: https://github.com/llvm/llvm-project/commit/b1fb07ddbaa539f9173e32dc27110168b165c1fe.diff LOG: [lldb][NFC] Simplify ClangASTContext::GetTypeForDecl Also removes the GetASTContext call from this code. Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Symbol/ClangASTContext.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 9307825675cf..e9a1d536ca8e 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -164,11 +164,11 @@ class ClangASTContext : public TypeSystem { static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers = false); - static CompilerType GetTypeForDecl(clang::NamedDecl *decl); + CompilerType GetTypeForDecl(clang::NamedDecl *decl); - static CompilerType GetTypeForDecl(clang::TagDecl *decl); + CompilerType GetTypeForDecl(clang::TagDecl *decl); - static CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl); + CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl); template <typename RecordDeclType> CompilerType diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index e5c37e771945..96dd72bb1009 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -255,7 +255,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc, return type_sp; } -static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer, +static void CompleteExternalTagDeclType(ClangASTContext &ast, + ClangASTImporter &ast_importer, clang::DeclContext *decl_ctx, DWARFDIE die, const char *type_name_cstr) { @@ -264,7 +265,7 @@ static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer, return; // If this type was not imported from an external AST, there's nothing to do. - CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx); + CompilerType type = ast.GetTypeForDecl(tag_decl_ctx); if (!type || !ast_importer.CanImport(type)) return; @@ -1594,7 +1595,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, // backing the Decl is complete before adding children to it. This is // not an issue in the non-gmodules case because the debug info will // always contain a full definition of parent types in that case. - CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die, + CompleteExternalTagDeclType(m_ast, GetClangASTImporter(), decl_ctx, die, attrs.name.GetCString()); if (attrs.accessibility == eAccessNone && decl_ctx) { diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index e9727399d7ec..d226a34b1ac4 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -1179,25 +1179,13 @@ CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) { } CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) { - // No need to call the getASTContext() accessor (which can create the AST if - // it isn't created yet, because we can't have created a decl in this - // AST if our AST didn't already exist... - ASTContext *ast = &decl->getASTContext(); - if (ast) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->getTagDeclType(decl).getAsOpaquePtr()); - return CompilerType(); + return CompilerType(this, + getASTContext().getTagDeclType(decl).getAsOpaquePtr()); } CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) { - // No need to call the getASTContext() accessor (which can create the AST if - // it isn't created yet, because we can't have created a decl in this - // AST if our AST didn't already exist... - ASTContext *ast = &decl->getASTContext(); - if (ast) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->getObjCInterfaceType(decl).getAsOpaquePtr()); - return CompilerType(); + return CompilerType( + this, getASTContext().getObjCInterfaceType(decl).getAsOpaquePtr()); } #pragma mark Structure, Unions, Classes @@ -9183,7 +9171,7 @@ uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx, continue; // Check types, if one was provided. if (child_type) { - CompilerType clang_type = ClangASTContext::GetTypeForDecl(nd); + CompilerType clang_type = GetTypeForDecl(nd); if (!AreTypesSame(clang_type, *child_type, /*ignore_qualifiers=*/true)) continue; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits