Add CFG support for @synchronized. This fixes <rdar://problem/6848820>.

llvm-svn: 70620
This commit is contained in:
Ted Kremenek 2009-05-02 01:49:13 +00:00
parent e6b424e53a
commit 49805454e6
2 changed files with 19 additions and 3 deletions

View File

@ -140,9 +140,7 @@ public:
// a 'return'.
CFGBlock* VisitObjCAtThrowStmt(ObjCAtThrowStmt* S);
CFGBlock* VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S){
return NYS();
}
CFGBlock* VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S);
// Blocks.
CFGBlock* VisitBlockExpr(BlockExpr* E) { return NYS(); }
@ -935,6 +933,16 @@ CFGBlock* CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
return addStmt(S->getCollection());
}
CFGBlock* CFGBuilder::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S) {
// FIXME: Add locking 'primitives' to CFG for @synchronized.
// Inline the body.
Visit(S->getSynchBody());
// Inline the sync expression.
return Visit(S->getSynchExpr());
}
CFGBlock* CFGBuilder::VisitObjCAtTryStmt(ObjCAtTryStmt* S) {
return NYS();
}

View File

@ -271,3 +271,11 @@ typedef NSString* WonkyTypedef;
void test_isTrackedObjectType(void) {
NSString *str = [TestIsTracked newString]; // expected-warning{{Potential leak}}
}
// Test @synchronized
void test_synchronized(id x) {
@synchronized(x) {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain]; // expected-warning {{leak}}
}
}