summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-12-23 10:55:21 +0100
committerRaphael Isemann <teemperor@gmail.com>2019-12-23 11:48:02 +0100
commit73951a11c64b4e748bbd1291d5021aef6aa400a5 (patch)
treed7efca0f00350ab7b0555dcd0bb93b9d5857a7ba /lldb/source/Symbol
parentf027e1a68dacfb692b4f3e30abfda529d020d472 (diff)
downloadbcm5719-llvm-73951a11c64b4e748bbd1291d5021aef6aa400a5.tar.gz
bcm5719-llvm-73951a11c64b4e748bbd1291d5021aef6aa400a5.zip
[lldb] Add sanity check to CreateDeclContext and fixed illformed CompilerContext in ClangExpressionDeclMap.
This adds a check that the ClangASTContext actually fits to the DeclContext that we want to create a CompilerDeclContext for. If the ClangASTContext (and its associated ASTContext) does not fit to the DeclContext (that is, the DeclContext wasn't created by the ASTContext), all computations using this malformed CompilerDeclContext will yield unpredictable results. Also fixes the only place that actually hits this assert which is the construction of a CompilerDeclContext in ClangExpressionDeclMap where we pass an unrelated ASTContext instead of the ASTContext of the current expression. I had to revert my previous change to DWARFASTParserClangTests.cpp back to using the unsafe direct construction of CompilerDeclContext as this assert won't work if the DeclContext we pass isn't a valid DeclContext in the first place.
Diffstat (limited to 'lldb/source/Symbol')
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index f86e4bcd06a..65d73d5f682 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -1201,6 +1201,8 @@ CompilerType ClangASTContext::GetTypeForDecl(void *opaque_decl) {
}
CompilerDeclContext ClangASTContext::CreateDeclContext(DeclContext *ctx) {
+ // Check that the DeclContext actually belongs to this ASTContext.
+ assert(&ctx->getParentASTContext() == &getASTContext());
return CompilerDeclContext(this, ctx);
}
OpenPOWER on IntegriCloud