[cfe-commits] r70620 - in /cfe/trunk: lib/AST/CFG.cpp test/Analysis/NSString.m
Ted Kremenek
kremenek at apple.com
Fri May 1 18:49:14 PDT 2009
Author: kremenek
Date: Fri May 1 20:49:13 2009
New Revision: 70620
URL: http://llvm.org/viewvc/llvm-project?rev=70620&view=rev
Log:
Add CFG support for @synchronized. This fixes <rdar://problem/6848820>.
Modified:
cfe/trunk/lib/AST/CFG.cpp
cfe/trunk/test/Analysis/NSString.m
Modified: cfe/trunk/lib/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CFG.cpp?rev=70620&r1=70619&r2=70620&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Fri May 1 20:49:13 2009
@@ -140,9 +140,7 @@
// 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 @@
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();
}
Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=70620&r1=70619&r2=70620&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Fri May 1 20:49:13 2009
@@ -271,3 +271,11 @@
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}}
+ }
+}
+
More information about the cfe-commits
mailing list