// a 'return'.
CFGBlock* VisitObjCAtThrowStmt(ObjCAtThrowStmt* S);
- CFGBlock* VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S){
- return NYS();
- }
+ CFGBlock* VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt* S);
// Blocks.
CFGBlock* VisitBlockExpr(BlockExpr* E) { return NYS(); }
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();
}
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}}
+ }
+}
+