[llvm-branch-commits] [cfe-branch] r167789 - in /cfe/branches/release_32: ./ lib/Analysis/CFG.cpp test/Analysis/dead-stores.cpp test/SemaCXX/warn-unreachable.cpp
Ted Kremenek
kremenek at apple.com
Mon Nov 12 16:13:40 PST 2012
Author: kremenek
Date: Mon Nov 12 18:13:40 2012
New Revision: 167789
URL: http://llvm.org/viewvc/llvm-project?rev=167789&view=rev
Log:
Merged 167788, and bad CFG construction bug, into the LLVM 3.2 release.
Modified:
cfe/branches/release_32/ (props changed)
cfe/branches/release_32/lib/Analysis/CFG.cpp
cfe/branches/release_32/test/Analysis/dead-stores.cpp
cfe/branches/release_32/test/SemaCXX/warn-unreachable.cpp (props changed)
Propchange: cfe/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 12 18:13:40 2012
@@ -1,3 +1,3 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:167749,167762
+/cfe/trunk:167749,167762,167788
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_32/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/lib/Analysis/CFG.cpp?rev=167789&r1=167788&r2=167789&view=diff
==============================================================================
--- cfe/branches/release_32/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/release_32/lib/Analysis/CFG.cpp Mon Nov 12 18:13:40 2012
@@ -1648,8 +1648,10 @@
// If the type of VD is a VLA, then we must process its size expressions.
for (const VariableArrayType* VA = FindVA(VD->getType().getTypePtr());
- VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
- Block = addStmt(VA->getSizeExpr());
+ VA != 0; VA = FindVA(VA->getElementType().getTypePtr())) {
+ if (CFGBlock *newBlock = addStmt(VA->getSizeExpr()))
+ LastBlock = newBlock;
+ }
// Remove variable from local scope.
if (ScopePos && VD == *ScopePos)
@@ -1767,7 +1769,7 @@
// Add the condition as the last statement in the new block. This may create
// new blocks as the condition may contain control-flow. Any newly created
// blocks will be pointed to be "Block".
- Block = addStmt(I->getCond());
+ CFGBlock *LastBlock = addStmt(I->getCond());
// Finally, if the IfStmt contains a condition variable, add both the IfStmt
// and the condition variable initialization to the CFG.
@@ -1775,11 +1777,11 @@
if (Expr *Init = VD->getInit()) {
autoCreateBlock();
appendStmt(Block, I->getConditionVariableDeclStmt());
- addStmt(Init);
+ LastBlock = addStmt(Init);
}
}
- return Block;
+ return LastBlock;
}
@@ -2611,7 +2613,7 @@
// Add the terminator and condition in the switch block.
SwitchTerminatedBlock->setTerminator(Terminator);
Block = SwitchTerminatedBlock;
- Block = addStmt(Terminator->getCond());
+ CFGBlock *LastBlock = addStmt(Terminator->getCond());
// Finally, if the SwitchStmt contains a condition variable, add both the
// SwitchStmt and the condition variable initialization to the CFG.
@@ -2619,11 +2621,11 @@
if (Expr *Init = VD->getInit()) {
autoCreateBlock();
appendStmt(Block, Terminator->getConditionVariableDeclStmt());
- addStmt(Init);
+ LastBlock = addStmt(Init);
}
}
- return Block;
+ return LastBlock;
}
static bool shouldAddCase(bool &switchExclusivelyCovered,
@@ -2807,8 +2809,7 @@
assert(Terminator->getTryBlock() && "try must contain a non-NULL body");
Block = NULL;
- Block = addStmt(Terminator->getTryBlock());
- return Block;
+ return addStmt(Terminator->getTryBlock());
}
CFGBlock *CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt *CS) {
@@ -2949,15 +2950,15 @@
addLocalScopeAndDtors(S->getLoopVarStmt());
// Populate a new block to contain the loop body and loop variable.
- Block = addStmt(S->getBody());
+ addStmt(S->getBody());
if (badCFG)
return 0;
- Block = addStmt(S->getLoopVarStmt());
+ CFGBlock *LoopVarStmtBlock = addStmt(S->getLoopVarStmt());
if (badCFG)
return 0;
// This new body block is a successor to our condition block.
- addSuccessor(ConditionBlock, KnownVal.isFalse() ? 0 : Block);
+ addSuccessor(ConditionBlock, KnownVal.isFalse() ? 0 : LoopVarStmtBlock);
}
// Link up the condition block with the code that follows the loop (the
Modified: cfe/branches/release_32/test/Analysis/dead-stores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/test/Analysis/dead-stores.cpp?rev=167789&r1=167788&r2=167789&view=diff
==============================================================================
--- cfe/branches/release_32/test/Analysis/dead-stores.cpp (original)
+++ cfe/branches/release_32/test/Analysis/dead-stores.cpp Mon Nov 12 18:13:40 2012
@@ -126,3 +126,26 @@
return 1;
}
+
+int test_6_aux(unsigned x);
+
+void test_6() {
+ unsigned currDestLen = 0; // no-warning
+ try {
+ while (test_6_aux(currDestLen)) {
+ currDestLen += 2; // no-warning
+ }
+ }
+ catch (void *) {}
+}
+
+void test_6b() {
+ unsigned currDestLen = 0; // no-warning
+ try {
+ while (test_6_aux(currDestLen)) {
+ currDestLen += 2; // expected-warning {{Value stored to 'currDestLen' is never read}}
+ break;
+ }
+ }
+ catch (void *) {}
+}
Propchange: cfe/branches/release_32/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 12 18:13:40 2012
@@ -1,2 +1,2 @@
/cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,167749,167762
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,167749,167762,167788
More information about the llvm-branch-commits
mailing list