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

Public Types

using InitializationFunction = void(*)(CheckerManager &)
 Initialization functions perform any necessary setup for a checker. More...
 
using ShouldRegisterFunction = bool(*)(const LangOptions &)
 
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
 

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)
 Adds a checker to the registry. More...
 
template<class T >
void addChecker (StringRef FullName, StringRef Desc, StringRef DocsUri)
 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 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
 

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

◆ CheckerInfoListRange

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

Definition at line 97 of file CheckerRegistry.h.

◆ CheckerInfoSet

Definition at line 99 of file CheckerRegistry.h.

◆ ConstCheckerInfoList

Definition at line 98 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.

◆ ShouldRegisterFunction

Definition at line 92 of file CheckerRegistry.h.

◆ StateFromCmdLine

Definition at line 137 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 
)

Adds a checker to the registry.

Use this non-templated overload when your checker requires custom initialization.

Referenced by addChecker(), and collectDependenciesImpl().

◆ addChecker() [2/2]

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

Adds a checker to the registry.

Use this templated overload when your checker does not require any custom initialization.

Definition at line 157 of file CheckerRegistry.h.

References addChecker(), addDependency(), printCheckerWithDescList(), printEnabledCheckerList(), and validateCheckerOptions().

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

References binaryFind().

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

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

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

References max().

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

◆ printEnabledCheckerList()

void CheckerRegistry::printEnabledCheckerList ( raw_ostream &  Out) const

Definition at line 359 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 306 of file CheckerRegistry.cpp.

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

Referenced by addChecker().


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