clang  10.0.0svn
Classes | Public Types | 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"

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
 

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

Member Typedef Documentation

◆ CheckerInfoList

Definition at line 136 of file CheckerRegistry.h.

◆ CheckerInfoListRange

using clang::ento::CheckerRegistry::CheckerInfoListRange = llvm::iterator_range<CheckerInfoList::iterator>

Definition at line 137 of file CheckerRegistry.h.

◆ CheckerInfoSet

Definition at line 139 of file CheckerRegistry.h.

◆ CmdLineOptionList

Definition at line 132 of file CheckerRegistry.h.

◆ ConstCheckerInfoList

Definition at line 138 of file CheckerRegistry.h.

◆ InitializationFunction

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.

◆ PackageInfoList

Definition at line 205 of file CheckerRegistry.h.

◆ ShouldRegisterFunction

Definition at line 92 of file CheckerRegistry.h.

◆ StateFromCmdLine

Definition at line 188 of file CheckerRegistry.h.

Constructor & Destructor Documentation

◆ CheckerRegistry()

CheckerRegistry::CheckerRegistry ( ArrayRef< std::string >  plugins,
DiagnosticsEngine diags,
AnalyzerOptions AnOpts,
const LangOptions LangOpts,
ArrayRef< std::function< void(CheckerRegistry &)>>  checkerRegistrationFns = {} 
)

Member Function Documentation

◆ addChecker() [1/2]

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

◆ addChecker() [2/2]

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

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

Referenced by addChecker(), and clang_registerCheckers().

◆ addDependency()

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

◆ addPackage()

void CheckerRegistry::addPackage ( StringRef  FullName)

Adds a package to the registry.

Definition at line 391 of file CheckerRegistry.cpp.

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

References addChecker().

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

References clang::ento::CheckerManager::setCurrentCheckerName().

◆ printCheckerOptionList()

void CheckerRegistry::printCheckerOptionList ( raw_ostream &  Out) const

◆ printCheckerWithDescList()

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 508 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().

◆ printEnabledCheckerList()

void CheckerRegistry::printEnabledCheckerList ( raw_ostream &  Out) const

Definition at line 558 of file CheckerRegistry.cpp.

Referenced by addChecker(), and clang::ento::printEnabledCheckerList().

◆ validateCheckerOptions()

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


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