Author: george.karpenkov Date: Mon Dec 10 17:13:58 2018 New Revision: 348821
URL: http://llvm.org/viewvc/llvm-project?rev=348821&view=rev Log: [analyzer] Hack for backwards compatibility for options for RetainCountChecker. To be removed once the clients update. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp cfe/trunk/test/Analysis/test-separate-retaincount.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=348821&r1=348820&r2=348821&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp Mon Dec 10 17:13:58 2018 @@ -1530,7 +1530,19 @@ void ento::registerRetainCountChecker(Ch 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; } Modified: cfe/trunk/test/Analysis/test-separate-retaincount.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/test-separate-retaincount.cpp?rev=348821&r1=348820&r2=348821&view=diff ============================================================================== --- cfe/trunk/test/Analysis/test-separate-retaincount.cpp (original) +++ cfe/trunk/test/Analysis/test-separate-retaincount.cpp Mon Dec 10 17:13:58 2018 @@ -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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits