diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-03-06 23:40:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-03-06 23:40:47 +0000 |
commit | 8e282c332f8ad51dedf86a185a4dcb78ef93fb51 (patch) | |
tree | c090604c1662a9cbcd2e28683e4a1d79d412f57a | |
parent | e5de3767186e2a31659c91c55a9665eff077eae6 (diff) |
Fix horrific CFG bug where '@autoreleasepool' would be put in a dangling block in the CFG.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152163 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/CFG.cpp | 10 | ||||
-rw-r--r-- | test/SemaObjC/warn-unreachable.m | 17 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 8ba6d448da..b06cf44344 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -339,6 +339,7 @@ private: 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 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc) { 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 @@ CFGBlock *CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { 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. diff --git a/test/SemaObjC/warn-unreachable.m b/test/SemaObjC/warn-unreachable.m new file mode 100644 index 0000000000..832cbd23d2 --- /dev/null +++ b/test/SemaObjC/warn-unreachable.m @@ -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}} +} + |