summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-15 07:01:20 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-15 07:01:20 +0000
commit7b31a61d10851a23664afbd57e51b4ec2c3afd17 (patch)
treea38d3c8c6d3b84d1fe24539840057ea1f4d81854
parent7d9edf670b518e80af18a39366a316f1288280f5 (diff)
downloadbcm5719-llvm-7b31a61d10851a23664afbd57e51b4ec2c3afd17.tar.gz
bcm5719-llvm-7b31a61d10851a23664afbd57e51b4ec2c3afd17.zip
Relax assertion in CFG builder when processing ForStmts. This fixes an assertion failure
on code containing GNU statement expressions reported in PR 8141. llvm-svn: 113953
-rw-r--r--clang/lib/Analysis/CFG.cpp3
-rw-r--r--clang/test/Analysis/misc-ps.m6
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index e297ec4856c..cc3a3888626 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -991,7 +991,8 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
if (Stmt* C = F->getCond()) {
Block = ExitConditionBlock;
EntryConditionBlock = addStmt(C);
- assert(Block == EntryConditionBlock);
+ assert(Block == EntryConditionBlock ||
+ (Block == 0 && EntryConditionBlock == Succ));
// If this block contains a condition variable, add both the condition
// variable and initializer to the CFG.
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index a44eb0c18d3..bb70c90e6a6 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -1129,3 +1129,9 @@ void rdar6351970_c() {
}
@end
+// PR 8149 - GNU statement expression in condition of ForStmt.
+// This previously triggered an assertion failure in CFGBuilder.
+void pr8149(void) {
+ for (; ({ do { } while (0); 0; });) { }
+}
+
OpenPOWER on IntegriCloud