clang
9.0.0
|
Manages a set of available checkers for running a static analysis. More...
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
Classes | |
struct | CheckerInfo |
Specifies a checker. More... | |
struct | CmdLineOption |
Specifies a command line option. More... | |
struct | PackageInfo |
Specifies a package. More... | |
Public Types | |
using | InitializationFunction = void(*)(CheckerManager &) |
Initialization functions perform any necessary setup for a checker. More... | |
using | ShouldRegisterFunction = bool(*)(const LangOptions &) |
using | CmdLineOptionList = llvm::SmallVector< CmdLineOption, 0 > |
using | CheckerInfoList = std::vector< CheckerInfo > |
using | CheckerInfoListRange = llvm::iterator_range< CheckerInfoList::iterator > |
using | ConstCheckerInfoList = llvm::SmallVector< const CheckerInfo *, 0 > |
using | CheckerInfoSet = llvm::SetVector< const CheckerInfo * > |
using | StateFromCmdLine = CheckerInfo::StateFromCmdLine |
using | PackageInfoList = llvm::SmallVector< PackageInfo, 0 > |
Public Member Functions | |
CheckerRegistry (ArrayRef< std::string > plugins, DiagnosticsEngine &diags, AnalyzerOptions &AnOpts, const LangOptions &LangOpts, ArrayRef< std::function< void(CheckerRegistry &)>> checkerRegistrationFns={}) | |
void | addChecker (InitializationFunction Fn, ShouldRegisterFunction sfn, StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden) |
Adds a checker to the registry. More... | |
template<class T > | |
void | addChecker (StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden=false) |
Adds a checker to the registry. More... | |
void | addDependency (StringRef FullName, StringRef Dependency) |
Makes the checker with the full name fullName depends on the checker called dependency . More... | |
void | addCheckerOption (StringRef OptionType, StringRef CheckerFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, bool IsHidden=false) |
Registers an option to a given checker. More... | |
void | addPackage (StringRef FullName) |
Adds a package to the registry. More... | |
void | addPackageOption (StringRef OptionType, StringRef PackageFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, bool IsHidden=false) |
Registers an option to a given package. More... | |
void | initializeManager (CheckerManager &CheckerMgr) const |
Initializes a CheckerManager by calling the initialization functions for all checkers specified by the given CheckerOptInfo list. More... | |
void | validateCheckerOptions () const |
Check if every option corresponds to a specific checker or package. More... | |
void | printCheckerWithDescList (raw_ostream &Out, size_t MaxNameChars=30) const |
Prints the name and description of all checkers in this registry. More... | |
void | printEnabledCheckerList (raw_ostream &Out) const |
void | printCheckerOptionList (raw_ostream &Out) const |
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. For example, the checker "core.builtin.NoReturnFunctionChecker" will be included if initializeManager() is called with an option of "core", "core.builtin", or the full name "core.builtin.NoReturnFunctionChecker".
Definition at line 82 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::CheckerInfoList = std::vector<CheckerInfo> |
Definition at line 136 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::CheckerInfoListRange = llvm::iterator_range<CheckerInfoList::iterator> |
Definition at line 137 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::CheckerInfoSet = llvm::SetVector<const CheckerInfo *> |
Definition at line 139 of file CheckerRegistry.h.
Definition at line 132 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::ConstCheckerInfoList = llvm::SmallVector<const CheckerInfo *, 0> |
Definition at line 138 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::InitializationFunction = void (*)(CheckerManager &) |
Initialization functions perform any necessary setup for a checker.
They should include a call to CheckerManager::registerChecker.
Definition at line 91 of file CheckerRegistry.h.
Definition at line 205 of file CheckerRegistry.h.
using clang::ento::CheckerRegistry::ShouldRegisterFunction = bool (*)(const LangOptions &) |
Definition at line 92 of file CheckerRegistry.h.
Definition at line 188 of file CheckerRegistry.h.
CheckerRegistry::CheckerRegistry | ( | ArrayRef< std::string > | plugins, |
DiagnosticsEngine & | diags, | ||
AnalyzerOptions & | AnOpts, | ||
const LangOptions & | LangOpts, | ||
ArrayRef< std::function< void(CheckerRegistry &)>> | checkerRegistrationFns = {} |
||
) |
Definition at line 111 of file CheckerRegistry.cpp.
References clang::AnalyzerOptions::CheckersControlList, CLANG_ANALYZER_API_VERSION_STRING, collectDependenciesImpl(), isCompatibleAPIVersion(), clang::DiagnosticsEngine::Report(), clang::ento::CheckerRegistry::CheckerInfo::State_Disabled, and clang::ento::CheckerRegistry::CheckerInfo::State_Enabled.
void clang::ento::CheckerRegistry::addChecker | ( | InitializationFunction | Fn, |
ShouldRegisterFunction | sfn, | ||
StringRef | FullName, | ||
StringRef | Desc, | ||
StringRef | DocsUri, | ||
bool | IsHidden | ||
) |
Adds a checker to the registry.
Use this non-templated overload when your checker requires custom initialization.
Referenced by addChecker(), addPackageOption(), and clang_registerCheckers().
|
inline |
Adds a checker to the registry.
Use this templated overload when your checker does not require any custom initialization.
Definition at line 226 of file CheckerRegistry.h.
References addChecker(), addCheckerOption(), addDependency(), addPackage(), addPackageOption(), clang::ento::CheckerRegistry::CmdLineOption::DefaultValStr, clang::ento::CheckerRegistry::CmdLineOption::Description, clang::ento::CheckerRegistry::CmdLineOption::DevelopmentStatus, clang::ento::CheckerRegistry::CmdLineOption::OptionName, clang::ento::CheckerRegistry::CmdLineOption::OptionType, printCheckerOptionList(), printCheckerWithDescList(), printEnabledCheckerList(), and validateCheckerOptions().
void CheckerRegistry::addCheckerOption | ( | StringRef | OptionType, |
StringRef | CheckerFullName, | ||
StringRef | OptionName, | ||
StringRef | DefaultValStr, | ||
StringRef | Description, | ||
StringRef | DevelopmentStatus, | ||
bool | IsHidden = false |
||
) |
Registers an option to a given checker.
A checker option will always have the following format: CheckerFullName:OptionName=Value And can be specified from the command line like this: -analyzer-config CheckerFullName:OptionName=Value
Options for unknown checkers, or unknown options for a given checker, or invalid value types for that given option are reported as an error in non-compatibility mode.
Definition at line 422 of file CheckerRegistry.cpp.
Referenced by addChecker(), and clang_registerCheckers().
void CheckerRegistry::addDependency | ( | StringRef | FullName, |
StringRef | Dependency | ||
) |
Makes the checker with the full name fullName
depends on the checker called dependency
.
Definition at line 306 of file CheckerRegistry.cpp.
Referenced by addChecker(), and clang_registerCheckers().
void CheckerRegistry::addPackage | ( | StringRef | FullName | ) |
Adds a package to the registry.
Definition at line 391 of file CheckerRegistry.cpp.
Referenced by addChecker().
void CheckerRegistry::addPackageOption | ( | StringRef | OptionType, |
StringRef | PackageFullName, | ||
StringRef | OptionName, | ||
StringRef | DefaultValStr, | ||
StringRef | Description, | ||
StringRef | DevelopmentStatus, | ||
bool | IsHidden = false |
||
) |
Registers an option to a given package.
A package option will always have the following format: PackageFullName:OptionName=Value And can be specified from the command line like this: -analyzer-config PackageFullName:OptionName=Value
Options for unknown packages, or unknown options for a given package, or invalid value types for that given option are reported as an error in non-compatibility mode.
Definition at line 395 of file CheckerRegistry.cpp.
References addChecker().
Referenced by addChecker().
void CheckerRegistry::initializeManager | ( | CheckerManager & | CheckerMgr | ) | const |
Initializes a CheckerManager by calling the initialization functions for all checkers specified by the given CheckerOptInfo list.
The order of this list is significant; later options can be used to reverse earlier ones. This can be used to exclude certain checkers in an included package.
Definition at line 434 of file CheckerRegistry.cpp.
References clang::ento::CheckerManager::setCurrentCheckName().
void CheckerRegistry::printCheckerOptionList | ( | raw_ostream & | Out | ) | const |
Definition at line 562 of file CheckerRegistry.cpp.
References clang::ento::CheckerRegistry::CmdLineOption::DefaultValStr, clang::ento::CheckerRegistry::CmdLineOption::Description, clang::ento::CheckerRegistry::CmdLineOption::DevelopmentStatus, clang::ento::CheckerRegistry::CmdLineOption::IsHidden, clang::ento::CheckerRegistry::CmdLineOption::OptionName, clang::ento::CheckerRegistry::CmdLineOption::OptionType, clang::AnalyzerOptions::printFormattedEntry(), clang::AnalyzerOptions::ShowCheckerOptionAlphaList, clang::AnalyzerOptions::ShowCheckerOptionDeveloperList, and clang::AnalyzerOptions::ShowCheckerOptionList.
Referenced by addChecker(), and clang::ento::printCheckerConfigList().
void CheckerRegistry::printCheckerWithDescList | ( | raw_ostream & | Out, |
size_t | MaxNameChars = 30 |
||
) | const |
Prints the name and description of all checkers in this registry.
This output is not intended to be machine-parseable.
Definition at line 504 of file CheckerRegistry.cpp.
References max(), clang::AnalyzerOptions::printFormattedEntry(), clang::AnalyzerOptions::ShowCheckerHelp, clang::AnalyzerOptions::ShowCheckerHelpAlpha, and clang::AnalyzerOptions::ShowCheckerHelpDeveloper.
Referenced by addChecker(), and clang::ento::printCheckerHelp().
void CheckerRegistry::printEnabledCheckerList | ( | raw_ostream & | Out | ) | const |
Definition at line 554 of file CheckerRegistry.cpp.
References i.
Referenced by addChecker(), and clang::ento::printEnabledCheckerList().
void CheckerRegistry::validateCheckerOptions | ( | ) | const |
Check if every option corresponds to a specific checker or package.
Definition at line 468 of file CheckerRegistry.cpp.
References clang::AnalyzerOptions::Config, isOptionContainedIn(), and clang::DiagnosticsEngine::Report().
Referenced by addChecker().