]> granicus.if.org Git - clang/commitdiff
Added simple hack to reduce redundant warnings from the checker:
authorTed Kremenek <kremenek@apple.com>
Thu, 28 Feb 2008 20:38:16 +0000 (20:38 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 28 Feb 2008 20:38:16 +0000 (20:38 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47727 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRSimpleVals.cpp

index 8b5e3c85a97fd6d5efec3a8b9d24d212cb627b4c..366ffb70c6636faa5f28d8bc49ffa3448b41fcfc 100644 (file)
@@ -32,6 +32,8 @@ static void EmitWarning(Diagnostic& Diag, SourceManager& SrcMgr,
   
   bool isFirst = true;
   unsigned ErrorDiag;
+  llvm::SmallPtrSet<void*,10> CachedErrors;
+  
   
   for (; I != E; ++I) {
   
@@ -39,6 +41,18 @@ static void EmitWarning(Diagnostic& Diag, SourceManager& SrcMgr,
       isFirst = false;    
       ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, msg);
     }
+    else {
+      
+      // HACK: 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.
+      void* p = (*I)->getLocation().getRawData();
+
+      if (CachedErrors.count(p))
+        continue;
+      
+      CachedErrors.insert(p);
+    }
   
     const PostStmt& L = cast<PostStmt>((*I)->getLocation());
     Expr* Exp = cast<Expr>(L.getStmt());