]> granicus.if.org Git - clang/commitdiff
Add a new RetainReleaseChecker class (that subclasses CheckerVisitor) to extend the...
authorTed Kremenek <kremenek@apple.com>
Wed, 25 Nov 2009 22:17:44 +0000 (22:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 25 Nov 2009 22:17:44 +0000 (22:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89889 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp

index deff7ccdc964e478b76626af43f3b95d54784bad..10d07762dbf1d86b2cb9d3d51a7682c8fb6f4dfb 100644 (file)
@@ -22,6 +22,7 @@
 #include "clang/Analysis/PathSensitive/BugReporter.h"
 #include "clang/Analysis/PathSensitive/SymbolManager.h"
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/Analysis/PathSensitive/CheckerVisitor.h"
 #include "clang/AST/DeclObjC.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -3633,6 +3634,22 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
   BR->EmitReport(report);
 }
 
+//===----------------------------------------------------------------------===//
+// Pieces of the retain/release checker implemented using a CheckerVisitor.
+// More pieces of the retain/release checker will be migrated to this interface
+// (ideally, all of it some day).
+//===----------------------------------------------------------------------===//
+
+namespace {
+class VISIBILITY_HIDDEN RetainReleaseChecker
+  : public CheckerVisitor<RetainReleaseChecker> {
+  CFRefCount *TF;
+public:
+    RetainReleaseChecker(CFRefCount *tf) : TF(tf) {}
+    static void* getTag() { static int x = 0; return &x; }    
+};
+} // end anonymous namespace
+
 //===----------------------------------------------------------------------===//
 // Transfer function creation for external clients.
 //===----------------------------------------------------------------------===//
@@ -3694,6 +3711,11 @@ void CFRefCount::RegisterChecks(GRExprEngine& Eng) {
   
   // Save the reference to the BugReporter.
   this->BR = &BR;
+  
+  // Register the RetainReleaseChecker with the GRExprEngine object.
+  // Functionality in CFRefCount will be migrated to RetainReleaseChecker
+  // over time.
+  Eng.registerCheck(new RetainReleaseChecker(this));
 }
 
 GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,