clang  11.0.0git
Public Member Functions | List of all members
clang::ento::CheckerRegistry Class Reference

Manages a set of available checkers for running a static analysis. More...

#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"

Public Member Functions

 CheckerRegistry (CheckerRegistryData &Data, ArrayRef< std::string > Plugins, DiagnosticsEngine &Diags, AnalyzerOptions &AnOpts, ArrayRef< std::function< void(CheckerRegistry &)>> CheckerRegistrationFns={})
 
void initializeRegistry (const CheckerManager &Mgr)
 Collects all enabled checkers in the field EnabledCheckers. More...
 
void addChecker (RegisterCheckerFn 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 depend on the checker called dependency. More...
 
void addWeakDependency (StringRef FullName, StringRef Dependency)
 Makes the checker with the full name fullName weak depend 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...
 
template<bool IsWeak>
void resolveDependencies ()
 

Detailed Description

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 89 of file CheckerRegistry.h.

Constructor & Destructor Documentation

◆ CheckerRegistry()

CheckerRegistry::CheckerRegistry ( CheckerRegistryData Data,
ArrayRef< std::string >  Plugins,
DiagnosticsEngine Diags,
AnalyzerOptions AnOpts,
ArrayRef< std::function< void(CheckerRegistry &)>>  CheckerRegistrationFns = {} 
)

Member Function Documentation

◆ addChecker() [1/2]

void clang::ento::CheckerRegistry::addChecker ( RegisterCheckerFn  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().

◆ addChecker() [2/2]

template<class T >
void clang::ento::CheckerRegistry::addChecker ( StringRef  FullName,
StringRef  Desc,
StringRef  DocsUri,
bool  IsHidden = false 
)
inline

Adds a checker to the registry.

Use this templated overload when your checker does not require any custom initialization. This function isn't really needed and probably causes more headaches than the tiny convenience that it provides, but external plugins might use it, and there isn't a strong incentive to remove it.

Definition at line 128 of file CheckerRegistry.h.

References addChecker(), addCheckerOption(), addDependency(), addPackage(), addPackageOption(), addWeakDependency(), and validateCheckerOptions().

◆ addCheckerOption()

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 450 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::CheckerOptions.

Referenced by addChecker(), and clang_registerCheckers().

◆ addDependency()

void CheckerRegistry::addDependency ( StringRef  FullName,
StringRef  Dependency 
)

Makes the checker with the full name fullName depend on the checker called dependency.

Definition at line 327 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::Dependencies.

Referenced by addChecker(), and clang_registerCheckers().

◆ addPackage()

void CheckerRegistry::addPackage ( StringRef  FullName)

Adds a package to the registry.

Definition at line 419 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::Packages.

Referenced by addChecker().

◆ addPackageOption()

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 423 of file CheckerRegistry.cpp.

References addChecker(), and clang::ento::CheckerRegistryData::PackageOptions.

Referenced by addChecker().

◆ addWeakDependency()

void CheckerRegistry::addWeakDependency ( StringRef  FullName,
StringRef  Dependency 
)

Makes the checker with the full name fullName weak depend on the checker called dependency.

Definition at line 331 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::WeakDependencies.

Referenced by addChecker().

◆ initializeManager()

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 462 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::EnabledCheckers, and clang::ento::CheckerManager::setCurrentCheckerName().

◆ initializeRegistry()

void CheckerRegistry::initializeRegistry ( const CheckerManager Mgr)

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.

Definition at line 206 of file CheckerRegistry.cpp.

References clang::ento::CheckerRegistryData::Checkers, collectStrongDependencies(), collectWeakDependencies(), clang::ento::CheckerInfo::Dependencies, clang::ento::CheckerRegistryData::EnabledCheckers, clang::ento::CheckerInfo::isEnabled(), and clang::ento::CheckerInfo::WeakDependencies.

Referenced by clang::ento::CheckerManager::CheckerManager().

◆ resolveDependencies()

template<bool IsWeak>
void clang::ento::CheckerRegistry::resolveDependencies ( )

◆ validateCheckerOptions()

void CheckerRegistry::validateCheckerOptions ( ) const

The documentation for this class was generated from the following files: