Add an IsInitializer flag to EmitAnyExpr. This is used to prevent temporaries from being destroyed when they're bound to a reference variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79179 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXXTemp.cpp b/lib/CodeGen/CGCXXTemp.cpp
index 04d3842..30de111 100644
--- a/lib/CodeGen/CGCXXTemp.cpp
+++ b/lib/CodeGen/CGCXXTemp.cpp
@@ -84,11 +84,13 @@
RValue
CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
llvm::Value *AggLoc,
- bool isAggLocVolatile) {
+ bool IsAggLocVolatile,
+ bool IsInitializer) {
// If we shouldn't destroy the temporaries, just emit the
// child expression.
if (!E->shouldDestroyTemporaries())
- return EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile);
+ return EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
+ /*IgnoreResult=*/false, IsInitializer);
// Keep track of the current cleanup stack depth.
size_t CleanupStackDepth = CleanupEntries.size();
@@ -96,7 +98,8 @@
unsigned OldNumLiveTemporaries = LiveTemporaries.size();
- RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile);
+ RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
+ /*IgnoreResult=*/false, IsInitializer);
// Pop temporaries.
while (LiveTemporaries.size() > OldNumLiveTemporaries)