summaryrefslogtreecommitdiffstats
path: root/lldb/include
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-12-21 22:40:52 +0100
committerRaphael Isemann <teemperor@gmail.com>2019-12-21 22:51:35 +0100
commitf9f49d3594bc7584cc5cb96125ca08f2ad97662c (patch)
tree9055539f626cc2ce798d895434b6092a9123cf3e /lldb/include
parentbf03e17c570171c7a52117fe63ace89d58f328d5 (diff)
downloadbcm5719-llvm-f9f49d3594bc7584cc5cb96125ca08f2ad97662c.tar.gz
bcm5719-llvm-f9f49d3594bc7584cc5cb96125ca08f2ad97662c.zip
[lldb][NFC] Return a reference from ClangASTContext::getASTContext and remove dead nullptr checks
ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a while that the ASTContext is not a nullptr. This causes that we still have a lot of code that is doing nullptr checks on the result of getASTContext() which is all unreachable code. This patch changes the return value to a reference to make it clear this can't be a nullptr and deletes all the nullptr checks.
Diffstat (limited to 'lldb/include')
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h54
1 files changed, 25 insertions, 29 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index e5dc77504af..e0216cce3e1 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -100,7 +100,7 @@ public:
return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
}
- clang::ASTContext *getASTContext();
+ clang::ASTContext &getASTContext();
clang::MangleContext *getMangleContext();
@@ -117,7 +117,7 @@ public:
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
bool GetCompleteDecl(clang::Decl *decl) {
- return ClangASTContext::GetCompleteDecl(getASTContext(), decl);
+ return ClangASTContext::GetCompleteDecl(&getASTContext(), decl);
}
static void DumpDeclHiearchy(clang::Decl *decl);
@@ -134,14 +134,14 @@ public:
void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data);
void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data);
ClangASTMetadata *GetMetadata(const clang::Decl *object) {
- return GetMetadata(getASTContext(), object);
+ return GetMetadata(&getASTContext(), object);
}
static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
const clang::Decl *object);
ClangASTMetadata *GetMetadata(const clang::Type *object) {
- return GetMetadata(getASTContext(), object);
+ return GetMetadata(&getASTContext(), object);
}
static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
@@ -170,7 +170,7 @@ public:
static clang::DeclContext *GetTranslationUnitDecl(clang::ASTContext *ast);
clang::DeclContext *GetTranslationUnitDecl() {
- return GetTranslationUnitDecl(getASTContext());
+ return GetTranslationUnitDecl(&getASTContext());
}
static clang::Decl *CopyDecl(clang::ASTContext *dest_context,
@@ -193,27 +193,23 @@ public:
CompilerType compiler_type;
if (type_name.GetLength()) {
- clang::ASTContext *ast = getASTContext();
- if (ast) {
- if (!decl_context)
- decl_context = ast->getTranslationUnitDecl();
-
- clang::IdentifierInfo &myIdent =
- ast->Idents.get(type_name.GetCString());
- clang::DeclarationName myName =
- ast->DeclarationNames.getIdentifier(&myIdent);
-
- clang::DeclContext::lookup_result result =
- decl_context->lookup(myName);
-
- if (!result.empty()) {
- clang::NamedDecl *named_decl = result[0];
- if (const RecordDeclType *record_decl =
- llvm::dyn_cast<RecordDeclType>(named_decl))
- compiler_type.SetCompilerType(
- this, clang::QualType(record_decl->getTypeForDecl(), 0)
- .getAsOpaquePtr());
- }
+ clang::ASTContext &ast = getASTContext();
+ if (!decl_context)
+ decl_context = ast.getTranslationUnitDecl();
+
+ clang::IdentifierInfo &myIdent = ast.Idents.get(type_name.GetCString());
+ clang::DeclarationName myName =
+ ast.DeclarationNames.getIdentifier(&myIdent);
+
+ clang::DeclContext::lookup_result result = decl_context->lookup(myName);
+
+ if (!result.empty()) {
+ clang::NamedDecl *named_decl = result[0];
+ if (const RecordDeclType *record_decl =
+ llvm::dyn_cast<RecordDeclType>(named_decl))
+ compiler_type.SetCompilerType(
+ this, clang::QualType(record_decl->getTypeForDecl(), 0)
+ .getAsOpaquePtr());
}
}
@@ -355,14 +351,14 @@ public:
const CompilerType *args, unsigned num_args,
bool is_variadic, unsigned type_quals) {
return ClangASTContext::CreateFunctionType(
- getASTContext(), result_type, args, num_args, is_variadic, type_quals);
+ &getASTContext(), result_type, args, num_args, is_variadic, type_quals);
}
CompilerType CreateFunctionType(const CompilerType &result_type,
const CompilerType *args, unsigned num_args,
bool is_variadic, unsigned type_quals,
clang::CallingConv cc) {
- return ClangASTContext::CreateFunctionType(getASTContext(), result_type,
+ return ClangASTContext::CreateFunctionType(&getASTContext(), result_type,
args, num_args, is_variadic,
type_quals, cc);
}
@@ -396,7 +392,7 @@ public:
size_t bit_size, bool is_signed);
CompilerType GetPointerSizedIntType(bool is_signed) {
- return GetPointerSizedIntType(getASTContext(), is_signed);
+ return GetPointerSizedIntType(&getASTContext(), is_signed);
}
static CompilerType GetPointerSizedIntType(clang::ASTContext *ast,
OpenPOWER on IntegriCloud