[llvm-branch-commits] [cfe-branch] r102615 - in /cfe/branches/Apple/williamson: lib/Analysis/CFG.cpp test/Analysis/misc-ps.m
Daniel Dunbar
daniel at zuster.org
Thu Apr 29 08:58:06 PDT 2010
Author: ddunbar
Date: Thu Apr 29 10:58:06 2010
New Revision: 102615
URL: http://llvm.org/viewvc/llvm-project?rev=102615&view=rev
Log:
Fix CFG crasher involving statement expressions reported in PR 6938.
Modified:
cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp
cfe/branches/Apple/williamson/test/Analysis/misc-ps.m
Modified: cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp?rev=102615&r1=102614&r2=102615&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/Apple/williamson/lib/Analysis/CFG.cpp Thu Apr 29 10:58:06 2010
@@ -498,8 +498,16 @@
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = addStmt(B->getRHS());
- if (!FinishBlock(RHSBlock))
- return 0;
+
+ if (RHSBlock) {
+ if (!FinishBlock(RHSBlock))
+ return 0;
+ }
+ else {
+ // Create an empty block for cases where the RHS doesn't require
+ // any explicit statements in the CFG.
+ RHSBlock = createBlock();
+ }
// See if this is a known constant.
TryResult KnownVal = TryEvaluateBool(B->getLHS());
Modified: cfe/branches/Apple/williamson/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/Analysis/misc-ps.m?rev=102615&r1=102614&r2=102615&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/Analysis/misc-ps.m (original)
+++ cfe/branches/Apple/williamson/test/Analysis/misc-ps.m Thu Apr 29 10:58:06 2010
@@ -933,3 +933,27 @@
struct s_rev95547 w2 = w;
w2.z1.x += 20.0; // no-warning
}
+
+//===----------------------------------------------------------------------===//
+// Test handling statement expressions that don't populate a CFG block that
+// is used to represent the computation of the RHS of a logical operator.
+// This previously triggered a crash.
+//===----------------------------------------------------------------------===//
+
+void pr6938() {
+ if (1 && ({
+ while (0);
+ 0;
+ }) == 0) {
+ }
+}
+
+void pr6938_b() {
+ if (1 && *({ // expected-warning{{Dereference of null pointer}}
+ while (0) {}
+ ({
+ (int *) 0;
+ });
+ }) == 0) {
+ }
+}
More information about the llvm-branch-commits
mailing list