Generalize caching mechanism for bugs reports.  Now individual BugTypes
can decide the policy on how to cache related bugs.  This allows us to
properly to handle warning about multiple leaks in the same location in the
ref count checker (not yet done).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49918 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index e74295c..e69c5a6 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -357,12 +357,14 @@
   }
 }
 
-bool BugReporter::IsCached(ExplodedNode<ValueState>* N) {
+bool BugTypeCacheLocation::isCached(BugReport& R) {
+  
+  ExplodedNode<ValueState>* N = R.getEndNode();
   
   if (!N)
     return false;
-  
-  // HACK: Cache the location of the error.  Don't emit the same
+
+  // Cache the location of the error.  Don't emit the same
   // warning for the same error type that occurs at the same program
   // location but along a different path.
   
@@ -371,14 +373,13 @@
   if (CachedErrors.count(p))
     return true;
   
-  CachedErrors.insert(p);
-  
+  CachedErrors.insert(p);  
   return false;
 }
 
 void BugReporter::EmitWarning(BugReport& R) {
 
-  if (IsCached(R.getEndNode()))
+  if (R.getBugType().isCached(R))
     return;
 
   PathDiagnostic D(R.getName());