aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-03-29 00:42:56 +0000
committerTed Kremenek <kremenek@apple.com>2013-03-29 00:42:56 +0000
commit5062bb22706c8f2ceec5815533ff5a88d169d098 (patch)
tree793f875ac1de2908019c1d59b6a2d6cdee29adc4
parent84e480447a20a8a5ed9ee561c8901475f0a4fd9c (diff)
[cfg] Always guard (when AddStaticInitBranches == true) DeclStmts for static variables, not just ones with explicit initializers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178322 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/CFG.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 91a7fdf6bc..1adb8b84e4 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -1654,24 +1654,24 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(DeclStmt *DS) {
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(DeclStmt *DS) {
++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;
}