Coverage Report

Created: 2020-09-15 12:33

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
Line
Count
Source (jump to first uncovered line)
1
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
2
#include "clang/StaticAnalyzer/Core/Checker.h"
3
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
4
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
5
6
using namespace clang;
7
using namespace ento;
8
9
namespace {
10
struct MyChecker : public Checker<check::BeginFunction> {
11
0
  void checkBeginFunction(CheckerContext &Ctx) const {}
12
};
13
14
0
void registerMyChecker(CheckerManager &Mgr) {
15
0
  MyChecker *Checker = Mgr.registerChecker<MyChecker>();
16
0
  llvm::outs() << "Example option is set to "
17
0
               << (Mgr.getAnalyzerOptions().getCheckerBooleanOption(
18
0
                       Checker, "ExampleOption")
19
0
                       ? "true"
20
0
                       : "false")
21
0
               << '\n';
22
0
}
23
24
0
bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; }
25
26
} // end anonymous namespace
27
28
// Register plugin!
29
0
extern "C" void clang_registerCheckers(CheckerRegistry &registry) {
30
0
  registry.addChecker(registerMyChecker, shouldRegisterMyChecker,
31
0
                      "example.MyChecker", "Example Description",
32
0
                      "example.mychecker.documentation.nonexistent.html",
33
0
                      /*isHidden*/false);
34
0
35
0
  registry.addCheckerOption(/*OptionType*/ "bool",
36
0
                            /*CheckerFullName*/ "example.MyChecker",
37
0
                            /*OptionName*/ "ExampleOption",
38
0
                            /*DefaultValStr*/ "false",
39
0
                            /*Description*/ "This is an example checker opt.",
40
0
                            /*DevelopmentStage*/ "released");
41
0
}
42
43
extern "C" const char clang_analyzerAPIVersionString[] =
44
    CLANG_ANALYZER_API_VERSION_STRING;