aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-27 23:02:32 +0000
committerChris Lattner <sabre@nondot.org>2011-02-27 23:02:32 +0000
commitc2c90011a688c04a4e980282f08c267e081c4b00 (patch)
treef543ec6056c1b38c7b6bc1ae2fb4b4b1090734e1 /lib/CodeGen/CGStmt.cpp
parenta02411e4d58b1730bea2a990822858ecc31e8eb1 (diff)
Change the interface to ConstantFoldsToSimpleInteger to not encode
a bool + success into one tri-state integer, simplifying things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index cd238112ed..1ed7c3d911 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -359,10 +359,12 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
// If the condition constant folds and can be elided, try to avoid emitting
// the condition and the dead arm of the if/else.
- if (int Cond = ConstantFoldsToSimpleInteger(S.getCond())) {
+ bool CondConstant;
+ if (ConstantFoldsToSimpleInteger(S.getCond(), CondConstant)) {
// Figure out which block (then or else) is executed.
- const Stmt *Executed = S.getThen(), *Skipped = S.getElse();
- if (Cond == -1) // Condition false?
+ const Stmt *Executed = S.getThen();
+ const Stmt *Skipped = S.getElse();
+ if (!CondConstant) // Condition false?
std::swap(Executed, Skipped);
// If the skipped block has no labels in it, just emit the executed block.