summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-11-20 12:40:08 +0100
committerRaphael Isemann <teemperor@gmail.com>2019-11-20 12:47:14 +0100
commitc502bae52410c83947e5ad7184dff810083afe75 (patch)
tree8a94073d43217b525368530a893bef0a680859f6
parent82800df4de1bfc5fc332fc60f399d50c444050fe (diff)
downloadbcm5719-llvm-c502bae52410c83947e5ad7184dff810083afe75.tar.gz
bcm5719-llvm-c502bae52410c83947e5ad7184dff810083afe75.zip
[lldb][NFC] Simplify ClangASTContext::GetBasicTypes
static convenience methods that do the clang::ASTContext -> ClangASTContext conversion and handle errors by simply ignoring them are not a good idea.
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h6
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp25
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp19
-rw-r--r--lldb/unittests/Symbol/TestClangASTContext.cpp3
4 files changed, 19 insertions, 34 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index e68df0a4868..c279bdb82c4 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -153,11 +153,7 @@ public:
CompilerType GetBasicType(lldb::BasicType type);
- static CompilerType GetBasicType(clang::ASTContext *ast,
- lldb::BasicType type);
-
- static CompilerType GetBasicType(clang::ASTContext *ast,
- ConstString name);
+ CompilerType GetBasicType(ConstString name);
static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index bbc03126ea2..f8e448ffcb6 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1724,17 +1724,15 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
if (target == nullptr)
return;
- ASTContext *scratch_ast_context =
- target->GetScratchClangASTContext()->getASTContext();
-
- TypeFromUser user_type(
- ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid)
- .GetPointerType()
- .GetLValueReferenceType());
- TypeFromParser parser_type(
- ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid)
- .GetPointerType()
- .GetLValueReferenceType());
+ ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext();
+
+ TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid)
+ .GetPointerType()
+ .GetLValueReferenceType());
+ ClangASTContext *own_context = ClangASTContext::GetASTContext(m_ast_context);
+ TypeFromParser parser_type(own_context->GetBasicType(eBasicTypeVoid)
+ .GetPointerType()
+ .GetLValueReferenceType());
NamedDecl *var_decl = context.AddVarDecl(parser_type);
std::string decl_name(context.m_decl_name.getAsString());
@@ -2024,8 +2022,9 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
if (copied_clang_type.IsAggregateType() &&
copied_clang_type.GetCompleteType()) {
- CompilerType void_clang_type =
- ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid);
+ ClangASTContext *own_context =
+ ClangASTContext::GetASTContext(m_ast_context);
+ CompilerType void_clang_type = own_context->GetBasicType(eBasicTypeVoid);
CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
CompilerType method_type = ClangASTContext::CreateFunctionType(
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index fbf5bd4cf40..bee72b219b5 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -987,13 +987,9 @@ ClangASTContext::GetBasicTypeEnumeration(ConstString name) {
return eBasicTypeInvalid;
}
-CompilerType ClangASTContext::GetBasicType(ASTContext *ast,
- ConstString name) {
- if (ast) {
- lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name);
- return ClangASTContext::GetBasicType(ast, basic_type);
- }
- return CompilerType();
+CompilerType ClangASTContext::GetBasicType(ConstString name) {
+ lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name);
+ return GetBasicType(basic_type);
}
uint32_t ClangASTContext::GetPointerByteSize() {
@@ -1006,13 +1002,8 @@ uint32_t ClangASTContext::GetPointerByteSize() {
}
CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) {
- return GetBasicType(getASTContext(), basic_type);
-}
+ clang::ASTContext *ast = getASTContext();
-CompilerType ClangASTContext::GetBasicType(ASTContext *ast,
- lldb::BasicType basic_type) {
- if (!ast)
- return CompilerType();
lldb::opaque_compiler_type_t clang_type =
GetOpaqueCompilerType(ast, basic_type);
@@ -4907,7 +4898,7 @@ ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
// Create related types using the current type's AST
CompilerType ClangASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type) {
- return ClangASTContext::GetBasicType(getASTContext(), basic_type);
+ return ClangASTContext::GetBasicType(basic_type);
}
// Exploring the type
diff --git a/lldb/unittests/Symbol/TestClangASTContext.cpp b/lldb/unittests/Symbol/TestClangASTContext.cpp
index 253b73f892b..44a824636cf 100644
--- a/lldb/unittests/Symbol/TestClangASTContext.cpp
+++ b/lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -317,8 +317,7 @@ TEST_F(TestClangASTContext, TestUnifyAccessSpecifiers) {
}
TEST_F(TestClangASTContext, TestRecordHasFields) {
- CompilerType int_type =
- ClangASTContext::GetBasicType(m_ast->getASTContext(), eBasicTypeInt);
+ CompilerType int_type = m_ast->GetBasicType(eBasicTypeInt);
// Test that a record with no fields returns false
CompilerType empty_base = m_ast->CreateRecordType(
OpenPOWER on IntegriCloud