Index: include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h =================================================================== --- include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h +++ include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h @@ -18,13 +18,17 @@ namespace clang { +class LangOptions; + namespace ento { + class CheckerManager; class CheckerRegistry; #define GET_CHECKERS #define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ - void register##CLASS(CheckerManager &mgr); + void register##CLASS(CheckerManager &mgr); \ + bool shouldRegister##CLASS(const LangOptions &LO); #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER #undef GET_CHECKERS Index: include/clang/StaticAnalyzer/Core/Checker.h =================================================================== --- include/clang/StaticAnalyzer/Core/Checker.h +++ include/clang/StaticAnalyzer/Core/Checker.h @@ -14,6 +14,7 @@ #define LLVM_CLANG_STATICANALYZER_CORE_CHECKER_H #include "clang/Analysis/ProgramPoint.h" +#include "clang/Basic/LangOptions.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/Support/Casting.h" Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h =================================================================== --- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h +++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h @@ -69,6 +69,7 @@ class AnalyzerOptions; class DiagnosticsEngine; +class LangOptions; namespace ento { @@ -80,21 +81,24 @@ /// "core.builtin", or the full name "core.builtin.NoReturnFunctionChecker". class CheckerRegistry { public: - CheckerRegistry(ArrayRef plugins, DiagnosticsEngine &diags); + CheckerRegistry(ArrayRef plugins, DiagnosticsEngine &diags, + const LangOptions &LangOpts); /// Initialization functions perform any necessary setup for a checker. /// They should include a call to CheckerManager::registerChecker. using InitializationFunction = void (*)(CheckerManager &); + using ShouldRegisterFunction = bool (*)(const LangOptions &); struct CheckerInfo { InitializationFunction Initialize; + ShouldRegisterFunction ShouldRegister; StringRef FullName; StringRef Desc; StringRef DocumentationUri; - CheckerInfo(InitializationFunction Fn, StringRef Name, StringRef Desc, - StringRef DocsUri) - : Initialize(Fn), FullName(Name), Desc(Desc), + CheckerInfo(InitializationFunction Fn, ShouldRegisterFunction sfn, + StringRef Name, StringRef Desc, StringRef DocsUri) + : Initialize(Fn), ShouldRegister(sfn), FullName(Name), Desc(Desc), DocumentationUri(DocsUri) {} }; @@ -107,11 +111,17 @@ mgr.registerChecker(); } + + template + static bool returnTrue(const LangOptions &LO) { + return true; + } + public: /// Adds a checker to the registry. Use this non-templated overload when your /// checker requires custom initialization. - void addChecker(InitializationFunction Fn, StringRef FullName, StringRef Desc, - StringRef DocsUri); + void addChecker(InitializationFunction Fn, ShouldRegisterFunction sfn, + StringRef FullName, StringRef Desc, StringRef DocsUri); /// Adds a checker to the registry. Use this templated overload when your /// checker does not require any custom initialization. @@ -119,7 +129,8 @@ void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri) { // Avoid MSVC's Compiler Error C2276: // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx - addChecker(&CheckerRegistry::initializeManager, FullName, Desc, DocsUri); + addChecker(&CheckerRegistry::initializeManager, + &CheckerRegistry::returnTrue, FullName, Desc, DocsUri); } /// Initializes a CheckerManager by calling the initialization functions for @@ -142,7 +153,9 @@ mutable CheckerInfoList Checkers; mutable llvm::StringMap Packages; + DiagnosticsEngine &Diags; + const LangOptions &LangOpts; }; } // namespace ento Index: include/clang/StaticAnalyzer/Frontend/FrontendActions.h =================================================================== --- include/clang/StaticAnalyzer/Frontend/FrontendActions.h +++ include/clang/StaticAnalyzer/Frontend/FrontendActions.h @@ -52,10 +52,11 @@ }; void printCheckerHelp(raw_ostream &OS, ArrayRef plugins, - DiagnosticsEngine &diags); + DiagnosticsEngine &diags, const LangOptions &LangOpts); void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins, const AnalyzerOptions &opts, - DiagnosticsEngine &diags); + DiagnosticsEngine &diags, + const LangOptions &LangOpts); void printAnalyzerConfigList(raw_ostream &OS); } // end GR namespace Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -238,7 +238,7 @@ // This should happen AFTER plugins have been loaded! if (Clang->getAnalyzerOpts()->ShowCheckerHelp) { ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins, - Clang->getDiagnostics()); + Clang->getDiagnostics(), Clang->getLangOpts()); return true; } @@ -247,7 +247,8 @@ ento::printEnabledCheckerList(llvm::outs(), Clang->getFrontendOpts().Plugins, *Clang->getAnalyzerOpts(), - Clang->getDiagnostics()); + Clang->getDiagnostics(), + Clang->getLangOpts()); } // Honor -analyzer-config-help. Index: lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp +++ lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp @@ -175,3 +175,7 @@ void ento::registerAnalysisOrderChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterAnalysisOrderChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp +++ lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp @@ -139,3 +139,7 @@ void ento::registerAnalyzerStatsChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterAnalyzerStatsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp +++ lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp @@ -90,3 +90,7 @@ void ento::registerArrayBoundChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterArrayBoundChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp +++ lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp @@ -353,3 +353,7 @@ void ento::registerArrayBoundCheckerV2(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterArrayBoundCheckerV2(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -1242,27 +1242,54 @@ mgr.registerChecker(); } +bool ento::shouldRegisterNilArgChecker(const LangOptions &LO) { + return true; +} + void ento::registerCFNumberChecker(CheckerManager &mgr) { mgr.registerChecker(); } +bool ento::shouldRegisterCFNumberChecker(const LangOptions &LO) { + return true; +} + void ento::registerCFRetainReleaseChecker(CheckerManager &mgr) { mgr.registerChecker(); } +bool ento::shouldRegisterCFRetainReleaseChecker(const LangOptions &LO) { + return true; +} + void ento::registerClassReleaseChecker(CheckerManager &mgr) { mgr.registerChecker(); } +bool ento::shouldRegisterClassReleaseChecker(const LangOptions &LO) { + return true; +} + void ento::registerVariadicMethodTypeChecker(CheckerManager &mgr) { mgr.registerChecker(); } +bool ento::shouldRegisterVariadicMethodTypeChecker(const LangOptions &LO) { + return true; +} + void ento::registerObjCLoopChecker(CheckerManager &mgr) { mgr.registerChecker(); } -void -ento::registerObjCNonNilReturnValueChecker(CheckerManager &mgr) { +bool ento::shouldRegisterObjCLoopChecker(const LangOptions &LO) { + return true; +} + +void ento::registerObjCNonNilReturnValueChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCNonNilReturnValueChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp +++ lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp @@ -182,3 +182,7 @@ void ento::registerBlockInCriticalSectionChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterBlockInCriticalSectionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp +++ lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp @@ -154,3 +154,7 @@ void ento::registerBoolAssignmentChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterBoolAssignmentChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp +++ lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp @@ -119,3 +119,7 @@ void ento::registerBuiltinFunctionChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterBuiltinFunctionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -2480,6 +2480,10 @@ CStringChecker *checker = mgr.registerChecker(); \ checker->Filter.Check##name = true; \ checker->Filter.CheckName##name = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(CStringNullArg) Index: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp @@ -289,3 +289,6 @@ mgr.registerChecker(); } +bool ento::shouldRegisterCStringSyntaxChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp +++ lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp @@ -59,3 +59,7 @@ void ento::registerCXXSelfAssignmentChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterCXXSelfAssignmentChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -613,6 +613,10 @@ mgr.registerChecker(); \ Checker->Filter.Check_##name = true; \ Checker->Filter.CheckName_##name = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(CallAndMessageUnInitRefArg) Index: lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp @@ -139,10 +139,13 @@ } void ento::registerCastSizeChecker(CheckerManager &mgr) { + mgr.registerChecker(); +} + +bool ento::shouldRegisterCastSizeChecker(const LangOptions &LO) { // PR31226: C++ is more complicated than what this checker currently supports. // There are derived-to-base casts, there are different rules for 0-size // structures, no flexible arrays, etc. // FIXME: Disabled on C++ for now. - if (!mgr.getLangOpts().CPlusPlus) - mgr.registerChecker(); + return !LO.CPlusPlus; } Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -119,3 +119,7 @@ void ento::registerCastToStructChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterCastToStructChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp +++ lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp @@ -1093,3 +1093,7 @@ Mgr.registerChecker(); } + +bool ento::shouldRegisterObjCDeallocChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp +++ lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp @@ -137,3 +137,7 @@ void ento::registerObjCMethSigsChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCMethSigsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp +++ lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp @@ -911,6 +911,10 @@ mgr.registerChecker(); \ checker->filter.check_##name = true; \ checker->filter.checkName_##name = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(bcmp) Index: lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp +++ lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp @@ -90,3 +90,7 @@ void ento::registerSizeofPointerChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterSizeofPointerChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ChrootChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -152,3 +152,7 @@ void ento::registerChrootChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterChrootChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -201,3 +201,7 @@ void ento::registerCloneChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterCloneChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp +++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp @@ -195,3 +195,7 @@ void ento::registerConversionChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterConversionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -478,3 +478,7 @@ void ento::registerDeadStoresChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDeadStoresChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DebugCheckers.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DebugCheckers.cpp +++ lib/StaticAnalyzer/Checkers/DebugCheckers.cpp @@ -47,6 +47,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterDominatorsTreeDumper(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // LiveVariablesDumper //===----------------------------------------------------------------------===// @@ -67,6 +71,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterLiveVariablesDumper(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // LiveStatementsDumper //===----------------------------------------------------------------------===// @@ -86,6 +94,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterLiveStatementsDumper(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // CFGViewer //===----------------------------------------------------------------------===// @@ -106,6 +118,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterCFGViewer(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // CFGDumper //===----------------------------------------------------------------------===// @@ -132,6 +148,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterCFGDumper(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // CallGraphViewer //===----------------------------------------------------------------------===// @@ -152,6 +172,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterCallGraphViewer(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // CallGraphDumper //===----------------------------------------------------------------------===// @@ -172,6 +196,9 @@ mgr.registerChecker(); } +bool ento::shouldRegisterCallGraphDumper(const LangOptions &LO) { + return true; +} //===----------------------------------------------------------------------===// // ConfigDumper @@ -213,6 +240,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterConfigDumper(const LangOptions &LO) { + return true; +} + //===----------------------------------------------------------------------===// // ExplodedGraph Viewer //===----------------------------------------------------------------------===// @@ -232,3 +263,6 @@ mgr.registerChecker(); } +bool ento::shouldRegisterExplodedGraphViewer(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp +++ lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp @@ -147,3 +147,8 @@ void ento::registerDeleteWithNonVirtualDtorChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDeleteWithNonVirtualDtorChecker( + const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -303,3 +303,7 @@ void ento::registerDereferenceChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDereferenceChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -205,12 +205,6 @@ } } -// Register the checker that checks for direct accesses in all functions, -// except for the initialization and copy routines. -void ento::registerDirectIvarAssignment(CheckerManager &mgr) { - mgr.registerChecker(); -} - // Register the checker that checks for direct accesses in functions annotated // with __attribute__((annotate("objc_no_direct_instance_variable_assignment"))). static bool AttrFilter(const ObjCMethodDecl *M) { @@ -220,7 +214,22 @@ return true; } +// Register the checker that checks for direct accesses in all functions, +// except for the initialization and copy routines. +void ento::registerDirectIvarAssignment(CheckerManager &mgr) { + mgr.registerChecker(); +} + +bool ento::shouldRegisterDirectIvarAssignment(const LangOptions &LO) { + return true; +} + void ento::registerDirectIvarAssignmentForAnnotatedFunctions( CheckerManager &mgr) { mgr.registerChecker()->ShouldSkipMethod = &AttrFilter; } + +bool ento::shouldRegisterDirectIvarAssignmentForAnnotatedFunctions( + const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp +++ lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp @@ -98,3 +98,7 @@ void ento::registerDivZeroChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDivZeroChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp +++ lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp @@ -205,3 +205,7 @@ void ento::registerDynamicTypeChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDynamicTypeChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -992,6 +992,14 @@ checker->CheckGenerics = true; } +bool ento::shouldRegisterObjCGenericsChecker(const LangOptions &LO) { + return true; +} + void ento::registerDynamicTypePropagation(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterDynamicTypePropagation(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp +++ lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp @@ -125,3 +125,7 @@ void ento::registerEnumCastOutOfRangeChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterEnumCastOutOfRangeChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -408,3 +408,7 @@ void ento::registerExprInspectionChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterExprInspectionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp +++ lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp @@ -64,3 +64,7 @@ void ento::registerFixedAddressChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterFixedAddressChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -221,8 +221,12 @@ emitDiagnostics(Match, "group", BR, ADC, this); } -} +} // end of anonymous namespace void ento::registerGCDAntipattern(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterGCDAntipattern(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/GTestChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/GTestChecker.cpp +++ lib/StaticAnalyzer/Checkers/GTestChecker.cpp @@ -288,11 +288,11 @@ } void ento::registerGTestChecker(CheckerManager &Mgr) { - const LangOptions &LangOpts = Mgr.getLangOpts(); + Mgr.registerChecker(); +} + +bool ento::shouldRegisterGTestChecker(const LangOptions &LO) { // gtest is a C++ API so there is no sense running the checker // if not compiling for C++. - if (!LangOpts.CPlusPlus) - return; - - Mgr.registerChecker(); + return LO.CPlusPlus; } Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -745,3 +745,7 @@ void ento::registerGenericTaintChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterGenericTaintChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp +++ lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp @@ -512,3 +512,7 @@ void ento::registerIdenticalExprChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterIdenticalExprChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp +++ lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp @@ -309,3 +309,7 @@ registerInnerPointerCheckerAux(Mgr); Mgr.registerChecker(); } + +bool ento::shouldRegisterInnerPointerChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp +++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp @@ -2399,6 +2399,10 @@ checker->ChecksEnabled[IteratorChecker::CK_##name] = true; \ checker->CheckNames[IteratorChecker::CK_##name] = \ Mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(IteratorRangeChecker) Index: lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -741,6 +741,10 @@ mgr.registerChecker(); \ checker->Filter.check_##name = true; \ checker->Filter.checkName_##name = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(InstanceVariableInvalidation) Index: lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp +++ lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp @@ -313,3 +313,7 @@ void ento::registerLLVMConventionsChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterLLVMConventionsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -1401,10 +1401,22 @@ false, checker); } +bool ento::shouldRegisterNonLocalizedStringChecker(const LangOptions &LO) { + return true; +} + void ento::registerEmptyLocalizationContextChecker(CheckerManager &mgr) { mgr.registerChecker(); } +bool ento::shouldRegisterEmptyLocalizationContextChecker(const LangOptions &LO) { + return true; +} + void ento::registerPluralMisuseChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterPluralMisuseChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp +++ lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp @@ -187,3 +187,7 @@ void clang::ento::registerMPIChecker(CheckerManager &MGR) { MGR.registerChecker(); } + +bool clang::ento::shouldRegisterMPIChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -661,3 +661,7 @@ void ento::registerMacOSKeychainAPIChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterMacOSKeychainAPIChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -173,3 +173,7 @@ void ento::registerMacOSXAPIChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterMacOSXAPIChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -3105,6 +3105,10 @@ } } +bool ento::shouldRegisterNewDeleteLeaksChecker(const LangOptions &LO) { + return true; +} + // Intended to be used in InnerPointerChecker to register the part of // MallocChecker connected to it. void ento::registerInnerPointerCheckerAux(CheckerManager &mgr) { @@ -3125,6 +3129,10 @@ "Optimistic", false, checker); \ checker->ChecksEnabled[MallocChecker::CK_##name] = true; \ checker->CheckNames[MallocChecker::CK_##name] = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(MallocChecker) Index: lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -333,7 +333,10 @@ OutputPossibleOverflows(PossibleMallocOverflows, D, BR, mgr); } -void -ento::registerMallocOverflowSecurityChecker(CheckerManager &mgr) { +void ento::registerMallocOverflowSecurityChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterMallocOverflowSecurityChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp @@ -249,3 +249,7 @@ void ento::registerMallocSizeofChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterMallocSizeofChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp +++ lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp @@ -87,3 +87,7 @@ mgr.getAnalyzerOptions() .getCheckerIntegerOption("MmapProtRead", 0x01, Mwec); } + +bool ento::shouldRegisterMmapWriteExecChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MoveChecker.cpp +++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp @@ -737,3 +737,7 @@ chk->setAggressiveness( mgr.getAnalyzerOptions().getCheckerStringOption("WarnOn", "", chk)); } + +bool ento::shouldRegisterMoveChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp +++ lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp @@ -75,6 +75,9 @@ } void ento::registerNSAutoreleasePoolChecker(CheckerManager &mgr) { - if (mgr.getLangOpts().getGC() != LangOptions::NonGC) - mgr.registerChecker(); + mgr.registerChecker(); +} + +bool ento::shouldRegisterNSAutoreleasePoolChecker(const LangOptions &LO) { + return LO.getGC() != LangOptions::NonGC; } Index: lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -314,9 +314,17 @@ checker->ShouldCheckNSError = true; } +bool ento::shouldRegisterNSErrorChecker(const LangOptions &LO) { + return true; +} + void ento::registerCFErrorChecker(CheckerManager &mgr) { mgr.registerChecker(); NSOrCFErrorDerefChecker *checker = mgr.registerChecker(); checker->ShouldCheckCFError = true; } + +bool ento::shouldRegisterCFErrorChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp +++ lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp @@ -142,3 +142,7 @@ void ento::registerNoReturnFunctionChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterNoReturnFunctionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp +++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp @@ -216,3 +216,7 @@ void ento::registerNonNullParamChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterNonNullParamChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp +++ lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp @@ -137,3 +137,7 @@ void ento::registerNonnullGlobalConstantsChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterNonnullGlobalConstantsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -1199,8 +1199,12 @@ checker->NeedTracking = checker->NeedTracking || trackingRequired; \ checker->NoDiagnoseCallsToSystemHeaders = \ checker->NoDiagnoseCallsToSystemHeaders || \ - mgr.getAnalyzerOptions().getCheckerBooleanOption( \ + mgr.getAnalyzerOptions().getCheckerBooleanOption( \ "NoDiagnoseCallsToSystemHeaders", false, checker, true); \ + } \ + \ + bool ento::shouldRegister##name##Checker(const LangOptions &LO) { \ + return true; \ } // The checks are likely to be turned on by default and it is possible to do Index: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -348,3 +348,7 @@ Chk->Pedantic = Mgr.getAnalyzerOptions().getCheckerBooleanOption("Pedantic", false, Chk); } + +bool ento::shouldRegisterNumberObjectConversionChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -88,6 +88,9 @@ } void ento::registerObjCAtSyncChecker(CheckerManager &mgr) { - if (mgr.getLangOpts().ObjC) - mgr.registerChecker(); + mgr.registerChecker(); +} + +bool ento::shouldRegisterObjCAtSyncChecker(const LangOptions &LO) { + return LO.ObjC; } Index: lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -206,3 +206,7 @@ void ento::registerAutoreleaseWriteChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterAutoreleaseWriteChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp @@ -171,3 +171,7 @@ void ento::registerObjCContainersASTChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCContainersASTChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp @@ -186,3 +186,7 @@ void ento::registerObjCContainersChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCContainersChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp @@ -221,6 +221,9 @@ Mgr.registerChecker(); } +bool ento::shouldRegisterObjCSuperCallChecker(const LangOptions &LO) { + return true; +} /* ToDo list for expanding this check in the future, the list is not exhaustive. Index: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp @@ -78,3 +78,7 @@ void ento::registerObjCPropertyChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterObjCPropertyChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -436,3 +436,7 @@ void ento::registerObjCSelfInitChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCSelfInitChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp @@ -281,8 +281,9 @@ //===----------------------------------------------------------------------===// void ento::registerObjCSuperDeallocChecker(CheckerManager &Mgr) { - const LangOptions &LangOpts = Mgr.getLangOpts(); - if (LangOpts.getGC() == LangOptions::GCOnly || LangOpts.ObjCAutoRefCount) - return; Mgr.registerChecker(); } + +bool ento::shouldRegisterObjCSuperDeallocChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -185,3 +185,7 @@ void ento::registerObjCUnusedIvarsChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterObjCUnusedIvarsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PaddingChecker.cpp +++ lib/StaticAnalyzer/Checkers/PaddingChecker.cpp @@ -350,3 +350,7 @@ void ento::registerPaddingChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } + +bool ento::shouldRegisterPaddingChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -342,3 +342,7 @@ void ento::registerPointerArithChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterPointerArithChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp +++ lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp @@ -72,3 +72,7 @@ void ento::registerPointerSubChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterPointerSubChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -480,3 +480,7 @@ void ento::registerPthreadLockChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterPthreadLockChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -1460,6 +1460,10 @@ Chk->TrackObjCAndCFObjects = true; } +bool ento::shouldRegisterRetainCountChecker(const LangOptions &LO) { + return 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 @@ -1476,3 +1480,7 @@ if (!hasPrevCheckOSObjectOptionDisabled(Mgr.getAnalyzerOptions())) Chk->TrackOSObjects = true; } + +bool ento::shouldRegisterOSObjectRetainCountChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp +++ lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp @@ -89,3 +89,7 @@ void ento::registerReturnPointerRangeChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterReturnPointerRangeChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp +++ lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp @@ -120,3 +120,7 @@ void ento::registerReturnUndefChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterReturnUndefChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -202,3 +202,7 @@ void ento::registerRunLoopAutoreleaseLeakChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterRunLoopAutoreleaseLeakChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -268,3 +268,8 @@ void ento::registerSimpleStreamChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +// This checker should be enabled regardless of how language options are set. +bool ento::shouldRegisterSimpleStreamChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -364,6 +364,10 @@ StackAddrEscapeChecker *Chk = \ Mgr.registerChecker(); \ Chk->ChecksEnabled[StackAddrEscapeChecker::CK_##name] = true; \ + } \ + \ + bool ento::shouldRegister##name(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(StackAddrEscapeChecker) Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -1055,3 +1055,7 @@ // class, turning on different function summaries. mgr.registerChecker(); } + +bool ento::shouldRegisterStdCLibraryFunctionsChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/StreamChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -408,3 +408,7 @@ void ento::registerStreamChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterStreamChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp +++ lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp @@ -59,3 +59,7 @@ void ento::registerTaintTesterChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterTaintTesterChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp +++ lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp @@ -260,3 +260,7 @@ void ento::registerTestAfterDivZeroChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterTestAfterDivZeroChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/TraversalChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/TraversalChecker.cpp +++ lib/StaticAnalyzer/Checkers/TraversalChecker.cpp @@ -64,6 +64,10 @@ mgr.registerChecker(); } +bool ento::shouldRegisterTraversalDumper(const LangOptions &LO) { + return true; +} + //------------------------------------------------------------------------------ namespace { @@ -111,3 +115,7 @@ void ento::registerCallDumper(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterCallDumper(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp +++ lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp @@ -248,7 +248,10 @@ } // end empty namespace - void ento::registerTrustNonnullChecker(CheckerManager &Mgr) { Mgr.registerChecker(Mgr.getASTContext()); } + +bool ento::shouldRegisterTrustNonnullChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp @@ -108,3 +108,7 @@ void ento::registerUndefBranchChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUndefBranchChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp @@ -99,3 +99,7 @@ void ento::registerUndefCapturedBlockVarChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUndefCapturedBlockVarChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -185,3 +185,7 @@ void ento::registerUndefResultChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUndefResultChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp @@ -61,3 +61,7 @@ void ento::registerUndefinedArraySubscriptChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUndefinedArraySubscriptChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp @@ -119,3 +119,7 @@ void ento::registerUndefinedAssignmentChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUndefinedAssignmentChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp @@ -535,3 +535,7 @@ AnOpts.getCheckerStringOption("IgnoreRecordsWithField", /*DefaultVal*/ "", Chk); } + +bool ento::shouldRegisterUninitializedObjectChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -472,6 +472,10 @@ #define REGISTER_CHECKER(Name) \ void ento::registerUnixAPI##Name##Checker(CheckerManager &mgr) { \ mgr.registerChecker()->Check##Name = true; \ + } \ + \ + bool ento::shouldRegisterUnixAPI##Name##Checker(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(Misuse) Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -256,3 +256,7 @@ void ento::registerUnreachableCodeChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterUnreachableCodeChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp +++ lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp @@ -182,3 +182,7 @@ void ento::registerVLASizeChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterVLASizeChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/ValistChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ValistChecker.cpp +++ lib/StaticAnalyzer/Checkers/ValistChecker.cpp @@ -404,6 +404,10 @@ ValistChecker *checker = mgr.registerChecker(); \ checker->ChecksEnabled[ValistChecker::CK_##name] = true; \ checker->CheckNames[ValistChecker::CK_##name] = mgr.getCurrentCheckName(); \ + } \ + \ + bool ento::shouldRegister##name##Checker(const LangOptions &LO) { \ + return true; \ } REGISTER_CHECKER(Uninitialized) Index: lib/StaticAnalyzer/Checkers/VforkChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/VforkChecker.cpp +++ lib/StaticAnalyzer/Checkers/VforkChecker.cpp @@ -215,3 +215,7 @@ void ento::registerVforkChecker(CheckerManager &mgr) { mgr.registerChecker(); } + +bool ento::shouldRegisterVforkChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp +++ lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp @@ -282,3 +282,7 @@ mgr.getAnalyzerOptions().getCheckerBooleanOption("PureOnly", false, checker); } + +bool ento::shouldRegisterVirtualCallChecker(const LangOptions &LO) { + return true; +} Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -33,7 +33,7 @@ DiagnosticsEngine &diags) { auto checkerMgr = llvm::make_unique(context, opts); - CheckerRegistry allCheckers(plugins, diags); + CheckerRegistry allCheckers(plugins, diags, context.getLangOpts()); for (const auto &Fn : checkerRegistrationFns) Fn(allCheckers); @@ -46,20 +46,22 @@ } void ento::printCheckerHelp(raw_ostream &out, ArrayRef plugins, - DiagnosticsEngine &diags) { + DiagnosticsEngine &diags, + const LangOptions &langOpts) { out << "OVERVIEW: Clang Static Analyzer Checkers List\n\n"; out << "USAGE: -analyzer-checker \n\n"; - CheckerRegistry(plugins, diags).printHelp(out); + CheckerRegistry(plugins, diags, langOpts).printHelp(out); } void ento::printEnabledCheckerList(raw_ostream &out, ArrayRef plugins, const AnalyzerOptions &opts, - DiagnosticsEngine &diags) { + DiagnosticsEngine &diags, + const LangOptions &langOpts) { out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n"; - CheckerRegistry(plugins, diags).printList(out, opts); + CheckerRegistry(plugins, diags, langOpts).printList(out, opts); } void ento::printAnalyzerConfigList(raw_ostream &out) { Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -39,10 +39,14 @@ } CheckerRegistry::CheckerRegistry(ArrayRef plugins, - DiagnosticsEngine &diags) : Diags(diags) { + DiagnosticsEngine &diags, + const LangOptions &LangOpts) + : Diags(diags), LangOpts(LangOpts) { + #define GET_CHECKERS #define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ - addChecker(register##CLASS, FULLNAME, HELPTEXT, DOC_URI); + addChecker(register##CLASS, shouldRegister##CLASS, FULLNAME, HELPTEXT, \ + DOC_URI); #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER #undef GET_CHECKERS @@ -114,7 +118,8 @@ for (const std::pair &opt : Opts.CheckersControlList) { // Use a binary search to find the possible start of the package. - CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.first, "", ""); + CheckerRegistry::CheckerInfo + packageInfo(nullptr, nullptr, opt.first, "", ""); auto firstRelatedChecker = std::lower_bound(Checkers.cbegin(), end, packageInfo, checkerNameLT); @@ -137,18 +142,21 @@ // Step through all the checkers in the package. for (auto lastRelatedChecker = firstRelatedChecker+size; firstRelatedChecker != lastRelatedChecker; ++firstRelatedChecker) - if (opt.second) - enabledCheckers.insert(&*firstRelatedChecker); - else + if (opt.second) { + if (firstRelatedChecker->ShouldRegister(LangOpts)) + enabledCheckers.insert(&*firstRelatedChecker); + } else { enabledCheckers.remove(&*firstRelatedChecker); + } } return enabledCheckers; } -void CheckerRegistry::addChecker(InitializationFunction Fn, StringRef Name, +void CheckerRegistry::addChecker(InitializationFunction Rfn, + ShouldRegisterFunction Sfn, StringRef Name, StringRef Desc, StringRef DocsUri) { - Checkers.emplace_back(Fn, Name, Desc, DocsUri); + Checkers.emplace_back(Rfn, Sfn, Name, Desc, DocsUri); // Record the presence of the checker in its packages. StringRef packageName, leafName;