aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-19 03:13:26 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-19 03:13:26 +0000
commitd40baf6a77f6353a93f181da5d1347d3730aad37 (patch)
tree4caf87f08fc540422ce29ede987e2c3910d677f1 /lib/Analysis/CFG.cpp
parent15e310a3b970b64a84cb30f0005bc396b4d978cb (diff)
Fix a -Wuninitialized warning; it's actually a false positive,
but it's not reasonable for the diagnostic to figure that out. Pointed out by Benjamin Kramer. Also clarify the logic here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFG.cpp')
-rw-r--r--lib/Analysis/CFG.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index abb8df5854..1ae5d40f4d 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -1223,10 +1223,18 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(AbstractConditionalOperator *C,
addSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock);
addSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock);
Block->setTerminator(C);
- CFGBlock *result;
Expr *condExpr = C->getCond();
+
+ CFGBlock *result = 0;
+
+ // Run the condition expression if it's not trivially expressed in
+ // terms of the opaque value (or if there is no opaque value).
if (condExpr != opaqueValue) result = addStmt(condExpr);
- if (BCO) result = addStmt(BCO->getCommon());
+
+ // Before that, run the common subexpression if there was one.
+ // At least one of this or the above will be run.
+ if (opaqueValue) result = addStmt(BCO->getCommon());
+
return result;
}