[cfe-commits] r113826 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/misc-ps-region-store.m
Ted Kremenek
kremenek at apple.com
Mon Sep 13 18:13:32 PDT 2010
Author: kremenek
Date: Mon Sep 13 20:13:32 2010
New Revision: 113826
URL: http://llvm.org/viewvc/llvm-project?rev=113826&view=rev
Log:
Fix CFGBuilder crash reported in PR 8141.
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.m
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=113826&r1=113825&r2=113826&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon Sep 13 20:13:32 2010
@@ -525,8 +525,12 @@
AppendStmt(Block, B, asc);
}
- Visit(B->getRHS());
- return Visit(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
+ // If visiting RHS causes us to finish 'Block' and the LHS doesn't
+ // create a new block, then we should return RBlock. Otherwise
+ // we'll incorrectly return NULL.
+ CFGBlock *RBlock = Visit(B->getRHS());
+ CFGBlock *LBlock = Visit(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
+ return LBlock ? LBlock : RBlock;
}
return VisitStmt(B, asc);
Modified: cfe/trunk/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.m?rev=113826&r1=113825&r2=113826&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Mon Sep 13 20:13:32 2010
@@ -1142,3 +1142,17 @@
}
}
+// PR 8141. Previously the statement expression in the for loop caused
+// the CFG builder to crash.
+struct list_pr8141
+{
+ struct list_pr8141 *tail;
+};
+
+struct list_pr8141 *
+pr8141 (void) {
+ struct list_pr8141 *items;
+ for (;; items = ({ do { } while (0); items->tail; })) // expected-warning{{Dereference of undefined pointer value}}
+ {
+ }
+}
More information about the cfe-commits
mailing list