diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-20 17:27:56 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-20 17:27:56 +0000 |
commit | a36bf8f74180e834c6bf2db867796fd5338495ab (patch) | |
tree | 200b94dca207fc74f01852c963aa08adcbc8bbbc /lib/CodeGen/CodeGenFunction.h | |
parent | 600d47e8d5edc93a08ada8086db23d1d434ce583 (diff) |
Fix lifetime of conditional temporaries. Patch by Victor Zverovich!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index d96c355101..0be527c8d4 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -176,19 +176,23 @@ 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: + /// StartConditionalBranch - 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 + /// This is used to make sure that any temporaries created in the conditional /// branch are only destroyed if the branch is taken. - void PushConditionalTempDestruction(); + void StartConditionalBranch() { + ++ConditionalBranchLevel; + } - /// PopConditionalTempDestruction - Should be called after a conditional - /// part of an expression has been emitted. - void PopConditionalTempDestruction(); + /// FinishConditionalBranch - Should be called after a conditional part of an + /// expression has been emitted. + void FinishConditionalBranch() { + --ConditionalBranchLevel; + } private: CGDebugInfo *DebugInfo; @@ -298,10 +302,10 @@ 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; + /// ConditionalBranchLevel - Contains the nesting level of the current + /// conditional branch. This is used so that we know if a temporary should be + /// destroyed conditionally. + unsigned ConditionalBranchLevel; /// ByrefValueInfoMap - For each __block variable, contains a pair of the LLVM |