[cfe-commits] r166778 - /cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Fri Oct 26 09:02:36 PDT 2012
Author: kremenek
Date: Fri Oct 26 11:02:36 2012
New Revision: 166778
URL: http://llvm.org/viewvc/llvm-project?rev=166778&view=rev
Log:
Add comments for RemoveRedundantMsgs, rename it to removeRedundantMsgs() per Jordan's feedback.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=166778&r1=166777&r2=166778&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Oct 26 11:02:36 2012
@@ -138,20 +138,29 @@
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 @@
// 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(),
More information about the cfe-commits
mailing list