Added boilerplate to execute the CF reference count checker (which isn't yet implemented).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47982 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index c5e8e5e..f8fbdc9 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -636,6 +636,43 @@
   }    
 }
 
+
+//===----------------------------------------------------------------------===//
+// Core Foundation Reference Counting Checker
+
+namespace {
+  class CFRefCountCheckerVisitor : public CFGVisitor {
+    Diagnostic &Diags;
+    ASTContext* Ctx;
+    
+  public:
+    CFRefCountCheckerVisitor(Diagnostic &diags, const std::string& fname)
+      : CFGVisitor(fname), Diags(diags) {}
+    
+    virtual void Initialize(ASTContext &Context) { Ctx = &Context; }    
+    virtual void VisitCFG(CFG& C, FunctionDecl&);
+    virtual bool printFuncDeclStart() { return false; }
+  };
+} // end anonymous namespace
+
+
+ASTConsumer* clang::CreateCFRefChecker(Diagnostic &Diags,
+                                       const std::string& FunctionName) {
+  
+  return new CFRefCountCheckerVisitor(Diags, FunctionName);
+}
+
+void CFRefCountCheckerVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
+  
+  SourceLocation Loc = FD.getLocation();
+  
+  if (!Loc.isFileID() ||
+      Loc.getFileID() != Ctx->getSourceManager().getMainFileID())
+    return;
+     
+  CheckCFRefCount(C, FD, *Ctx, Diags);
+}
+
 //===----------------------------------------------------------------------===//
 // AST Serializer