r178322 - [cfg] Always guard (when AddStaticInitBranches == true) DeclStmts for static variables, not just ones with explicit initializers

Ted Kremenek kremenek at apple.com
Thu Mar 28 17:42:56 PDT 2013


Author: kremenek
Date: Thu Mar 28 19:42:56 2013
New Revision: 178322

URL: http://llvm.org/viewvc/llvm-project?rev=178322&view=rev
Log:
[cfg] Always guard (when AddStaticInitBranches == true) DeclStmts for static variables, not just ones with explicit initializers

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=178322&r1=178321&r2=178322&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Mar 28 19:42:56 2013
@@ -1654,24 +1654,24 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(D
   bool HasTemporaries = false;
 
   // Guard static initializers under a branch.
-  CFGBlock *blockBeforeInit = 0;
+  CFGBlock *blockAfterStaticInit = 0;
+
+  if (BuildOpts.AddStaticInitBranches && VD->isStaticLocal()) {
+    // For static variables, we need to create a branch to track
+    // whether or not they are initialized.
+    if (Block) {
+      Succ = Block;
+      Block = 0;
+      if (badCFG)
+        return 0;
+    }
+    blockAfterStaticInit = Succ;
+  }
 
   // Destructors of temporaries in initialization expression should be called
   // after initialization finishes.
   Expr *Init = VD->getInit();
   if (Init) {
-    if (BuildOpts.AddStaticInitBranches && VD->isStaticLocal()) {
-      // For static variables, we need to create a branch to track
-      // whether or not they are initialized.
-      if (Block) {
-        Succ = Block;
-        Block = 0;
-        if (badCFG)
-          return 0;
-      }
-      blockBeforeInit = Succ;
-    }
-
     IsReference = VD->getType()->isReferenceType();
     HasTemporaries = isa<ExprWithCleanups>(Init);
 
@@ -1716,11 +1716,11 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(D
     ++ScopePos;
 
   CFGBlock *B = LastBlock;
-  if (blockBeforeInit) {
+  if (blockAfterStaticInit) {
     Succ = B;
     Block = createBlock(false);
     Block->setTerminator(DS);
-    addSuccessor(Block, blockBeforeInit);
+    addSuccessor(Block, blockAfterStaticInit);
     addSuccessor(Block, B);
     B = Block;
   }





More information about the cfe-commits mailing list