summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp7
-rw-r--r--clang/lib/Analysis/ConstructionContext.cpp5
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index ae18278a0d9..9d11fcdbc78 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1202,8 +1202,13 @@ void CFGBuilder::findConstructionContexts(
case Stmt::ImplicitCastExprClass: {
auto *Cast = cast<ImplicitCastExpr>(Child);
// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
- if (Cast->getCastKind() == CK_NoOp)
+ switch (Cast->getCastKind()) {
+ case CK_NoOp:
+ case CK_ConstructorConversion:
findConstructionContexts(Layer, Cast->getSubExpr());
+ default:
+ break;
+ }
break;
}
case Stmt::CXXBindTemporaryExprClass: {
diff --git a/clang/lib/Analysis/ConstructionContext.cpp b/clang/lib/Analysis/ConstructionContext.cpp
index aea329b1fea..1a1bc7db8fb 100644
--- a/clang/lib/Analysis/ConstructionContext.cpp
+++ b/clang/lib/Analysis/ConstructionContext.cpp
@@ -70,8 +70,11 @@ const ConstructionContext *ConstructionContext::createFromLayers(
C.getAllocator().Allocate<TemporaryObjectConstructionContext>();
return new (CC) TemporaryObjectConstructionContext(BTE, MTE);
} else 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()
- ->getAsCXXRecordDecl()->hasTrivialDestructor());
+ ->getAsCXXRecordDecl()->hasTrivialDestructor() ||
+ MTE->getStorageDuration() != SD_FullExpression);
assert(TopLayer->isLast());
auto *CC =
C.getAllocator().Allocate<TemporaryObjectConstructionContext>();
OpenPOWER on IntegriCloud