diff options
author | Anders Carlsson <andersca@mac.com> | 2010-01-24 00:20:05 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-01-24 00:20:05 +0000 |
commit | 60ddba67a883d76743feef04b8dcff262cb87d59 (patch) | |
tree | a775d17551673c6de5a185ab5447ccbb19dce583 /clang/lib | |
parent | 0bd52403d456bd33a15c2c4a53cfadda10f70e77 (diff) | |
download | bcm5719-llvm-60ddba67a883d76743feef04b8dcff262cb87d59.tar.gz bcm5719-llvm-60ddba67a883d76743feef04b8dcff262cb87d59.zip |
Fix a nasty bug where temporaries weren't marked as being conditional in some cases.
llvm-svn: 94341
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index f0a5c64d2fd..5db441197e1 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -431,7 +431,11 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, EmitBranchOnBoolExpr(CondBOp->getLHS(), LHSTrue, FalseBlock); EmitBlock(LHSTrue); + // Any temporaries created here are conditional. + StartConditionalBranch(); EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock); + FinishConditionalBranch(); + return; } else if (CondBOp->getOpcode() == BinaryOperator::LOr) { // If we have "0 || X", simplify the code. "1 || X" would have constant @@ -454,7 +458,11 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, EmitBranchOnBoolExpr(CondBOp->getLHS(), TrueBlock, LHSFalse); EmitBlock(LHSFalse); + // Any temporaries created here are conditional. + StartConditionalBranch(); EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock); + FinishConditionalBranch(); + return; } } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 30ad663771b..684d1ce2859 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -283,6 +283,9 @@ public: /// FinishConditionalBranch - Should be called after a conditional part of an /// expression has been emitted. void FinishConditionalBranch() { + assert(ConditionalBranchLevel != 0 && + "Conditional branch mismatch!"); + --ConditionalBranchLevel; } |