diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-10-26 16:02:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-10-26 16:02:36 +0000 |
commit | 808102685b2f82b07a98912993e74cc97d99f926 (patch) | |
tree | f9565e88f2f760323ad3b80847577ba9e72fadb5 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | 3c7380bfba0c184e21241133a5a401c1df496ab7 (diff) | |
download | bcm5719-llvm-808102685b2f82b07a98912993e74cc97d99f926.tar.gz bcm5719-llvm-808102685b2f82b07a98912993e74cc97d99f926.zip |
Add comments for RemoveRedundantMsgs, rename it to removeRedundantMsgs() per Jordan's feedback.
llvm-svn: 166778
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index ed919882588..2bf701bb9c3 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -138,20 +138,29 @@ eventsDescribeSameCondition(PathDiagnosticEventPiece *X, return 0; } -static void RemoveRedundantMsgs(PathPieces &path) { +/// An optimization pass over PathPieces that removes redundant diagnostics +/// generated by both ConditionBRVisitor and TrackConstraintBRVisitor. Both +/// BugReporterVisitors use different methods to generate diagnostics, with +/// one capable of emitting diagnostics in some cases but not in others. This +/// can lead to redundant diagnostic pieces at the same point in a path. +static void removeRedundantMsgs(PathPieces &path) { unsigned N = path.size(); if (N < 2) return; + // NOTE: this loop intentionally is not using an iterator. Instead, we + // are streaming the path and modifying it in place. This is done by + // grabbing the front, processing it, and if we decide to keep it append + // it to the end of the path. The entire path is processed in this way. for (unsigned i = 0; i < N; ++i) { IntrusiveRefCntPtr<PathDiagnosticPiece> piece(path.front()); path.pop_front(); switch (piece->getKind()) { case clang::ento::PathDiagnosticPiece::Call: - RemoveRedundantMsgs(cast<PathDiagnosticCallPiece>(piece)->path); + removeRedundantMsgs(cast<PathDiagnosticCallPiece>(piece)->path); break; case clang::ento::PathDiagnosticPiece::Macro: - RemoveRedundantMsgs(cast<PathDiagnosticMacroPiece>(piece)->subPieces); + removeRedundantMsgs(cast<PathDiagnosticMacroPiece>(piece)->subPieces); break; case clang::ento::PathDiagnosticPiece::ControlFlow: break; @@ -2080,7 +2089,7 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD, // Finally, prune the diagnostic path of uninteresting stuff. if (!PD.path.empty()) { // Remove messages that are basically the same. - RemoveRedundantMsgs(PD.getMutablePieces()); + removeRedundantMsgs(PD.getMutablePieces()); if (R->shouldPrunePath()) { bool hasSomethingInteresting = RemoveUneededCalls(PD.getMutablePieces(), |