diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-12-20 19:53:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-12-20 19:53:05 +0000 |
commit | 0b57cec536236d46e3dba9bd041533462f33dbb7 (patch) | |
tree | 56229dbdbbf76d18580f72f789003db17246c8d9 /contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling | |
parent | 718ef55ec7785aae63f98f8ca05dc07ed399c16d (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling')
2 files changed, 46 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp b/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp new file mode 100644 index 000000000000..77de3630ae7e --- /dev/null +++ b/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp @@ -0,0 +1,44 @@ +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" + +using namespace clang; +using namespace ento; + +namespace { +struct MyChecker : public Checker<check::BeginFunction> { + void checkBeginFunction(CheckerContext &Ctx) const {} +}; + +void registerMyChecker(CheckerManager &Mgr) { + MyChecker *Checker = Mgr.registerChecker<MyChecker>(); + llvm::outs() << "Example option is set to " + << (Mgr.getAnalyzerOptions().getCheckerBooleanOption( + Checker, "ExampleOption") + ? "true" + : "false") + << '\n'; +} + +bool shouldRegisterMyChecker(const LangOptions &LO) { return true; } + +} // end anonymous namespace + +// Register plugin! +extern "C" void clang_registerCheckers(CheckerRegistry ®istry) { + registry.addChecker(registerMyChecker, shouldRegisterMyChecker, + "example.MyChecker", "Example Description", + "example.mychecker.documentation.nonexistent.html", + /*isHidden*/false); + + registry.addCheckerOption(/*OptionType*/ "bool", + /*CheckerFullName*/ "example.MyChecker", + /*OptionName*/ "ExampleOption", + /*DefaultValStr*/ "false", + /*Description*/ "This is an example checker opt.", + /*DevelopmentStage*/ "released"); +} + +extern "C" const char clang_analyzerAPIVersionString[] = + CLANG_ANALYZER_API_VERSION_STRING; diff --git a/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports b/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports new file mode 100644 index 000000000000..8d9ff882cfb1 --- /dev/null +++ b/contrib/llvm-project/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandlingAnalyzerPlugin.exports @@ -0,0 +1,2 @@ +clang_registerCheckers +clang_analyzerAPIVersionString |