summaryrefslogtreecommitdiffstats
path: root/clang/examples/analyzer-plugin/MainCallChecker.cpp
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
commit1b93a24c297117c455a126f1c3e858fefe410c2f (patch)
treef3fe99582555a26e93051c3e865abea1ab8fd674 /clang/examples/analyzer-plugin/MainCallChecker.cpp
parent0732fcc7d5a4d11a82b86062ddcdb72f7fb94d41 (diff)
downloadbcm5719-llvm-1b93a24c297117c455a126f1c3e858fefe410c2f.tar.gz
bcm5719-llvm-1b93a24c297117c455a126f1c3e858fefe410c2f.zip
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 llvm-svn: 360891
Diffstat (limited to 'clang/examples/analyzer-plugin/MainCallChecker.cpp')
-rw-r--r--clang/examples/analyzer-plugin/MainCallChecker.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/clang/examples/analyzer-plugin/MainCallChecker.cpp b/clang/examples/analyzer-plugin/MainCallChecker.cpp
deleted file mode 100644
index 77316d696de..00000000000
--- a/clang/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;
OpenPOWER on IntegriCloud