forked from OSchip/llvm-project
Fix horrific CFG bug where '@autoreleasepool' would be put in a dangling block in the CFG.
llvm-svn: 152163
This commit is contained in:
parent
80893ce5f5
commit
5022f1dffe
|
@ -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.
|
||||
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue