[cfe-commits] r126017 - /cfe/trunk/lib/Analysis/CFG.cpp

John McCall rjmccall at apple.com
Fri Feb 18 19:13:26 PST 2011


Author: rjmccall
Date: Fri Feb 18 21:13:26 2011
New Revision: 126017

URL: http://llvm.org/viewvc/llvm-project?rev=126017&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=126017&r1=126016&r2=126017&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 18 21:13:26 2011
@@ -1223,10 +1223,18 @@
     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;
 }
 





More information about the cfe-commits mailing list