@@ -68,6 +68,7 @@ class HTMLDiagnostics : public PathDiagnosticConsumer {
68
68
bool noDir = false ;
69
69
const Preprocessor &PP;
70
70
const bool SupportsCrossFileDiagnostics;
71
+ llvm::StringSet<> EmittedHashes;
71
72
72
73
public:
73
74
HTMLDiagnostics (PathDiagnosticConsumerOptions DiagOpts,
@@ -301,6 +302,17 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
301
302
}
302
303
}
303
304
305
+ SmallString<32 > IssueHash = getIssueHash (D, PP);
306
+ auto [It, IsNew] = EmittedHashes.insert (IssueHash);
307
+ if (!IsNew) {
308
+ // We've already emitted a duplicate issue. It'll get overwritten anyway.
309
+ return ;
310
+ }
311
+
312
+ // FIXME: This causes each file to be re-parsed and syntax-highlighted
313
+ // and macro-expanded separately for each report. We could cache such rewrites
314
+ // across all reports and only re-do the part that's actually different:
315
+ // the warning/note bubbles.
304
316
std::string report = GenerateHTML (D, R, SMgr, path, declName.c_str ());
305
317
if (report.empty ()) {
306
318
llvm::errs () << " warning: no diagnostics generated for main file.\n " ;
@@ -332,7 +344,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
332
344
<< declName.c_str () << " -" << offsetDecl << " -" ;
333
345
}
334
346
335
- FileName << StringRef (getIssueHash (D, PP) ).substr (0 , 6 ).str () << " .html" ;
347
+ FileName << StringRef (IssueHash ).substr (0 , 6 ).str () << " .html" ;
336
348
337
349
SmallString<128 > ResultPath;
338
350
llvm::sys::path::append (ResultPath, Directory, FileName.str ());
0 commit comments