[cfe-commits] r113573 - in /cfe/trunk: lib/Checker/CMakeLists.txt lib/Checker/GRExprEngine.cpp lib/Checker/GRExprEngineInternalChecks.h test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Thu Sep 9 20:05:40 PDT 2010
Author: kremenek
Date: Thu Sep 9 22:05:40 2010
New Revision: 113573
URL: http://llvm.org/viewvc/llvm-project?rev=113573&view=rev
Log:
Implement: <rdar://problem/6351970> rule request: warn if @synchronized mutex can be nil
Modified:
cfe/trunk/lib/Checker/CMakeLists.txt
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Checker/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CMakeLists.txt?rev=113573&r1=113572&r2=113573&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CMakeLists.txt (original)
+++ cfe/trunk/lib/Checker/CMakeLists.txt Thu Sep 9 22:05:40 2010
@@ -18,6 +18,7 @@
BugReporterVisitors.cpp
BuiltinFunctionChecker.cpp
CFRefCount.cpp
+ CStringChecker.cpp
CallAndMessageChecker.cpp
CastSizeChecker.cpp
CastToStructChecker.cpp
@@ -29,7 +30,6 @@
Checker.cpp
CheckerHelpers.cpp
CocoaConventions.cpp
- CStringChecker.cpp
DereferenceChecker.cpp
DivZeroChecker.cpp
Environment.cpp
@@ -54,6 +54,7 @@
NSErrorChecker.cpp
NoReturnFunctionChecker.cpp
OSAtomicChecker.cpp
+ ObjCAtSyncChecker.cpp
ObjCUnusedIVarsChecker.cpp
PathDiagnostic.cpp
PlistDiagnostics.cpp
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=113573&r1=113572&r2=113573&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Sep 9 22:05:40 2010
@@ -373,6 +373,7 @@
RegisterUndefCapturedBlockVarChecker(Eng);
RegisterUndefResultChecker(Eng);
RegisterStackAddrLeakChecker(Eng);
+ RegisterObjCAtSyncChecker(Eng);
// This is not a checker yet.
RegisterNoReturnFunctionChecker(Eng);
Modified: cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h?rev=113573&r1=113572&r2=113573&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h (original)
+++ cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h Thu Sep 9 22:05:40 2010
@@ -31,6 +31,7 @@
void RegisterDivZeroChecker(GRExprEngine &Eng);
void RegisterFixedAddressChecker(GRExprEngine &Eng);
void RegisterNoReturnFunctionChecker(GRExprEngine &Eng);
+void RegisterObjCAtSyncChecker(GRExprEngine &Eng);
void RegisterPointerArithChecker(GRExprEngine &Eng);
void RegisterPointerSubChecker(GRExprEngine &Eng);
void RegisterReturnPointerRangeChecker(GRExprEngine &Eng);
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=113573&r1=113572&r2=113573&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Thu Sep 9 22:05:40 2010
@@ -1094,4 +1094,19 @@
*p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
}
+// <rdar://problem/6351970> rule request: warn if synchronization mutex can be nil
+void rdar6351970() {
+ id x = 0;
+ @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
+}
+
+void rdar6351970_b(id x) {
+ if (!x)
+ @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
+}
+
+void rdar6351970_c() {
+ id x;
+ @synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}}
+}
More information about the cfe-commits
mailing list