diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-03-30 19:25:39 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-03-30 19:25:39 +0000 |
commit | 6a5cd5e1cad601bfe3785654f6bbdfe81844bc07 (patch) | |
tree | b613739fb954f5424f0397ece15a36f8e46f0cf3 /clang/lib/Analysis | |
parent | b5294a3b5934cee3196cbd5a6d69010022b8ace9 (diff) | |
download | bcm5719-llvm-6a5cd5e1cad601bfe3785654f6bbdfe81844bc07.tar.gz bcm5719-llvm-6a5cd5e1cad601bfe3785654f6bbdfe81844bc07.zip |
[CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.
Sometimes template instantiation causes CXXBindTemporaryExpr to be missing in
its usual spot. In CFG, temporary destructors work by relying on
CXXBindTemporaryExprs, so they won't work in this case.
Avoid the crash and notify the clients that we've encountered an unsupported AST
by failing to provide the ill-formed construction context for the temporary.
Differential Revision: https://reviews.llvm.org/D44955
llvm-svn: 328895
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Analysis/ConstructionContext.cpp | 7 |
2 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 0f0556135c2..34d40162275 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -736,12 +736,12 @@ private: if (BuildOpts.AddRichCXXConstructors) { if (const ConstructionContextLayer *Layer = ConstructionContextMap.lookup(CE)) { - const ConstructionContext *CC = - ConstructionContext::createFromLayers(cfg->getBumpVectorContext(), - Layer); - B->appendConstructor(CE, CC, cfg->getBumpVectorContext()); cleanupConstructionContext(CE); - return; + if (const auto *CC = ConstructionContext::createFromLayers( + cfg->getBumpVectorContext(), Layer)) { + B->appendConstructor(CE, CC, cfg->getBumpVectorContext()); + return; + } } } @@ -757,12 +757,12 @@ private: if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE, *Context)) { if (const ConstructionContextLayer *Layer = ConstructionContextMap.lookup(CE)) { - const ConstructionContext *CC = - ConstructionContext::createFromLayers(cfg->getBumpVectorContext(), - Layer); - B->appendCXXRecordTypedCall(CE, CC, cfg->getBumpVectorContext()); cleanupConstructionContext(CE); - return; + if (const auto *CC = ConstructionContext::createFromLayers( + cfg->getBumpVectorContext(), Layer)) { + B->appendCXXRecordTypedCall(CE, CC, cfg->getBumpVectorContext()); + return; + } } } } diff --git a/clang/lib/Analysis/ConstructionContext.cpp b/clang/lib/Analysis/ConstructionContext.cpp index ad0dbd2bb11..9f3c00b2bc9 100644 --- a/clang/lib/Analysis/ConstructionContext.cpp +++ b/clang/lib/Analysis/ConstructionContext.cpp @@ -101,9 +101,12 @@ const ConstructionContext *ConstructionContext::createFromLayers( if (const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(S)) { // If the object requires destruction and is not lifetime-extended, // then it must have a BTE within its MTE. - assert(MTE->getType().getCanonicalType() + // FIXME: This should be an assertion. + if (!(MTE->getType().getCanonicalType() ->getAsCXXRecordDecl()->hasTrivialDestructor() || - MTE->getStorageDuration() != SD_FullExpression); + MTE->getStorageDuration() != SD_FullExpression)) + return nullptr; + assert(TopLayer->isLast()); return create<TemporaryObjectConstructionContext>(C, nullptr, MTE); } |