summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorGabor Horvath <xazax@google.com>2019-12-23 10:01:00 -0800
committerGabor Horvath <xazax@google.com>2019-12-23 16:35:37 -0800
commit379613d7c7fa9698a2c300f4067165b5309a5e6e (patch)
treee310e2bfae0705b39ed0aa742584a6e63c923046 /clang/lib/Analysis
parent25cf5d97ace15c6835f6ad222c5a3aaa02c99522 (diff)
downloadbcm5719-llvm-379613d7c7fa9698a2c300f4067165b5309a5e6e.tar.gz
bcm5719-llvm-379613d7c7fa9698a2c300f4067165b5309a5e6e.zip
[CFG] Fix an assertion failure with static initializers
The CFGBlock::getLastCondition was not prepared for static initializer branches. This patch also revamps CFG unit tests. Earlier the lifetime of the AST was smaller than the CFG. So all the AST pointers within the CFG blocks were dangling. This was OK, since none of the tests dereferenced those pointers. This was, however, a timed bomb. There were patches in the past that were reverted partially due to this problem. Differential revision: https://reviews.llvm.org/D71791
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 07945a80a31..4c1ea8995f9 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5919,7 +5919,7 @@ const Expr *CFGBlock::getLastCondition() const {
return nullptr;
const Stmt *Cond = StmtElem->getStmt();
- if (isa<ObjCForCollectionStmt>(Cond))
+ if (isa<ObjCForCollectionStmt>(Cond) || isa<DeclStmt>(Cond))
return nullptr;
// Only ObjCForCollectionStmt is known not to be a non-Expr terminator, hence
OpenPOWER on IntegriCloud