[analyzer] Migrate UndefResultChecker to CheckerV2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126614 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
index 64a3567..602c59a 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 @@
 
 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 @@
       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 @@
     C.EmitReport(report);
   }
 }
+
+void ento::registerUndefResultChecker(CheckerManager &mgr) {
+  mgr.registerChecker<UndefResultChecker>();
+}