
Recommit of r361790 that was temporarily reverted in r361793 due to bot breakage. Summary: The following changes were required to fix these tests: 1) Change LLVM_ENABLE_PLUGINS to an option and move it to llvm/CMakeLists.txt with an appropriate default -- which matches the original default behavior. 2) Move the plugins directory from clang/test/Analysis clang/lib/Analysis. It's not enough to add an exclude to the lit.local.cfg file because add_lit_testsuites recurses the tree and automatically adds the appropriate `check-` targets, which don't make sense for the plugins because they aren't tests and don't have `RUN` statements. Here's a list of the `clang-check-anlysis*` targets with this change: ``` $ ninja -t targets all| sed -n "s/.*\/\(check[^:]*\):.*/\1/p" | sort -u | grep clang-analysis check-clang-analysis check-clang-analysis-checkers check-clang-analysis-copypaste check-clang-analysis-diagnostics check-clang-analysis-engine check-clang-analysis-exploration_order check-clang-analysis-html_diagnostics check-clang-analysis-html_diagnostics-relevant_lines check-clang-analysis-inlining check-clang-analysis-objc check-clang-analysis-unified-sources check-clang-analysis-z3 ``` 3) Simplify the logic and only include the subdirectories under clang/lib/Analysis/plugins if LLVM_ENABLE_PLUGINS is set. Reviewed By: NoQ Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62445 llvm-svn: 362328
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
#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;
|