summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-21 15:38:55 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-21 15:38:55 +0000
commitc5644e1b9750c1e5b4c0f10f69efa895c10a9fec (patch)
tree53087c62b26ade7e206ca45c8aa6d4c2a531a09a
parenta11e9827b1c83d8193b0f72134add936cacafa13 (diff)
downloadbcm5719-llvm-c5644e1b9750c1e5b4c0f10f69efa895c10a9fec.tar.gz
bcm5719-llvm-c5644e1b9750c1e5b4c0f10f69efa895c10a9fec.zip
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>. llvm-svn: 117016
-rw-r--r--clang/lib/Checker/ObjCAtSyncChecker.cpp8
-rw-r--r--clang/test/Analysis/misc-ps.m14
2 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Checker/ObjCAtSyncChecker.cpp b/clang/lib/Checker/ObjCAtSyncChecker.cpp
index dc2e664e054..41580955a9a 100644
--- a/clang/lib/Checker/ObjCAtSyncChecker.cpp
+++ b/clang/lib/Checker/ObjCAtSyncChecker.cpp
@@ -75,13 +75,15 @@ void ObjCAtSyncChecker::PreVisitObjCAtSynchronizedStmt(CheckerContext &C,
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);
}
-
+
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index bb70c90e6a6..2409be351c7 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -1110,6 +1110,20 @@ void rdar6351970_c() {
@synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}}
}
+@interface Rdar8578650
+- (id) foo8578650;
+@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;
OpenPOWER on IntegriCloud