clang 19.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.
 
void addChecker (RegisterCheckerFn Fn, ShouldRegisterFunction sfn, StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden)
 Adds a checker to the registry.
 
template<class T >
void addChecker (StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden=false)
 Adds a checker to the registry.
 
void addDependency (StringRef FullName, StringRef Dependency)
 Makes the checker with the full name fullName depend on the checker called dependency.
 
void addWeakDependency (StringRef FullName, StringRef Dependency)
 Makes the checker with the full name fullName weak depend on the checker called dependency.
 
void addCheckerOption (StringRef OptionType, StringRef CheckerFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, bool IsHidden=false)
 Registers an option to a given checker.
 
void addPackage (StringRef FullName)
 Adds a package to the registry.
 
void addPackageOption (StringRef OptionType, StringRef PackageFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, bool IsHidden=false)
 Registers an option to a given package.
 
void initializeManager (CheckerManager &CheckerMgr) const
 Initializes a CheckerManager by calling the initialization functions for all checkers specified by the given CheckerOptInfo list.
 
void validateCheckerOptions () const
 Check if every option corresponds to a specific checker or package.
 

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 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.

Definition at line 434 of file CheckerRegistry.cpp.

References Data, and PackageSeparator.

Referenced by addChecker(), 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()

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

References Data.

Referenced by 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 326 of file CheckerRegistry.cpp.

References Data.

Referenced by clang_registerCheckers().

◆ addPackage()

void CheckerRegistry::addPackage ( StringRef  FullName)

Adds a package to the registry.

Definition at line 418 of file CheckerRegistry.cpp.

References Data.

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

References Data.

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

References Data.

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

References Data, 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 205 of file CheckerRegistry.cpp.

References collectStrongDependencies(), collectWeakDependencies(), and Data.

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

◆ validateCheckerOptions()

void CheckerRegistry::validateCheckerOptions ( ) const

Check if every option corresponds to a specific checker or package.

Definition at line 489 of file CheckerRegistry.cpp.

References clang::AnalyzerOptions::Config, Data, isOptionContainedIn(), and clang::DiagnosticsEngine::Report().

Referenced by CheckerRegistry().


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