From: Ted Kremenek Date: Thu, 28 Feb 2008 20:38:16 +0000 (+0000) Subject: Added simple hack to reduce redundant warnings from the checker: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c61e7a1fcfc0712cb97f995310fd79877db19b3;p=clang Added simple hack to reduce redundant warnings from the checker: 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 --- diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp index 8b5e3c85a9..366ffb70c6 100644 --- a/Analysis/GRSimpleVals.cpp +++ b/Analysis/GRSimpleVals.cpp @@ -32,6 +32,8 @@ static void EmitWarning(Diagnostic& Diag, SourceManager& SrcMgr, bool isFirst = true; unsigned ErrorDiag; + llvm::SmallPtrSet 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((*I)->getLocation()); Expr* Exp = cast(L.getStmt());