summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-04 02:22:12 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-04 02:22:12 +0000
commit44bfcf0f97e52ac9545d35cafb8abca845565886 (patch)
tree2ae45fe2ae0737a7afa47695491ed875b527b663 /clang/lib/CodeGen
parent8936009a919775af9f32c0172d9a871e9873344b (diff)
downloadbcm5719-llvm-44bfcf0f97e52ac9545d35cafb8abca845565886.tar.gz
bcm5719-llvm-44bfcf0f97e52ac9545d35cafb8abca845565886.zip
Add PushConditionalTempDestruction/PopConditionalTempDestruction.
llvm-svn: 72835
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCXXTemp.cpp11
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h19
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCXXTemp.cpp b/clang/lib/CodeGen/CGCXXTemp.cpp
index 4e20b74ed59..b7bc6b70334 100644
--- a/clang/lib/CodeGen/CGCXXTemp.cpp
+++ b/clang/lib/CodeGen/CGCXXTemp.cpp
@@ -67,3 +67,14 @@ CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
return RV;
}
+
+void
+CodeGenFunction::PushConditionalTempDestruction() {
+ // Store the current number of live temporaries.
+ ConditionalTempDestructionStack.push_back(LiveTemporaries.size());
+}
+
+void CodeGenFunction::PopConditionalTempDestruction() {
+ ConditionalTempDestructionStack.pop_back();
+}
+
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index c91a052cd54..72c4aa4a658 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -160,6 +160,20 @@ public:
/// this behavior for branches?
void EmitBranchThroughCleanup(llvm::BasicBlock *Dest);
+ /// PushConditionalTempDestruction - Should be called before a conditional
+ /// part of an expression is emitted. For example, before the RHS of the
+ /// expression below is emitted:
+ ///
+ /// b && f(T());
+ ///
+ /// This is used to make sure that any temporaryes created in the conditional
+ /// branch are only destroyed if the branch is taken.
+ void PushConditionalTempDestruction();
+
+ /// PopConditionalTempDestruction - Should be called after a conditional
+ /// part of an expression has been emitted.
+ void PopConditionalTempDestruction();
+
private:
CGDebugInfo* DebugInfo;
@@ -263,6 +277,11 @@ private:
};
llvm::SmallVector<CXXLiveTemporaryInfo, 4> LiveTemporaries;
+
+ /// ConditionalTempDestructionStack - Contains the number of live temporaries
+ /// when PushConditionalTempDestruction was called. This is used so that
+ /// we know how many temporaries were created by a certain expression.
+ llvm::SmallVector<size_t, 4> ConditionalTempDestructionStack;
public:
CodeGenFunction(CodeGenModule &cgm);
OpenPOWER on IntegriCloud