summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 738ad9a062f..6627633f393 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -154,8 +154,6 @@ static void removeRedundantMsgs(PathPieces &path) {
case PathDiagnosticPiece::Macro:
removeRedundantMsgs(cast<PathDiagnosticMacroPiece>(*piece).subPieces);
break;
- case PathDiagnosticPiece::ControlFlow:
- break;
case PathDiagnosticPiece::Event: {
if (i == N-1)
break;
@@ -175,7 +173,9 @@ static void removeRedundantMsgs(PathPieces &path) {
}
break;
}
+ case PathDiagnosticPiece::ControlFlow:
case PathDiagnosticPiece::Note:
+ case PathDiagnosticPiece::PopUp:
break;
}
path.push_back(std::move(piece));
@@ -230,9 +230,8 @@ static bool removeUnneededCalls(PathPieces &pieces, BugReport *R,
break;
}
case PathDiagnosticPiece::ControlFlow:
- break;
-
case PathDiagnosticPiece::Note:
+ case PathDiagnosticPiece::PopUp:
break;
}
@@ -242,6 +241,16 @@ static bool removeUnneededCalls(PathPieces &pieces, BugReport *R,
return containsSomethingInteresting;
}
+/// Same logic as above to remove extra pieces.
+static void removePopUpNotes(PathPieces &Path) {
+ for (unsigned int i = 0; i < Path.size(); ++i) {
+ auto Piece = std::move(Path.front());
+ Path.pop_front();
+ if (!isa<PathDiagnosticPopUpPiece>(*Piece))
+ Path.push_back(std::move(Piece));
+ }
+}
+
/// Returns true if the given decl has been implicitly given a body, either by
/// the analyzer or by the compiler proper.
static bool hasImplicitBody(const Decl *D) {
@@ -1981,6 +1990,10 @@ static std::unique_ptr<PathDiagnostic> generatePathDiagnosticForConsumer(
(void)stillHasNotes;
}
+ // Remove pop-up notes if needed.
+ if (!Opts.ShouldAddPopUpNotes)
+ removePopUpNotes(PD->getMutablePieces());
+
// Redirect all call pieces to have valid locations.
adjustCallLocations(PD->getMutablePieces());
removePiecesWithInvalidLocations(PD->getMutablePieces());
OpenPOWER on IntegriCloud