[cfe-commits] r117016 - in /cfe/trunk: lib/Checker/ObjCAtSyncChecker.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Thu Oct 21 08:38:55 PDT 2010


Author: kremenek
Date: Thu Oct 21 10:38:55 2010
New Revision: 117016

URL: http://llvm.org/viewvc/llvm-project?rev=117016&view=rev
Log:
Tweak the ObjCAtSyncChecker to assume that a mutex is non-nil after checking that it is
nil.  Otherwise we can get false paths where a second @synchronized using the mutex
can have a bogus warning.  Fixes <rdar://problem/8578650>.

Modified:
    cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp?rev=117016&r1=117015&r2=117016&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp (original)
+++ cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp Thu Oct 21 10:38:55 2010
@@ -75,13 +75,15 @@
                                   Ex);
 
         C.EmitReport(report);
+        return;
       }
     }
-    // From this point forward, we know that the mutex is null.
-    C.addTransition(nullState);
+    // Don't add a transition for 'nullState'.  If the value is
+    // under-constrained to be null or non-null, assume it is non-null
+    // afterwards.
   }
 
   if (notNullState)
     C.addTransition(notNullState);
 }
- 
+

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=117016&r1=117015&r2=117016&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Thu Oct 21 10:38:55 2010
@@ -1110,6 +1110,20 @@
   @synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}}
 }
 
+ at interface Rdar8578650
+- (id) foo8578650;
+ at end
+
+void rdar8578650(id x) {
+  @synchronized (x) {
+    [x foo8578650];
+  }
+  // At this point we should assume that 'x' is not nil, not
+  // the inverse.
+  @synchronized (x) { // no-warning
+  }
+}
+
 // <rdar://problem/6352035> rule request: direct structure member access null pointer dereference
 @interface RDar6352035 {
   int c;





More information about the cfe-commits mailing list