summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-06-11 02:41:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-06-11 02:41:00 +0000
commit7c5d4dce49fb03e63858e44da450b7ff462cd592 (patch)
tree6d86151dcafe65d13ba326501aabbc2b63e1596c /clang/lib/Sema/SemaInit.cpp
parent276135073091ea3545cb177666d9815b49fe797d (diff)
downloadbcm5719-llvm-7c5d4dce49fb03e63858e44da450b7ff462cd592.tar.gz
bcm5719-llvm-7c5d4dce49fb03e63858e44da450b7ff462cd592.zip
Rework IR emission for lifetime-extended temporaries. Instead of trying to walk
into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7d73e0890ec..847b935505a 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5214,6 +5214,9 @@ static void performLifetimeExtension(Expr *Init, const ValueDecl *ExtendingD) {
Init = const_cast<Expr *>(
Init->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments));
+ if (CXXBindTemporaryExpr *BTE = dyn_cast<CXXBindTemporaryExpr>(Init))
+ Init = BTE->getSubExpr();
+
if (InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
if (ILE->initializesStdInitializerList() || ILE->getType()->isArrayType()) {
// FIXME: If this is an InitListExpr which creates a std::initializer_list
OpenPOWER on IntegriCloud