summaryrefslogtreecommitdiffstats
path: root/clang/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
commit68cc3350a80fa3170e1669ec13c7f245355f693d (patch)
tree206a60972b3a2adc229707a42d84ce3c152a5e1d /clang/lib/Analysis/CFG.cpp
parent837796754391377198973bac26fb2f229a4665f6 (diff)
downloadbcm5719-llvm-68cc3350a80fa3170e1669ec13c7f245355f693d.tar.gz
bcm5719-llvm-68cc3350a80fa3170e1669ec13c7f245355f693d.zip
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. llvm-svn: 126017
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r--clang/lib/Analysis/CFG.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index abb8df58544..1ae5d40f4d1 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud