]> granicus.if.org Git - clang/commitdiff
[analyzer] Hack for backwards compatibility for options for RetainCountChecker.
authorGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 11 Dec 2018 01:13:58 +0000 (01:13 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 11 Dec 2018 01:13:58 +0000 (01:13 +0000)
To be removed once the clients update.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348821 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
test/Analysis/test-separate-retaincount.cpp

index 8d0d407eab83d66dac73d959e5112dfa2aebe235..488cf6d3eb883f73d1f5d88eb83295f5d609535d 100644 (file)
@@ -1530,7 +1530,19 @@ void ento::registerRetainCountChecker(CheckerManager &Mgr) {
   Chk->TrackObjCAndCFObjects = true;
 }
 
+// FIXME: remove this, hack for backwards compatibility:
+// it should be possible to enable the NS/CF retain count checker as
+// osx.cocoa.RetainCount, and it should be possible to disable
+// osx.OSObjectRetainCount using osx.cocoa.RetainCount:CheckOSObject=false.
+static bool hasPrevCheckOSObjectOptionDisabled(AnalyzerOptions &Options) {
+  auto I = Options.Config.find("osx.cocoa.RetainCount:CheckOSObject");
+  if (I != Options.Config.end())
+    return I->getValue() == "false";
+  return false;
+}
+
 void ento::registerOSObjectRetainCountChecker(CheckerManager &Mgr) {
   auto *Chk = Mgr.registerChecker<RetainCountChecker>();
-  Chk->TrackOSObjects = true;
+  if (!hasPrevCheckOSObjectOptionDisabled(Mgr.getAnalyzerOptions()))
+    Chk->TrackOSObjects = true;
 }
index 36bcc48df2b8a1237315fed320b07e4ff06affc8..be6534f544bddaea5c05f2d4b16e1f5078a0be91 100644 (file)
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-disable-checker osx.cocoa.RetainCount -DNO_CF_OBJECT -verify %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-disable-checker osx.OSObjectRetainCount -DNO_OS_OBJECT -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-config "osx.cocoa.RetainCount:CheckOSObject=false" -DNO_OS_OBJECT -verify %s
 
 typedef const void * CFTypeRef;
 extern CFTypeRef CFRetain(CFTypeRef cf);