clang  14.0.0git
CheckerOptionHandling.cpp
Go to the documentation of this file.
5 
6 using namespace clang;
7 using namespace ento;
8 
9 namespace {
10 struct MyChecker : public Checker<check::BeginFunction> {
11  void checkBeginFunction(CheckerContext &Ctx) const {}
12 };
13 
14 void registerMyChecker(CheckerManager &Mgr) {
15  MyChecker *Checker = Mgr.registerChecker<MyChecker>();
16  llvm::outs() << "Example option is set to "
18  Checker, "ExampleOption")
19  ? "true"
20  : "false")
21  << '\n';
22 }
23 
24 bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; }
25 
26 } // end anonymous namespace
27 
28 // Register plugin!
29 extern "C" void clang_registerCheckers(CheckerRegistry &registry) {
30  registry.addChecker(registerMyChecker, shouldRegisterMyChecker,
31  "example.MyChecker", "Example Description",
32  "example.mychecker.documentation.nonexistent.html",
33  /*isHidden*/false);
34 
35  registry.addCheckerOption(/*OptionType*/ "bool",
36  /*CheckerFullName*/ "example.MyChecker",
37  /*OptionName*/ "ExampleOption",
38  /*DefaultValStr*/ "false",
39  /*Description*/ "This is an example checker opt.",
40  /*DevelopmentStage*/ "released");
41 }
42 
43 extern "C" const char clang_analyzerAPIVersionString[] =
CLANG_ANALYZER_API_VERSION_STRING
#define CLANG_ANALYZER_API_VERSION_STRING
Definition: CheckerRegistry.h:71
clang_registerCheckers
void clang_registerCheckers(CheckerRegistry &registry)
Definition: CheckerOptionHandling.cpp:29
clang::ento::CheckerManager::registerChecker
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
Definition: CheckerManager.h:205
clang::ento::CheckerManager::getAnalyzerOptions
const AnalyzerOptions & getAnalyzerOptions() const
Definition: CheckerManager.h:171
clang_analyzerAPIVersionString
const char clang_analyzerAPIVersionString[]
Definition: CheckerOptionHandling.cpp:43
clang::ento::CheckerRegistry::addCheckerOption
void addCheckerOption(StringRef OptionType, StringRef CheckerFullName, StringRef OptionName, StringRef DefaultValStr, StringRef Description, StringRef DevelopmentStatus, bool IsHidden=false)
Registers an option to a given checker.
Definition: CheckerRegistry.cpp:450
BugType.h
CheckerContext.h
clang::AnalyzerOptions::getCheckerBooleanOption
bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Interprets an option's string value as a boolean.
Definition: AnalyzerOptions.cpp:151
Checker.h
clang::ento::CheckerManager
Definition: CheckerManager.h:127
clang
Definition: CalledOnceCheck.h:17
clang::ento::CheckerContext
Definition: CheckerContext.h:23
CheckerRegistry.h
clang::ento::Checker
Definition: Checker.h:517
clang::ento::CheckerRegistry::addChecker
void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn, StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden)
Adds a checker to the registry.
clang::ento::CheckerRegistry
Manages a set of available checkers for running a static analysis.
Definition: CheckerRegistry.h:89