summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:28:01 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:28:01 +0000
commit6fff2e3d36ce51976cd63abf6203d9701a08a53f (patch)
tree61ce58bfbdd9ef95d847bffe36909dbf3af6e488 /clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
parent4f7745a3b1421c8559d810e3fa8b5f974f69cc7d (diff)
downloadbcm5719-llvm-6fff2e3d36ce51976cd63abf6203d9701a08a53f.tar.gz
bcm5719-llvm-6fff2e3d36ce51976cd63abf6203d9701a08a53f.zip
[analyzer] Migrate AttrNonNullChecker to CheckerV2.
llvm-svn: 126623
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
index e4865b142c0..7b0e443f865 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
@@ -12,33 +12,27 @@
//
//===----------------------------------------------------------------------===//
-#include "InternalChecks.h"
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/CheckerV2.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
using namespace clang;
using namespace ento;
namespace {
class AttrNonNullChecker
- : public CheckerVisitor<AttrNonNullChecker> {
- BugType *BT;
+ : public CheckerV2< check::PreStmt<CallExpr> > {
+ mutable llvm::OwningPtr<BugType> BT;
public:
- AttrNonNullChecker() : BT(0) {}
- static void *getTag() {
- static int x = 0;
- return &x;
- }
- void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE);
+
+ void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
};
} // end anonymous namespace
-void ento::RegisterAttrNonNullChecker(ExprEngine &Eng) {
- Eng.registerCheck(new AttrNonNullChecker());
-}
-
-void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C,
- const CallExpr *CE) {
+void AttrNonNullChecker::checkPreStmt(const CallExpr *CE,
+ CheckerContext &C) const {
const GRState *state = C.getState();
// Check if the callee has a 'nonnull' attribute.
@@ -103,8 +97,8 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C,
// created. Ownership is transferred to the BugReporter object once
// the BugReport is passed to 'EmitWarning'.
if (!BT)
- BT = new BugType("Argument with 'nonnull' attribute passed null",
- "API");
+ BT.reset(new BugType("Argument with 'nonnull' attribute passed null",
+ "API"));
EnhancedBugReport *R =
new EnhancedBugReport(*BT,
@@ -134,3 +128,7 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C,
// If 'state' has been updated generated a new node.
C.addTransition(state);
}
+
+void ento::registerAttrNonNullChecker(CheckerManager &mgr) {
+ mgr.registerChecker<AttrNonNullChecker>();
+}
OpenPOWER on IntegriCloud