summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKristof Umann <kristof.umann@ericsson.com>2019-05-16 13:22:04 +0000
committerKristof Umann <kristof.umann@ericsson.com>2019-05-16 13:22:04 +0000
commit2b469b71cbf579c95af77cbdd667f17965a0fb0f (patch)
tree2b9953dc36980e62dcd287684e91d7232e54ec5a /examples
parenteffb4994daa210879cc375c55141296e93b27534 (diff)
downloadclang-2b469b71cbf579c95af77cbdd667f17965a0fb0f.tar.gz
Reland "[analyzer] Add an example plugin for checker dependency handling"
Buildbots complained that they couldn't find the newly added plugins. The solution was to move the check-clang cmake target closer to the bottom of the file, after the new dependencies are added. Differential Revision: https://reviews.llvm.org/D59464 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt3
-rw-r--r--examples/analyzer-plugin/CMakeLists.txt11
-rw-r--r--examples/analyzer-plugin/MainCallChecker.cpp54
-rw-r--r--examples/analyzer-plugin/SampleAnalyzerPlugin.exports2
4 files changed, 0 insertions, 70 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 8c2654840a..e4fedf3682 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -3,9 +3,6 @@ if(NOT CLANG_BUILD_EXAMPLES)
set(EXCLUDE_FROM_ALL ON)
endif()
-if(CLANG_ENABLE_STATIC_ANALYZER)
-add_subdirectory(analyzer-plugin)
-endif()
add_subdirectory(clang-interpreter)
add_subdirectory(PrintFunctionNames)
add_subdirectory(AnnotateFunctions)
diff --git a/examples/analyzer-plugin/CMakeLists.txt b/examples/analyzer-plugin/CMakeLists.txt
deleted file mode 100644
index 7c7b2aec19..0000000000
--- a/examples/analyzer-plugin/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
-add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang)
-
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
- target_link_libraries(SampleAnalyzerPlugin PRIVATE
- clangAnalysis
- clangAST
- clangStaticAnalyzerCore
- LLVMSupport
- )
-endif()
diff --git a/examples/analyzer-plugin/MainCallChecker.cpp b/examples/analyzer-plugin/MainCallChecker.cpp
deleted file mode 100644
index 77316d696d..0000000000
--- a/examples/analyzer-plugin/MainCallChecker.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "clang/StaticAnalyzer/Core/Checker.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
-
-using namespace clang;
-using namespace ento;
-
-namespace {
-class MainCallChecker : public Checker < check::PreStmt<CallExpr> > {
- mutable std::unique_ptr<BugType> BT;
-
-public:
- void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
-};
-} // end anonymous namespace
-
-void MainCallChecker::checkPreStmt(const CallExpr *CE, CheckerContext &C) const {
- const Expr *Callee = CE->getCallee();
- const FunctionDecl *FD = C.getSVal(Callee).getAsFunctionDecl();
-
- if (!FD)
- return;
-
- // Get the name of the callee.
- IdentifierInfo *II = FD->getIdentifier();
- if (!II) // if no identifier, not a simple C function
- return;
-
- if (II->isStr("main")) {
- ExplodedNode *N = C.generateErrorNode();
- if (!N)
- return;
-
- if (!BT)
- BT.reset(new BugType(this, "call to main", "example analyzer plugin"));
-
- std::unique_ptr<BugReport> report =
- llvm::make_unique<BugReport>(*BT, BT->getName(), N);
- report->addRange(Callee->getSourceRange());
- C.emitReport(std::move(report));
- }
-}
-
-// Register plugin!
-extern "C"
-void clang_registerCheckers (CheckerRegistry &registry) {
- registry.addChecker<MainCallChecker>(
- "example.MainCallChecker", "Disallows calls to functions called main",
- "");
-}
-
-extern "C"
-const char clang_analyzerAPIVersionString[] = CLANG_ANALYZER_API_VERSION_STRING;
diff --git a/examples/analyzer-plugin/SampleAnalyzerPlugin.exports b/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
deleted file mode 100644
index 8d9ff882cf..0000000000
--- a/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
+++ /dev/null
@@ -1,2 +0,0 @@
-clang_registerCheckers
-clang_analyzerAPIVersionString