aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-01-24 19:17:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-06 20:13:49 +0000
commit7a6dacaca14b62ca4b74406814becb87a3fefac0 (patch)
tree273a870ac27484bb1f5ee55e7ef0dc0d061f63e7 /contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
parent46c59ea9b61755455ff6bf9f3e7b834e1af634ea (diff)
parent4df029cc74e5ec124f14a5682e44999ce4f086df (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 69d25120dcd4..86947b7929e9 100644
--- a/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/contrib/llvm-project/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -68,6 +68,7 @@ class HTMLDiagnostics : public PathDiagnosticConsumer {
bool noDir = false;
const Preprocessor &PP;
const bool SupportsCrossFileDiagnostics;
+ llvm::StringSet<> EmittedHashes;
public:
HTMLDiagnostics(PathDiagnosticConsumerOptions DiagOpts,
@@ -301,6 +302,17 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
}
}
+ SmallString<32> IssueHash = getIssueHash(D, PP);
+ auto [It, IsNew] = EmittedHashes.insert(IssueHash);
+ if (!IsNew) {
+ // We've already emitted a duplicate issue. It'll get overwritten anyway.
+ return;
+ }
+
+ // FIXME: This causes each file to be re-parsed and syntax-highlighted
+ // and macro-expanded separately for each report. We could cache such rewrites
+ // across all reports and only re-do the part that's actually different:
+ // the warning/note bubbles.
std::string report = GenerateHTML(D, R, SMgr, path, declName.c_str());
if (report.empty()) {
llvm::errs() << "warning: no diagnostics generated for main file.\n";
@@ -332,7 +344,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
<< declName.c_str() << "-" << offsetDecl << "-";
}
- FileName << StringRef(getIssueHash(D, PP)).substr(0, 6).str() << ".html";
+ FileName << StringRef(IssueHash).substr(0, 6).str() << ".html";
SmallString<128> ResultPath;
llvm::sys::path::append(ResultPath, Directory, FileName.str());