clang 22.0.0git
CheckerOptionHandling.cpp
Go to the documentation of this file.
4
5using namespace clang;
6using namespace ento;
7
8// This barebones plugin is used by clang/test/Analysis/checker-plugins.c
9// to test option handling on checkers loaded from plugins.
10
11namespace {
12struct MyChecker : public Checker<check::BeginFunction> {
13 void checkBeginFunction(CheckerContext &Ctx) const {}
14};
15
16void registerMyChecker(CheckerManager &Mgr) {
17 MyChecker *Checker = Mgr.registerChecker<MyChecker>();
18 llvm::outs() << "Example option is set to "
19 << (Mgr.getAnalyzerOptions().getCheckerBooleanOption(
20 Checker, "ExampleOption")
21 ? "true"
22 : "false")
23 << '\n';
24}
25
26bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; }
27
28} // end anonymous namespace
29
30// Register plugin!
31extern "C" void clang_registerCheckers(CheckerRegistry &Registry) {
32 Registry.addChecker(registerMyChecker, shouldRegisterMyChecker,
33 "example.MyChecker", "Example Description");
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
43extern "C" const char clang_analyzerAPIVersionString[] =
const char clang_analyzerAPIVersionString[]
void clang_registerCheckers(CheckerRegistry &Registry)
#define CLANG_ANALYZER_API_VERSION_STRING
const AnalyzerOptions & getAnalyzerOptions() const
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Manages a set of available checkers for running a static analysis.
Simple checker classes that implement one frontend (i.e.
Definition Checker.h:553
The JSON file list parser is used to communicate input to InstallAPI.