[cfe-commits] r152163 - in /cfe/trunk: lib/Analysis/CFG.cpp test/SemaObjC/warn-unreachable.m
Ted Kremenek
kremenek at apple.com
Tue Mar 6 15:40:47 PST 2012
Author: kremenek
Date: Tue Mar 6 17:40:47 2012
New Revision: 152163
URL: http://llvm.org/viewvc/llvm-project?rev=152163&view=rev
Log:
Fix horrific CFG bug where '@autoreleasepool' would be put in a dangling block in the CFG.
Added:
cfe/trunk/test/SemaObjC/warn-unreachable.m
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=152163&r1=152162&r2=152163&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Mar 6 17:40:47 2012
@@ -339,6 +339,7 @@
CFGBlock *VisitLabelStmt(LabelStmt *L);
CFGBlock *VisitMemberExpr(MemberExpr *M, AddStmtChoice asc);
CFGBlock *VisitObjCAtCatchStmt(ObjCAtCatchStmt *S);
+ CFGBlock *VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S);
CFGBlock *VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S);
CFGBlock *VisitObjCAtThrowStmt(ObjCAtThrowStmt *S);
CFGBlock *VisitObjCAtTryStmt(ObjCAtTryStmt *S);
@@ -1014,6 +1015,9 @@
case Stmt::ObjCAtCatchStmtClass:
return VisitObjCAtCatchStmt(cast<ObjCAtCatchStmt>(S));
+ case Stmt::ObjCAutoreleasePoolStmtClass:
+ return VisitObjCAutoreleasePoolStmt(cast<ObjCAutoreleasePoolStmt>(S));
+
case Stmt::ObjCAtSynchronizedStmtClass:
return VisitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(S));
@@ -1929,6 +1933,12 @@
return addStmt(S->getCollection());
}
+CFGBlock *CFGBuilder::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
+ // Inline the body.
+ return addStmt(S->getSubStmt());
+ // TODO: consider adding cleanups for the end of @autoreleasepool scope.
+}
+
CFGBlock *CFGBuilder::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
// FIXME: Add locking 'primitives' to CFG for @synchronized.
Added: cfe/trunk/test/SemaObjC/warn-unreachable.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-unreachable.m?rev=152163&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/warn-unreachable.m (added)
+++ cfe/trunk/test/SemaObjC/warn-unreachable.m Tue Mar 6 17:40:47 2012
@@ -0,0 +1,17 @@
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
+
+// This previously triggered a warning from -Wunreachable-code because of
+// a busted CFG.
+typedef signed char BOOL;
+BOOL radar10989084() {
+ @autoreleasepool { // no-warning
+ return __objc_yes;
+ }
+}
+
+// Test the warning works.
+void test_unreachable() {
+ return;
+ return; // expected-warning {{will never be executed}}
+}
+
More information about the cfe-commits
mailing list