[analyzer] Migrate UndefCapturedBlockVarChecker to CheckerV2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126615 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
index 6d3c966..718aa75 100644
--- a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
@@ -11,8 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "InternalChecks.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.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/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "llvm/Support/raw_ostream.h"
@@ -22,20 +24,14 @@
 
 namespace {
 class UndefCapturedBlockVarChecker
-  : public CheckerVisitor<UndefCapturedBlockVarChecker> {
- BugType *BT;
+  : public CheckerV2< check::PostStmt<BlockExpr> > {
+ mutable llvm::OwningPtr<BugType> BT;
 
 public:
-  UndefCapturedBlockVarChecker() : BT(0) {}
-  static void *getTag() { static int tag = 0; return &tag; }
-  void PostVisitBlockExpr(CheckerContext &C, const BlockExpr *BE);
+  void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const;
 };
 } // end anonymous namespace
 
-void ento::RegisterUndefCapturedBlockVarChecker(ExprEngine &Eng) {
-  Eng.registerCheck(new UndefCapturedBlockVarChecker());
-}
-
 static const BlockDeclRefExpr *FindBlockDeclRefExpr(const Stmt *S,
                                                     const VarDecl *VD){
   if (const BlockDeclRefExpr *BR = dyn_cast<BlockDeclRefExpr>(S))
@@ -54,8 +50,8 @@
 }
 
 void
-UndefCapturedBlockVarChecker::PostVisitBlockExpr(CheckerContext &C,
-                                                 const BlockExpr *BE) {
+UndefCapturedBlockVarChecker::checkPostStmt(const BlockExpr *BE,
+                                            CheckerContext &C) const {
   if (!BE->getBlockDecl()->hasCaptures())
     return;
 
@@ -82,7 +78,7 @@
     if (state->getSVal(VR).isUndef())
       if (ExplodedNode *N = C.generateSink()) {
         if (!BT)
-          BT = new BuiltinBug("uninitialized variable captured by block");
+          BT.reset(new BuiltinBug("uninitialized variable captured by block"));
 
         // Generate a bug report.
         llvm::SmallString<128> buf;
@@ -100,3 +96,7 @@
       }
   }
 }
+
+void ento::registerUndefCapturedBlockVarChecker(CheckerManager &mgr) {
+  mgr.registerChecker<UndefCapturedBlockVarChecker>();
+}