summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-12-29 23:01:53 +0100
committerRaphael Isemann <teemperor@gmail.com>2019-12-30 00:22:23 +0100
commitb1fb07ddbaa539f9173e32dc27110168b165c1fe (patch)
treec78dbe24e774121055411bdb52830fcd105a1c0d
parent6991d5728f12594cabfd8d8d570361efb07f1d5a (diff)
downloadbcm5719-llvm-b1fb07ddbaa539f9173e32dc27110168b165c1fe.tar.gz
bcm5719-llvm-b1fb07ddbaa539f9173e32dc27110168b165c1fe.zip
[lldb][NFC] Simplify ClangASTContext::GetTypeForDecl
Also removes the GetASTContext call from this code.
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp7
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp22
3 files changed, 12 insertions, 23 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 9307825675c..e9a1d536ca8 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -164,11 +164,11 @@ public:
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 e5c37e77194..96dd72bb100 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 e9727399d7e..d226a34b1ac 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;
OpenPOWER on IntegriCloud