Index: clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -344,6 +344,8 @@ "checker '%0' has no option called '%1'">; def err_analyzer_checker_option_invalid_input : Error< "invalid input for checker option '%0', that expects %1">; +def err_analyzer_checker_incompatible_analyzer_option : Error< + "checker cannot be enabled with analyzer option '%0' == %1">; def err_drv_invalid_hvx_length : Error< "-mhvx-length is not supported without a -mhvx/-mhvx= flag">; Index: clang/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h +++ clang/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h @@ -28,7 +28,7 @@ #define GET_CHECKERS #define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ void register##CLASS(CheckerManager &mgr); \ - bool shouldRegister##CLASS(const LangOptions &LO); + bool shouldRegister##CLASS(const CheckerManager &mgr); #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER #undef GET_CHECKERS Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ clang/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -14,9 +14,11 @@ #define LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H #include "clang/Analysis/ProgramPoint.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/LangOptions.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h" +#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -40,7 +42,6 @@ class CallEvent; class CheckerBase; class CheckerContext; -class CheckerRegistry; class ExplodedGraph; class ExplodedNode; class ExplodedNodeSet; @@ -121,14 +122,42 @@ }; class CheckerManager { - ASTContext &Context; + ASTContext *Context; const LangOptions LangOpts; AnalyzerOptions &AOptions; CheckerNameRef CurrentCheckerName; + DiagnosticsEngine &Diags; + CheckerRegistry Registry; public: + CheckerManager( + ASTContext &Context, AnalyzerOptions &AOptions, + ArrayRef plugins, + ArrayRef> checkerRegistrationFns) + : Context(&Context), LangOpts(Context.getLangOpts()), AOptions(AOptions), + Diags(Context.getDiagnostics()), + Registry(plugins, Context.getDiagnostics(), AOptions, + checkerRegistrationFns) { + Registry.initializeRegistry(*this); + Registry.initializeManager(*this); + finishedCheckerRegistration(); + } + + /// Constructs a CheckerManager that ignores all non TblGen-generated + /// checkers. Useful for unit testing, unless the checker infrastructure + /// itself is tested. CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions) - : Context(Context), LangOpts(Context.getLangOpts()), AOptions(AOptions) {} + : CheckerManager(Context, AOptions, {}, {}) {} + + /// Constructs a CheckerManager without requiring an AST. No checker + /// registration will take place. Only useful for retrieving the + /// CheckerRegistry and print for help flags where the AST is unavalaible. + CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts, + DiagnosticsEngine &Diags, ArrayRef plugins) + : LangOpts(LangOpts), AOptions(AOptions), Diags(Diags), + Registry(plugins, Diags, AOptions) { + Registry.initializeRegistry(*this); + } ~CheckerManager(); @@ -141,7 +170,12 @@ const LangOptions &getLangOpts() const { return LangOpts; } AnalyzerOptions &getAnalyzerOptions() { return AOptions; } - ASTContext &getASTContext() { return Context; } + ASTContext &getASTContext() { + assert(Context); + return *Context; + } + const CheckerRegistry &getCheckerRegistry() { return Registry; } + DiagnosticsEngine &getDiagnostics() { return Diags; } /// Emits an error through a DiagnosticsEngine about an invalid user supplied /// checker option value. Index: clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h =================================================================== --- clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h +++ clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h @@ -55,7 +55,7 @@ std::unique_ptr CreateAnalysisConsumer(CompilerInstance &CI); -} // end GR namespace +} // namespace ento } // end clang namespace Index: clang/include/clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h =================================================================== --- /dev/null +++ clang/include/clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h @@ -0,0 +1,32 @@ +//===-- CheckerRegistration.h - Checker Registration Function ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H +#define LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H + + +#include "clang/Frontend/CompilerInstance.h" +namespace llvm { +class raw_ostream; +} // namespace llvm + +namespace clang { + +class CompilerInstance; + +namespace ento { + +void printCheckerHelp(raw_ostream &OS, CompilerInstance &CI); +void printEnabledCheckerList(raw_ostream &OS, CompilerInstance &CI); +void printAnalyzerConfigList(raw_ostream &OS); +void printCheckerConfigList(raw_ostream &OS, CompilerInstance &CI); + +} // namespace ento +} // namespace clang + +#endif Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h =================================================================== --- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h +++ /dev/null @@ -1,38 +0,0 @@ -//===-- CheckerRegistration.h - Checker Registration Function ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H -#define LLVM_CLANG_STATICANALYZER_FRONTEND_CHECKERREGISTRATION_H - -#include "clang/AST/ASTContext.h" -#include "clang/Basic/LLVM.h" -#include -#include -#include - -namespace clang { - class AnalyzerOptions; - class LangOptions; - class DiagnosticsEngine; - -namespace ento { - class CheckerManager; - class CheckerRegistry; - - std::unique_ptr createCheckerManager( - ASTContext &context, - AnalyzerOptions &opts, - ArrayRef plugins, - ArrayRef> checkerRegistrationFns, - DiagnosticsEngine &diags); - -} // end ento namespace - -} // end namespace clang - -#endif Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h =================================================================== --- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h +++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h @@ -10,7 +10,7 @@ #define LLVM_CLANG_STATICANALYZER_CORE_CHECKERREGISTRY_H #include "clang/Basic/LLVM.h" -#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include @@ -69,10 +69,11 @@ class AnalyzerOptions; class DiagnosticsEngine; -class LangOptions; namespace ento { +class CheckerManager; + /// Manages a set of available checkers for running a static analysis. /// The checkers are organized into packages by full name, where including /// a package will recursively include all subpackages and checkers within it. @@ -82,14 +83,19 @@ class CheckerRegistry { public: CheckerRegistry(ArrayRef plugins, DiagnosticsEngine &diags, - AnalyzerOptions &AnOpts, const LangOptions &LangOpts, + AnalyzerOptions &AnOpts, ArrayRef> checkerRegistrationFns = {}); + /// Collects all enabled checkers in the field EnabledCheckers. It preserves + /// the order of insertion, as dependencies have to be enabled before the + /// checkers that depend on them. + void initializeRegistry(const CheckerManager &Mgr); + /// 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 &); + using ShouldRegisterFunction = bool (*)(const CheckerManager &); /// Specifies a command line option. It may either belong to a checker or a /// package. @@ -161,12 +167,12 @@ ConstCheckerInfoList Dependencies; - bool isEnabled(const LangOptions &LO) const { - return State == StateFromCmdLine::State_Enabled && ShouldRegister(LO); + bool isEnabled(const CheckerManager &mgr) const { + return State == StateFromCmdLine::State_Enabled && ShouldRegister(mgr); } - bool isDisabled(const LangOptions &LO) const { - return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO); + bool isDisabled(const CheckerManager &mgr) const { + return State == StateFromCmdLine::State_Disabled && ShouldRegister(mgr); } // Since each checker must have a different full name, we can identify @@ -205,11 +211,11 @@ using PackageInfoList = llvm::SmallVector; private: - template static void initializeManager(CheckerManager &mgr) { - mgr.registerChecker(); + template static void initializeManager(MGR &mgr) { + mgr.template registerChecker(); } - template static bool returnTrue(const LangOptions &LO) { + template static bool returnTrue(const CheckerManager &mgr) { return true; } @@ -227,9 +233,8 @@ bool IsHidden = false) { // Avoid MSVC's Compiler Error C2276: // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx - addChecker(&CheckerRegistry::initializeManager, - &CheckerRegistry::returnTrue, FullName, Desc, DocsUri, - IsHidden); + addChecker(&initializeManager, &returnTrue, FullName, + Desc, DocsUri, IsHidden); } /// Makes the checker with the full name \p fullName depends on the checker @@ -265,7 +270,7 @@ void addPackageOption(StringRef OptionType, StringRef PackageFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, - bool IsHidden = false); + bool IsHidden = false); // FIXME: This *really* should be added to the frontend flag descriptions. /// Initializes a CheckerManager by calling the initialization functions for @@ -285,11 +290,6 @@ void printCheckerOptionList(raw_ostream &Out) const; private: - /// Collect all enabled checkers. The returned container preserves the order - /// of insertion, as dependencies have to be enabled before the checkers that - /// depend on them. - CheckerInfoSet getEnabledCheckers() const; - /// Return an iterator range of mutable CheckerInfos \p CmdLineArg applies to. /// For example, it'll return the checkers for the core package, if /// \p CmdLineArg is "core". @@ -316,7 +316,7 @@ DiagnosticsEngine &Diags; AnalyzerOptions &AnOpts; - const LangOptions &LangOpts; + CheckerInfoSet EnabledCheckers; }; } // namespace ento Index: clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h =================================================================== --- clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h +++ clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h @@ -51,22 +51,7 @@ llvm::StringMap &Bodies; }; -void printCheckerHelp(raw_ostream &OS, - ArrayRef plugins, - AnalyzerOptions &opts, - DiagnosticsEngine &diags, - const LangOptions &LangOpts); -void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins, - AnalyzerOptions &opts, - DiagnosticsEngine &diags, - const LangOptions &LangOpts); -void printAnalyzerConfigList(raw_ostream &OS); -void printCheckerConfigList(raw_ostream &OS, ArrayRef plugins, - AnalyzerOptions &opts, - DiagnosticsEngine &diags, - const LangOptions &LangOpts); - -} // end GR namespace +} // namespace ento } // end namespace clang Index: clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp =================================================================== --- clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp +++ clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp @@ -21,7 +21,7 @@ << '\n'; } -bool shouldRegisterMyChecker(const LangOptions &LO) { return true; } +bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; } } // end anonymous namespace Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -23,12 +23,14 @@ #include "clang/Frontend/Utils.h" #include "clang/FrontendTool/Utils.h" #include "clang/Rewrite/Frontend/FrontendActions.h" +#include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/Option/OptTable.h" #include "llvm/Option/Option.h" #include "llvm/Support/BuryPointer.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" +#include using namespace clang; using namespace llvm::opt; @@ -243,35 +245,24 @@ // These should happen AFTER plugins have been loaded! AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts(); + // Honor -analyzer-checker-help and -analyzer-checker-help-hidden. if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha || AnOpts.ShowCheckerHelpDeveloper) { - ento::printCheckerHelp(llvm::outs(), - Clang->getFrontendOpts().Plugins, - AnOpts, - Clang->getDiagnostics(), - Clang->getLangOpts()); + ento::printCheckerHelp(llvm::outs(), *Clang); return true; } // Honor -analyzer-checker-option-help. if (AnOpts.ShowCheckerOptionList || AnOpts.ShowCheckerOptionAlphaList || AnOpts.ShowCheckerOptionDeveloperList) { - ento::printCheckerConfigList(llvm::outs(), - Clang->getFrontendOpts().Plugins, - *Clang->getAnalyzerOpts(), - Clang->getDiagnostics(), - Clang->getLangOpts()); + ento::printCheckerConfigList(llvm::outs(), *Clang); return true; } // Honor -analyzer-list-enabled-checkers. if (AnOpts.ShowEnabledCheckerList) { - ento::printEnabledCheckerList(llvm::outs(), - Clang->getFrontendOpts().Plugins, - AnOpts, - Clang->getDiagnostics(), - Clang->getLangOpts()); + ento::printEnabledCheckerList(llvm::outs(), *Clang); return true; } Index: clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp @@ -186,6 +186,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterAnalysisOrderChecker(const LangOptions &LO) { +bool ento::shouldRegisterAnalysisOrderChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp @@ -140,6 +140,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterAnalyzerStatsChecker(const LangOptions &LO) { +bool ento::shouldRegisterAnalyzerStatsChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp @@ -92,6 +92,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterArrayBoundChecker(const LangOptions &LO) { +bool ento::shouldRegisterArrayBoundChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp +++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp @@ -356,6 +356,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterArrayBoundCheckerV2(const LangOptions &LO) { +bool ento::shouldRegisterArrayBoundCheckerV2(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -1243,7 +1243,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNilArgChecker(const LangOptions &LO) { +bool ento::shouldRegisterNilArgChecker(const CheckerManager &mgr) { return true; } @@ -1251,7 +1251,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCFNumberChecker(const LangOptions &LO) { +bool ento::shouldRegisterCFNumberChecker(const CheckerManager &mgr) { return true; } @@ -1259,7 +1259,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCFRetainReleaseChecker(const LangOptions &LO) { +bool ento::shouldRegisterCFRetainReleaseChecker(const CheckerManager &mgr) { return true; } @@ -1267,7 +1267,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterClassReleaseChecker(const LangOptions &LO) { +bool ento::shouldRegisterClassReleaseChecker(const CheckerManager &mgr) { return true; } @@ -1275,7 +1275,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterVariadicMethodTypeChecker(const LangOptions &LO) { +bool ento::shouldRegisterVariadicMethodTypeChecker(const CheckerManager &mgr) { return true; } @@ -1283,7 +1283,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCLoopChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCLoopChecker(const CheckerManager &mgr) { return true; } @@ -1291,6 +1291,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCNonNilReturnValueChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCNonNilReturnValueChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp @@ -184,6 +184,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterBlockInCriticalSectionChecker(const LangOptions &LO) { +bool ento::shouldRegisterBlockInCriticalSectionChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp @@ -96,6 +96,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterBoolAssignmentChecker(const LangOptions &LO) { +bool ento::shouldRegisterBoolAssignmentChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp @@ -135,6 +135,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterBuiltinFunctionChecker(const LangOptions &LO) { +bool ento::shouldRegisterBuiltinFunctionChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -2430,7 +2430,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterCStringModeling(const LangOptions &LO) { +bool ento::shouldRegisterCStringModeling(const CheckerManager &mgr) { return true; } @@ -2441,7 +2441,7 @@ checker->Filter.CheckName##name = mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { return true; } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(CStringNullArg) REGISTER_CHECKER(CStringOutOfBounds) Index: clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp @@ -291,6 +291,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCStringSyntaxChecker(const LangOptions &LO) { +bool ento::shouldRegisterCStringSyntaxChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp @@ -76,6 +76,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterCXXSelfAssignmentChecker(const LangOptions &LO) { +bool ento::shouldRegisterCXXSelfAssignmentChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -605,7 +605,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCallAndMessageChecker(const LangOptions &LO) { +bool ento::shouldRegisterCallAndMessageChecker(const CheckerManager &mgr) { return true; } @@ -615,6 +615,6 @@ Checker->CheckName_CallAndMessageUnInitRefArg = mgr.getCurrentCheckerName(); } -bool ento::shouldRegisterCallAndMessageUnInitRefArg(const LangOptions &LO) { +bool ento::shouldRegisterCallAndMessageUnInitRefArg(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp @@ -146,10 +146,11 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCastSizeChecker(const LangOptions &LO) { +bool ento::shouldRegisterCastSizeChecker(const CheckerManager &mgr) { // 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. + const LangOptions &LO = mgr.getLangOpts(); return !LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -120,6 +120,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCastToStructChecker(const LangOptions &LO) { +bool ento::shouldRegisterCastToStructChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp @@ -436,6 +436,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterCastValueChecker(const LangOptions &LO) { +bool ento::shouldRegisterCastValueChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp +++ clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp @@ -1088,7 +1088,8 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterObjCDeallocChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCDeallocChecker(const CheckerManager &mgr) { // These checker only makes sense under MRR. + const LangOptions &LO = mgr.getLangOpts(); return LO.getGC() != LangOptions::GCOnly && !LO.ObjCAutoRefCount; } Index: clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp +++ clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp @@ -138,6 +138,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCMethSigsChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCMethSigsChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp +++ clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp @@ -117,6 +117,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPlacementNewChecker(const LangOptions &LO) { +bool ento::shouldRegisterPlacementNewChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp +++ clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp @@ -1076,7 +1076,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterSecuritySyntaxChecker(const LangOptions &LO) { +bool ento::shouldRegisterSecuritySyntaxChecker(const CheckerManager &mgr) { return true; } @@ -1087,7 +1087,7 @@ checker->filter.checkName_##name = mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { return true; } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(bcmp) REGISTER_CHECKER(bcopy) Index: clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp +++ clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp @@ -91,6 +91,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterSizeofPointerChecker(const LangOptions &LO) { +bool ento::shouldRegisterSizeofPointerChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -136,6 +136,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterChrootChecker(const LangOptions &LO) { +bool ento::shouldRegisterChrootChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -208,6 +208,6 @@ .getCheckerStringOption(Checker, "IgnoredFilesPattern"); } -bool ento::shouldRegisterCloneChecker(const LangOptions &LO) { +bool ento::shouldRegisterCloneChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp @@ -12,6 +12,7 @@ #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/AST/DeclTemplate.h" +#include "clang/Driver/DriverDiagnostic.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" @@ -1035,6 +1036,16 @@ mgr.registerChecker(); } -bool ento::shouldRegisterContainerModeling(const LangOptions &LO) { +bool ento::shouldRegisterContainerModeling(const CheckerManager &mgr) { + if (!mgr.getLangOpts().CPlusPlus) + return false; + + if (!mgr.getAnalyzerOptions().ShouldAggressivelySimplifyBinaryOperation) { + mgr.getASTContext().getDiagnostics().Report( + diag::err_analyzer_checker_incompatible_analyzer_option) + << "aggressive-binary-operation-simplification" << "false"; + return false; + } + return true; } Index: clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp @@ -196,6 +196,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterConversionChecker(const LangOptions &LO) { +bool ento::shouldRegisterConversionChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -540,6 +540,6 @@ AnOpts.getCheckerBooleanOption(Chk, "ShowFixIts"); } -bool ento::shouldRegisterDeadStoresChecker(const LangOptions &LO) { +bool ento::shouldRegisterDeadStoresChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp +++ clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp @@ -47,7 +47,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDominatorsTreeDumper(const LangOptions &LO) { +bool ento::shouldRegisterDominatorsTreeDumper(const CheckerManager &mgr) { return true; } @@ -73,7 +73,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPostDominatorsTreeDumper(const LangOptions &LO) { +bool ento::shouldRegisterPostDominatorsTreeDumper(const CheckerManager &mgr) { return true; } @@ -98,7 +98,8 @@ mgr.registerChecker(); } -bool ento::shouldRegisterControlDependencyTreeDumper(const LangOptions &LO) { +bool ento::shouldRegisterControlDependencyTreeDumper( + const CheckerManager &mgr) { return true; } @@ -122,7 +123,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterLiveVariablesDumper(const LangOptions &LO) { +bool ento::shouldRegisterLiveVariablesDumper(const CheckerManager &mgr) { return true; } @@ -145,7 +146,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterLiveStatementsDumper(const LangOptions &LO) { +bool ento::shouldRegisterLiveStatementsDumper(const CheckerManager &mgr) { return true; } @@ -169,9 +170,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCFGViewer(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterCFGViewer(const CheckerManager &mgr) { return true; } //===----------------------------------------------------------------------===// // CFGDumper @@ -199,9 +198,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCFGDumper(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterCFGDumper(const CheckerManager &mgr) { return true; } //===----------------------------------------------------------------------===// // CallGraphViewer @@ -223,7 +220,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCallGraphViewer(const LangOptions &LO) { +bool ento::shouldRegisterCallGraphViewer(const CheckerManager &mgr) { return true; } @@ -247,7 +244,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCallGraphDumper(const LangOptions &LO) { +bool ento::shouldRegisterCallGraphDumper(const CheckerManager &mgr) { return true; } @@ -291,7 +288,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterConfigDumper(const LangOptions &LO) { +bool ento::shouldRegisterConfigDumper(const CheckerManager &mgr) { return true; } @@ -314,7 +311,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterExplodedGraphViewer(const LangOptions &LO) { +bool ento::shouldRegisterExplodedGraphViewer(const CheckerManager &mgr) { return true; } @@ -346,6 +343,4 @@ mgr.registerChecker(); } -bool ento::shouldRegisterReportStmts(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterReportStmts(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp @@ -133,6 +133,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDebugContainerModeling(const LangOptions &LO) { +bool ento::shouldRegisterDebugContainerModeling(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp @@ -139,6 +139,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDebugIteratorModeling(const LangOptions &LO) { +bool ento::shouldRegisterDebugIteratorModeling(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp @@ -148,6 +148,6 @@ } bool ento::shouldRegisterDeleteWithNonVirtualDtorChecker( - const LangOptions &LO) { + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -304,6 +304,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDereferenceChecker(const LangOptions &LO) { +bool ento::shouldRegisterDereferenceChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -222,7 +222,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDirectIvarAssignment(const LangOptions &LO) { +bool ento::shouldRegisterDirectIvarAssignment(const CheckerManager &mgr) { return true; } @@ -232,6 +232,6 @@ } bool ento::shouldRegisterDirectIvarAssignmentForAnnotatedFunctions( - const LangOptions &LO) { + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp @@ -101,6 +101,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDivZeroChecker(const LangOptions &LO) { +bool ento::shouldRegisterDivZeroChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp @@ -203,6 +203,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDynamicTypeChecker(const LangOptions &LO) { +bool ento::shouldRegisterDynamicTypeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -981,7 +981,7 @@ checker->CheckGenerics = true; } -bool ento::shouldRegisterObjCGenericsChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCGenericsChecker(const CheckerManager &mgr) { return true; } @@ -989,6 +989,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterDynamicTypePropagation(const LangOptions &LO) { +bool ento::shouldRegisterDynamicTypePropagation(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp @@ -142,6 +142,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterEnumCastOutOfRangeChecker(const LangOptions &LO) { +bool ento::shouldRegisterEnumCastOutOfRangeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -416,6 +416,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterExprInspectionChecker(const LangOptions &LO) { +bool ento::shouldRegisterExprInspectionChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp @@ -66,6 +66,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterFixedAddressChecker(const LangOptions &LO) { +bool ento::shouldRegisterFixedAddressChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp @@ -565,7 +565,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterFuchsiaHandleChecker(const LangOptions &LO) { +bool ento::shouldRegisterFuchsiaHandleChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -225,6 +225,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterGCDAntipattern(const LangOptions &LO) { +bool ento::shouldRegisterGCDAntipattern(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp @@ -291,8 +291,9 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterGTestChecker(const LangOptions &LO) { +bool ento::shouldRegisterGTestChecker(const CheckerManager &mgr) { // gtest is a C++ API so there is no sense running the checker // if not compiling for C++. + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -942,6 +942,6 @@ Checker->parseConfiguration(Mgr, Option, std::move(Config.getValue())); } -bool ento::shouldRegisterGenericTaintChecker(const LangOptions &LO) { +bool ento::shouldRegisterGenericTaintChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp @@ -513,6 +513,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterIdenticalExprChecker(const LangOptions &LO) { +bool ento::shouldRegisterIdenticalExprChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp @@ -307,6 +307,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterInnerPointerChecker(const LangOptions &LO) { +bool ento::shouldRegisterInnerPointerChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp @@ -90,6 +90,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterInvalidatedIteratorChecker(const LangOptions &LO) { +bool ento::shouldRegisterInvalidatedIteratorChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -590,6 +590,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterIteratorModeling(const LangOptions &LO) { +bool ento::shouldRegisterIteratorModeling(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp @@ -268,6 +268,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterIteratorRangeChecker(const LangOptions &LO) { +bool ento::shouldRegisterIteratorRangeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -739,7 +739,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterIvarInvalidationModeling(const LangOptions &LO) { +bool ento::shouldRegisterIvarInvalidationModeling(const CheckerManager &mgr) { return true; } @@ -751,7 +751,7 @@ checker->Filter.checkName_##name = mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { return true; } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(InstanceVariableInvalidation) REGISTER_CHECKER(MissingInvalidationMethod) Index: clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp @@ -314,6 +314,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterLLVMConventionsChecker(const LangOptions &LO) { +bool ento::shouldRegisterLLVMConventionsChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -1403,7 +1403,7 @@ checker, "AggressiveReport"); } -bool ento::shouldRegisterNonLocalizedStringChecker(const LangOptions &LO) { +bool ento::shouldRegisterNonLocalizedStringChecker(const CheckerManager &mgr) { return true; } @@ -1412,7 +1412,7 @@ } bool ento::shouldRegisterEmptyLocalizationContextChecker( - const LangOptions &LO) { + const CheckerManager &mgr) { return true; } @@ -1420,6 +1420,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPluralMisuseChecker(const LangOptions &LO) { +bool ento::shouldRegisterPluralMisuseChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp @@ -292,6 +292,4 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterMIGChecker(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterMIGChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp @@ -190,6 +190,6 @@ MGR.registerChecker(); } -bool clang::ento::shouldRegisterMPIChecker(const LangOptions &LO) { +bool clang::ento::shouldRegisterMPIChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -667,6 +667,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterMacOSKeychainAPIChecker(const LangOptions &LO) { +bool ento::shouldRegisterMacOSKeychainAPIChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -176,6 +176,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterMacOSXAPIChecker(const LangOptions &LO) { +bool ento::shouldRegisterMacOSXAPIChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -3289,7 +3289,7 @@ mgr.getAnalyzerOptions().getCheckerBooleanOption(checker, "Optimistic"); } -bool ento::shouldRegisterDynamicMemoryModeling(const LangOptions &LO) { +bool ento::shouldRegisterDynamicMemoryModeling(const CheckerManager &mgr) { return true; } @@ -3301,7 +3301,7 @@ mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { return true; } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(MallocChecker) REGISTER_CHECKER(NewDeleteChecker) Index: clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -337,6 +337,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterMallocOverflowSecurityChecker(const LangOptions &LO) { +bool ento::shouldRegisterMallocOverflowSecurityChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp @@ -250,6 +250,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterMallocSizeofChecker(const LangOptions &LO) { +bool ento::shouldRegisterMallocSizeofChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp @@ -290,6 +290,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterMismatchedIteratorChecker(const LangOptions &LO) { +bool ento::shouldRegisterMismatchedIteratorChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp @@ -88,6 +88,6 @@ .getCheckerIntegerOption(Mwec, "MmapProtRead"); } -bool ento::shouldRegisterMmapWriteExecChecker(const LangOptions &LO) { +bool ento::shouldRegisterMmapWriteExecChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp @@ -757,6 +757,4 @@ mgr.getAnalyzerOptions().getCheckerStringOption(chk, "WarnOn"), mgr); } -bool ento::shouldRegisterMoveChecker(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterMoveChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp @@ -80,6 +80,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNSAutoreleasePoolChecker(const LangOptions &LO) { +bool ento::shouldRegisterNSAutoreleasePoolChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.getGC() != LangOptions::NonGC; } Index: clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -312,7 +312,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNSOrCFErrorDerefChecker(const LangOptions &LO) { +bool ento::shouldRegisterNSOrCFErrorDerefChecker(const CheckerManager &mgr) { return true; } @@ -322,7 +322,7 @@ checker->ShouldCheckNSError = true; } -bool ento::shouldRegisterNSErrorChecker(const LangOptions &LO) { +bool ento::shouldRegisterNSErrorChecker(const CheckerManager &mgr) { return true; } @@ -332,6 +332,6 @@ checker->ShouldCheckCFError = true; } -bool ento::shouldRegisterCFErrorChecker(const LangOptions &LO) { +bool ento::shouldRegisterCFErrorChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp @@ -143,6 +143,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNoReturnFunctionChecker(const LangOptions &LO) { +bool ento::shouldRegisterNoReturnFunctionChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp @@ -226,6 +226,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNonNullParamChecker(const LangOptions &LO) { +bool ento::shouldRegisterNonNullParamChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp @@ -147,6 +147,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterNonnullGlobalConstantsChecker(const LangOptions &LO) { +bool ento::shouldRegisterNonnullGlobalConstantsChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -1188,7 +1188,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterNullabilityBase(const LangOptions &LO) { +bool ento::shouldRegisterNullabilityBase(const CheckerManager &mgr) { return true; } @@ -1204,7 +1204,7 @@ checker, "NoDiagnoseCallsToSystemHeaders", true); \ } \ \ - bool ento::shouldRegister##name##Checker(const LangOptions &LO) { \ + bool ento::shouldRegister##name##Checker(const CheckerManager &mgr) { \ return true; \ } Index: clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -349,6 +349,7 @@ Mgr.getAnalyzerOptions().getCheckerBooleanOption(Chk, "Pedantic"); } -bool ento::shouldRegisterNumberObjectConversionChecker(const LangOptions &LO) { +bool ento::shouldRegisterNumberObjectConversionChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp +++ clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp @@ -84,6 +84,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterOSObjectCStyleCast(const LangOptions &LO) { +bool ento::shouldRegisterOSObjectCStyleCast(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -91,6 +91,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCAtSyncChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCAtSyncChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.ObjC; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -206,6 +206,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterAutoreleaseWriteChecker(const LangOptions &LO) { +bool ento::shouldRegisterAutoreleaseWriteChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp @@ -172,6 +172,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCContainersASTChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCContainersASTChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp @@ -188,6 +188,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCContainersChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCContainersChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp @@ -221,7 +221,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterObjCSuperCallChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCSuperCallChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp @@ -79,6 +79,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterObjCPropertyChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCPropertyChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -437,6 +437,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCSelfInitChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCSelfInitChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp @@ -284,6 +284,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterObjCSuperDeallocChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCSuperDeallocChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -186,6 +186,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterObjCUnusedIvarsChecker(const LangOptions &LO) { +bool ento::shouldRegisterObjCUnusedIvarsChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp @@ -353,6 +353,6 @@ Checker, "AllowedPad", "a non-negative value"); } -bool ento::shouldRegisterPaddingChecker(const LangOptions &LO) { +bool ento::shouldRegisterPaddingChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -343,6 +343,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPointerArithChecker(const LangOptions &LO) { +bool ento::shouldRegisterPointerArithChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp @@ -95,6 +95,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterPointerIterationChecker(const LangOptions &LO) { +bool ento::shouldRegisterPointerIterationChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp @@ -108,6 +108,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterPointerSortingChecker(const LangOptions &LO) { +bool ento::shouldRegisterPointerSortingChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp @@ -74,6 +74,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPointerSubChecker(const LangOptions &LO) { +bool ento::shouldRegisterPointerSubChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -725,7 +725,9 @@ mgr.registerChecker(); } -bool ento::shouldRegisterPthreadLockBase(const LangOptions &LO) { return true; } +bool ento::shouldRegisterPthreadLockBase(const CheckerManager &mgr) { + return true; +} #define REGISTER_CHECKER(name) \ void ento::register##name(CheckerManager &mgr) { \ @@ -735,7 +737,7 @@ mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { return true; } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(PthreadLockChecker) REGISTER_CHECKER(FuchsiaLockChecker) Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -1477,7 +1477,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterRetainCountBase(const LangOptions &LO) { +bool ento::shouldRegisterRetainCountBase(const CheckerManager &mgr) { return true; } @@ -1503,7 +1503,7 @@ "true"); } -bool ento::shouldRegisterRetainCountChecker(const LangOptions &LO) { +bool ento::shouldRegisterRetainCountChecker(const CheckerManager &mgr) { return true; } @@ -1515,6 +1515,6 @@ Chk->TrackOSObjects = true; } -bool ento::shouldRegisterOSObjectRetainCountChecker(const LangOptions &LO) { +bool ento::shouldRegisterOSObjectRetainCountChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp @@ -91,6 +91,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterReturnPointerRangeChecker(const LangOptions &LO) { +bool ento::shouldRegisterReturnPointerRangeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp @@ -122,6 +122,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterReturnUndefChecker(const LangOptions &LO) { +bool ento::shouldRegisterReturnUndefChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp @@ -165,6 +165,6 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterReturnValueChecker(const LangOptions &LO) { +bool ento::shouldRegisterReturnValueChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -203,6 +203,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterRunLoopAutoreleaseLeakChecker(const LangOptions &LO) { +bool ento::shouldRegisterRunLoopAutoreleaseLeakChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp @@ -174,7 +174,6 @@ "AggressiveStdFindModeling"); } -bool ento::shouldRegisterSTLAlgorithmModeling(const LangOptions &LO) { +bool ento::shouldRegisterSTLAlgorithmModeling(const CheckerManager &mgr) { return true; } - Index: clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -271,6 +271,6 @@ } // This checker should be enabled regardless of how language options are set. -bool ento::shouldRegisterSimpleStreamChecker(const LangOptions &LO) { +bool ento::shouldRegisterSimpleStreamChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp @@ -67,6 +67,7 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterSmartPtrModeling(const LangOptions &LO) { +bool ento::shouldRegisterSmartPtrModeling(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -365,20 +365,17 @@ mgr.registerChecker(); } -bool ento::shouldRegisterStackAddrEscapeBase(const LangOptions &LO) { +bool ento::shouldRegisterStackAddrEscapeBase(const CheckerManager &mgr) { return true; } #define REGISTER_CHECKER(name) \ void ento::register##name(CheckerManager &Mgr) { \ - StackAddrEscapeChecker *Chk = \ - Mgr.getChecker(); \ + StackAddrEscapeChecker *Chk = Mgr.getChecker(); \ Chk->ChecksEnabled[StackAddrEscapeChecker::CK_##name] = true; \ } \ \ - bool ento::shouldRegister##name(const LangOptions &LO) { \ - return true; \ - } + bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; } REGISTER_CHECKER(StackAddrEscapeChecker) REGISTER_CHECKER(StackAddrAsyncEscapeChecker) Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -795,6 +795,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterStdCLibraryFunctionsChecker(const LangOptions &LO) { +bool ento::shouldRegisterStdCLibraryFunctionsChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -360,6 +360,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterStreamChecker(const LangOptions &LO) { +bool ento::shouldRegisterStreamChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp @@ -63,6 +63,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterTaintTesterChecker(const LangOptions &LO) { +bool ento::shouldRegisterTaintTesterChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp @@ -261,6 +261,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterTestAfterDivZeroChecker(const LangOptions &LO) { +bool ento::shouldRegisterTestAfterDivZeroChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp @@ -64,7 +64,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterTraversalDumper(const LangOptions &LO) { +bool ento::shouldRegisterTraversalDumper(const CheckerManager &mgr) { return true; } @@ -116,6 +116,4 @@ mgr.registerChecker(); } -bool ento::shouldRegisterCallDumper(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterCallDumper(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp @@ -252,6 +252,6 @@ Mgr.registerChecker(Mgr.getASTContext()); } -bool ento::shouldRegisterTrustNonnullChecker(const LangOptions &LO) { +bool ento::shouldRegisterTrustNonnullChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp @@ -110,6 +110,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUndefBranchChecker(const LangOptions &LO) { +bool ento::shouldRegisterUndefBranchChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp @@ -101,6 +101,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUndefCapturedBlockVarChecker(const LangOptions &LO) { +bool ento::shouldRegisterUndefCapturedBlockVarChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -187,6 +187,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUndefResultChecker(const LangOptions &LO) { +bool ento::shouldRegisterUndefResultChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp @@ -62,6 +62,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUndefinedArraySubscriptChecker(const LangOptions &LO) { +bool ento::shouldRegisterUndefinedArraySubscriptChecker( + const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp @@ -120,6 +120,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUndefinedAssignmentChecker(const LangOptions &LO) { +bool ento::shouldRegisterUndefinedAssignmentChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp @@ -628,6 +628,6 @@ "\"" + ErrorMsg + "\""); } -bool ento::shouldRegisterUninitializedObjectChecker(const LangOptions &LO) { +bool ento::shouldRegisterUninitializedObjectChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -503,7 +503,7 @@ mgr.registerChecker(); \ } \ \ - bool ento::shouldRegister##CHECKERNAME(const LangOptions &LO) { \ + bool ento::shouldRegister##CHECKERNAME(const CheckerManager &mgr) { \ return true; \ } Index: clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -257,6 +257,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterUnreachableCodeChecker(const LangOptions &LO) { +bool ento::shouldRegisterUnreachableCodeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp @@ -187,6 +187,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterVLASizeChecker(const LangOptions &LO) { +bool ento::shouldRegisterVLASizeChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp @@ -404,9 +404,7 @@ mgr.registerChecker(); } -bool ento::shouldRegisterValistBase(const LangOptions &LO) { - return true; -} +bool ento::shouldRegisterValistBase(const CheckerManager &mgr) { return true; } #define REGISTER_CHECKER(name) \ void ento::register##name##Checker(CheckerManager &mgr) { \ @@ -416,7 +414,7 @@ mgr.getCurrentCheckerName(); \ } \ \ - bool ento::shouldRegister##name##Checker(const LangOptions &LO) { \ + bool ento::shouldRegister##name##Checker(const CheckerManager &mgr) { \ return true; \ } Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp @@ -217,6 +217,6 @@ mgr.registerChecker(); } -bool ento::shouldRegisterVforkChecker(const LangOptions &LO) { +bool ento::shouldRegisterVforkChecker(const CheckerManager &mgr) { return true; } Index: clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp @@ -224,14 +224,17 @@ } } -bool ento::shouldRegisterVirtualCallModeling(const LangOptions &LO) { +bool ento::shouldRegisterVirtualCallModeling(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } -bool ento::shouldRegisterPureVirtualCallChecker(const LangOptions &LO) { +bool ento::shouldRegisterPureVirtualCallChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } -bool ento::shouldRegisterVirtualCallChecker(const LangOptions &LO) { +bool ento::shouldRegisterVirtualCallChecker(const CheckerManager &mgr) { + const LangOptions &LO = mgr.getLangOpts(); return LO.CPlusPlus; } Index: clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp @@ -61,4 +61,4 @@ Mgr.registerChecker(); } -bool ento::shouldRegisterPutenvWithAuto(const LangOptions &) { return true; } +bool ento::shouldRegisterPutenvWithAuto(const CheckerManager &) { return true; } Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp +++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp @@ -63,10 +63,9 @@ void CheckerManager::reportInvalidCheckerOptionValue( const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) { - Context.getDiagnostics() - .Report(diag::err_analyzer_checker_option_invalid_input) - << (llvm::Twine() + C->getTagDescription() + ":" + OptionName).str() - << ExpectedValueDesc; + getDiagnostics().Report(diag::err_analyzer_checker_option_invalid_input) + << (llvm::Twine() + C->getTagDescription() + ":" + OptionName).str() + << ExpectedValueDesc; } //===----------------------------------------------------------------------===// Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -32,7 +32,6 @@ #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" -#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FileSystem.h" @@ -333,8 +332,8 @@ void Initialize(ASTContext &Context) override { Ctx = &Context; - checkerMgr = createCheckerManager( - *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics()); + checkerMgr = std::make_unique(*Ctx, *Opts, Plugins, + CheckerRegistrationFns); Mgr = std::make_unique(*Ctx, PP, PathConsumers, CreateStoreMgr, CreateConstraintMgr, Index: clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp +++ clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h" +#include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h" #include "clang/Basic/Diagnostic.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" @@ -24,53 +24,34 @@ using namespace clang; using namespace ento; -std::unique_ptr ento::createCheckerManager( - ASTContext &context, - AnalyzerOptions &opts, - ArrayRef plugins, - ArrayRef> checkerRegistrationFns, - DiagnosticsEngine &diags) { - auto checkerMgr = std::make_unique(context, opts); - - CheckerRegistry allCheckers(plugins, diags, opts, context.getLangOpts(), - checkerRegistrationFns); - - allCheckers.initializeManager(*checkerMgr); - allCheckers.validateCheckerOptions(); - checkerMgr->finishedCheckerRegistration(); - - return checkerMgr; -} - -void ento::printCheckerHelp(raw_ostream &out, ArrayRef plugins, - AnalyzerOptions &anopts, - DiagnosticsEngine &diags, - const LangOptions &langOpts) { +void ento::printCheckerHelp(raw_ostream &out, CompilerInstance &CI) { out << "OVERVIEW: Clang Static Analyzer Checkers List\n\n"; out << "USAGE: -analyzer-checker \n\n"; - CheckerRegistry(plugins, diags, anopts, langOpts) - .printCheckerWithDescList(out); + auto CheckerMgr = std::make_unique( + *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(), + CI.getFrontendOpts().Plugins); + + CheckerMgr->getCheckerRegistry().printCheckerWithDescList(out); } -void ento::printEnabledCheckerList(raw_ostream &out, - ArrayRef plugins, - AnalyzerOptions &anopts, - DiagnosticsEngine &diags, - const LangOptions &langOpts) { +void ento::printEnabledCheckerList(raw_ostream &out, CompilerInstance &CI) { out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n"; - CheckerRegistry(plugins, diags, anopts, langOpts) - .printEnabledCheckerList(out); + auto CheckerMgr = std::make_unique( + *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(), + CI.getFrontendOpts().Plugins); + + CheckerMgr->getCheckerRegistry().printEnabledCheckerList(out); } -void ento::printCheckerConfigList(raw_ostream &OS, - ArrayRef plugins, - AnalyzerOptions &opts, - DiagnosticsEngine &diags, - const LangOptions &LangOpts) { - CheckerRegistry(plugins, diags, opts, LangOpts) - .printCheckerOptionList(OS); +void ento::printCheckerConfigList(raw_ostream &out, CompilerInstance &CI) { + + auto CheckerMgr = std::make_unique( + *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(), + CI.getFrontendOpts().Plugins); + + CheckerMgr->getCheckerRegistry().printCheckerOptionList(out); } void ento::printAnalyzerConfigList(raw_ostream &out) { Index: clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt =================================================================== --- clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt +++ clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt @@ -6,7 +6,7 @@ add_clang_library(clangStaticAnalyzerFrontend AnalysisConsumer.cpp - CheckerRegistration.cpp + AnalyzerHelpFlags.cpp CheckerRegistry.cpp FrontendActions.cpp ModelConsumer.cpp Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -109,9 +109,9 @@ CheckerRegistry::CheckerRegistry( ArrayRef Plugins, DiagnosticsEngine &Diags, - AnalyzerOptions &AnOpts, const LangOptions &LangOpts, + AnalyzerOptions &AnOpts, ArrayRef> CheckerRegistrationFns) - : Diags(Diags), AnOpts(AnOpts), LangOpts(LangOpts) { + : Diags(Diags), AnOpts(AnOpts) { // Register builtin checkers. #define GET_CHECKERS @@ -179,12 +179,16 @@ addDependency(FULLNAME, DEPENDENCY); #define GET_CHECKER_OPTIONS -#define CHECKER_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, DEVELOPMENT_STATUS, IS_HIDDEN) \ - addCheckerOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, DEVELOPMENT_STATUS, IS_HIDDEN); +#define CHECKER_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, \ + DEVELOPMENT_STATUS, IS_HIDDEN) \ + addCheckerOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, \ + DEVELOPMENT_STATUS, IS_HIDDEN); #define GET_PACKAGE_OPTIONS -#define PACKAGE_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, DEVELOPMENT_STATUS, IS_HIDDEN) \ - addPackageOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, DEVELOPMENT_STATUS, IS_HIDDEN); +#define PACKAGE_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, \ + DEVELOPMENT_STATUS, IS_HIDDEN) \ + addPackageOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, \ + DEVELOPMENT_STATUS, IS_HIDDEN); #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER_DEPENDENCY @@ -213,24 +217,53 @@ : StateFromCmdLine::State_Disabled; } } + validateCheckerOptions(); +} + +/// Collects dependenies in \p enabledCheckers. Return None on failure. +LLVM_NODISCARD +static llvm::Optional +collectDependencies(const CheckerRegistry::CheckerInfo &checker, + const CheckerManager &Mgr); + +void CheckerRegistry::initializeRegistry(const CheckerManager &Mgr) { + for (const CheckerInfo &Checker : Checkers) { + if (!Checker.isEnabled(Mgr)) + continue; + + // Recursively enable its dependencies. + llvm::Optional Deps = collectDependencies(Checker, Mgr); + + if (!Deps) { + // If we failed to enable any of the dependencies, don't enable this + // checker. + continue; + } + + // Note that set_union also preserves the order of insertion. + EnabledCheckers.set_union(*Deps); + + // Enable the checker. + EnabledCheckers.insert(&Checker); + } } /// Collects dependencies in \p ret, returns false on failure. static bool collectDependenciesImpl(const CheckerRegistry::ConstCheckerInfoList &Deps, - const LangOptions &LO, + const CheckerManager &Mgr, CheckerRegistry::CheckerInfoSet &Ret); /// Collects dependenies in \p enabledCheckers. Return None on failure. LLVM_NODISCARD static llvm::Optional collectDependencies(const CheckerRegistry::CheckerInfo &checker, - const LangOptions &LO) { + const CheckerManager &Mgr) { CheckerRegistry::CheckerInfoSet Ret; // Add dependencies to the enabled checkers only if all of them can be // enabled. - if (!collectDependenciesImpl(checker.Dependencies, LO, Ret)) + if (!collectDependenciesImpl(checker.Dependencies, Mgr, Ret)) return None; return Ret; @@ -238,16 +271,16 @@ static bool collectDependenciesImpl(const CheckerRegistry::ConstCheckerInfoList &Deps, - const LangOptions &LO, + const CheckerManager &Mgr, CheckerRegistry::CheckerInfoSet &Ret) { for (const CheckerRegistry::CheckerInfo *Dependency : Deps) { - if (Dependency->isDisabled(LO)) + if (Dependency->isDisabled(Mgr)) return false; // Collect dependencies recursively. - if (!collectDependenciesImpl(Dependency->Dependencies, LO, Ret)) + if (!collectDependenciesImpl(Dependency->Dependencies, Mgr, Ret)) return false; Ret.insert(Dependency); @@ -256,34 +289,6 @@ return true; } -CheckerRegistry::CheckerInfoSet CheckerRegistry::getEnabledCheckers() const { - - CheckerInfoSet EnabledCheckers; - - for (const CheckerInfo &Checker : Checkers) { - if (!Checker.isEnabled(LangOpts)) - continue; - - // Recursively enable its dependencies. - llvm::Optional Deps = - collectDependencies(Checker, LangOpts); - - if (!Deps) { - // If we failed to enable any of the dependencies, don't enable this - // checker. - continue; - } - - // Note that set_union also preserves the order of insertion. - EnabledCheckers.set_union(*Deps); - - // Enable the checker. - EnabledCheckers.insert(&Checker); - } - - return EnabledCheckers; -} - void CheckerRegistry::resolveDependencies() { for (const std::pair &Entry : Dependencies) { auto CheckerIt = binaryFind(Checkers, Entry.first); @@ -298,8 +303,6 @@ CheckerIt->Dependencies.emplace_back(&*DependencyIt); } - - Dependencies.clear(); } void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) { @@ -378,14 +381,12 @@ insertOptionToCollection(CheckerOptEntry.first, Checkers, CheckerOptEntry.second, AnOpts, Diags); } - CheckerOptions.clear(); for (const std::pair &PackageOptEntry : PackageOptions) { insertOptionToCollection(PackageOptEntry.first, Packages, PackageOptEntry.second, AnOpts, Diags); } - PackageOptions.clear(); } void CheckerRegistry::addPackage(StringRef FullName) { @@ -432,11 +433,8 @@ } void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const { - // Collect checkers enabled by the options. - CheckerInfoSet enabledCheckers = getEnabledCheckers(); - // Initialize the CheckerManager with all enabled checkers. - for (const auto *Checker : enabledCheckers) { + for (const auto *Checker : EnabledCheckers) { CheckerMgr.setCurrentCheckerName(CheckerNameRef(Checker->FullName)); Checker->Initialize(CheckerMgr); } @@ -505,6 +503,10 @@ } } +//===----------------------------------------------------------------------===// +// Printing functions. +//===----------------------------------------------------------------------===// + void CheckerRegistry::printCheckerWithDescList(raw_ostream &Out, size_t MaxNameChars) const { // FIXME: Print available packages. @@ -556,9 +558,6 @@ } void CheckerRegistry::printEnabledCheckerList(raw_ostream &Out) const { - // Collect checkers enabled by the options. - CheckerInfoSet EnabledCheckers = getEnabledCheckers(); - for (const auto *i : EnabledCheckers) Out << i->FullName << '\n'; } Index: clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp =================================================================== --- /dev/null +++ clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\ +// RUN: -analyzer-config c++-container-inlining=false %s 2>&1 | FileCheck %s + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s 2>&1 |\ +// RUN: FileCheck %s + +// CHECK: checker cannot be enabled with analyzer option 'aggressive-binary-operation-simplification' == false Index: clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp =================================================================== --- /dev/null +++ clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config c++-container-inlining=false %s 2>&1 | FileCheck %s + +// RUN: %clang_analyze_cc1 -std=c++11\ +// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\ +// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s 2>&1 |\ +// RUN: FileCheck %s + +// CHECK: checker cannot be enabled with analyzer option 'aggressive-binary-operation-simplification' == false + +#include "Inputs/system-header-simulator-cxx.h" + +template +long clang_analyzer_container_end(const Container&); +template +long clang_analyzer_iterator_position(const Iterator&); + +void clang_analyzer_eval(bool); + + +template +InputIterator nonStdFind(InputIterator first, InputIterator last, + const T &val) { + for (auto i = first; i != last; ++i) { + if (*i == val) { + return i; + } + } + return last; +} + +void non_std_find(std::vector &V, int e) { + auto first = nonStdFind(V.begin(), V.end(), e); + clang_analyzer_eval(clang_analyzer_container_end(V) == + clang_analyzer_iterator_position(first)); + if (V.end() != first) { + clang_analyzer_eval(clang_analyzer_container_end(V) == + clang_analyzer_iterator_position(first)); + } +} Index: clang/test/Analysis/loop-widening-notes.cpp =================================================================== --- clang/test/Analysis/loop-widening-notes.cpp +++ clang/test/Analysis/loop-widening-notes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s int *p_a; int bar();