summaryrefslogtreecommitdiffstats
path: root/clang/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
commitd4d3cee6e4c4b81d426baa93a980216697082080 (patch)
treee02b67af6c60c2b20e128ed17045ee6e2b7558ba /clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
parent142dbbfcd81abaeb2a384c7e64c2c3f2111b78d6 (diff)
downloadbcm5719-llvm-d4d3cee6e4c4b81d426baa93a980216697082080.tar.gz
bcm5719-llvm-d4d3cee6e4c4b81d426baa93a980216697082080.zip
[analyzer] Migrate UndefResultChecker to CheckerV2.
llvm-svn: 126614
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
index 64a3567bc34..602c59a4281 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ b/clang/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>();
+}
OpenPOWER on IntegriCloud