This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Deduplicate clang-tidy diagnostic messages.
ClosedPublic

Authored by hokein on Jul 3 2019, 2:53 AM.

Details

Summary

Clang-tidy checks may emit duplicated messages (clang-tidy tool
deduplicate them in its custom diagnostic consumer), and we may show
multiple duplicated diagnostics in the UI, which is really bad.

This patch makes clangd do the deduplication as well.

Diff Detail

Repository
rL LLVM

Event Timeline

hokein created this revision.Jul 3 2019, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 3 2019, 2:53 AM

Could you also revert changes in LSPDiagnosticCompare in Protocol.h, that were introduced by rL363889? (or bring back fixits-duplication.test)

hokein updated this revision to Diff 207760.Jul 3 2019, 4:57 AM

Revert the LSPDiagnosticCompare change in rL363889.

hokein added a comment.Jul 3 2019, 4:57 AM

Could you also revert changes in LSPDiagnosticCompare in Protocol.h, that were introduced by rL363889? (or bring back fixits-duplication.test)

Done, it looks like we don't need this change as we don't store all diagnostics of clang-tidy alias checks.

sammccall added inline comments.Jul 5 2019, 4:29 AM
clang-tools-extra/clangd/Diagnostics.cpp
427 ↗(On Diff #207760)

This sorting/partitioning seems a bit heavyweight... what about

DenseSet<pair<Range, Message>> SeenDiagnostics;
llvm::erase_if([&](const Diag &D) {
  return !SeenDiagnostics.try_emplace(D.Range, D.Message).second;
});
hokein updated this revision to Diff 208158.Jul 5 2019, 5:22 AM
hokein marked 2 inline comments as done.

Address comment.

clang-tools-extra/clangd/Diagnostics.cpp
427 ↗(On Diff #207760)

This is neat. DenseSet requires a hashvalue function of the value, which we don't have, switched to use set

sammccall accepted this revision.Jul 5 2019, 5:40 AM
sammccall added inline comments.
clang-tools-extra/clangd/Diagnostics.cpp
427 ↗(On Diff #207760)

Can we add one instead? It'd be nice to get rid of the operator< on range, use of set etc.
I can do this is a followup if you prefer.

This revision is now accepted and ready to land.Jul 5 2019, 5:40 AM
hokein marked an inline comment as done.Jul 5 2019, 5:57 AM
hokein added inline comments.
clang-tools-extra/clangd/Diagnostics.cpp
427 ↗(On Diff #207760)

I'd leave it to a follow-up.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2019, 5:59 AM
nridge added a subscriber: nridge.Jul 6 2019, 4:14 PM
clang-tools-extra/trunk/clangd/Protocol.h