aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:27:22 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:27:22 +0000
commit180e03f9761aa55b5adca430706595e1bbb79c4d (patch)
tree82f7bb5b622619dc7708cfa6aaa1097003d9e352 /lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
parent3267d9563f8265bfce967b3801273a7c53b91346 (diff)
[analyzer] Migrate UndefResultChecker to CheckerV2.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
index 64a3567bc3..602c59a428 100644
--- a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -12,9 +12,11 @@
//
//===----------------------------------------------------------------------===//
-#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"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
using namespace clang;
@@ -22,23 +24,17 @@ using namespace ento;
namespace {
class UndefResultChecker
- : public CheckerVisitor<UndefResultChecker> {
+ : public CheckerV2< check::PostStmt<BinaryOperator> > {
- BugType *BT;
+ mutable llvm::OwningPtr<BugType> BT;
public:
- UndefResultChecker() : BT(0) {}
- static void *getTag() { static int tag = 0; return &tag; }
- void PostVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
+ void checkPostStmt(const BinaryOperator *B, CheckerContext &C) const;
};
} // end anonymous namespace
-void ento::RegisterUndefResultChecker(ExprEngine &Eng) {
- Eng.registerCheck(new UndefResultChecker());
-}
-
-void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C,
- const BinaryOperator *B) {
+void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
+ CheckerContext &C) const {
const GRState *state = C.getState();
if (state->getSVal(B).isUndef()) {
// Generate an error node.
@@ -47,7 +43,7 @@ void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C,
return;
if (!BT)
- BT = new BuiltinBug("Result of operation is garbage or undefined");
+ BT.reset(new BuiltinBug("Result of operation is garbage or undefined"));
llvm::SmallString<256> sbuf;
llvm::raw_svector_ostream OS(sbuf);
@@ -85,3 +81,7 @@ void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C,
C.EmitReport(report);
}
}
+
+void ento::registerUndefResultChecker(CheckerManager &mgr) {
+ mgr.registerChecker<UndefResultChecker>();
+}