diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -597,7 +597,6 @@ }; bool fromJSON(const llvm::json::Value &, DocumentSymbolParams &); - /// Represents a related message and source code location for a diagnostic. /// This should be used to point to code locations that cause or related to a /// diagnostics, e.g when duplicating a symbol in a scope. @@ -647,12 +646,13 @@ /// A LSP-specific comparator used to find diagnostic in a container like /// std:map. -/// We only use the required fields of Diagnostic to do the comparsion to avoid -/// any regression issues from LSP clients (e.g. VScode), see -/// https://git.io/vbr29 +/// We only use as many fields of Diagnostic as is needed to make distinct +/// diagnostics unique in practice, to avoid regression issues from LSP clients +/// (e.g. VScode), see https://git.io/vbr29 struct LSPDiagnosticCompare { bool operator()(const Diagnostic &LHS, const Diagnostic &RHS) const { - return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message); + return std::tie(LHS.code, LHS.range, LHS.message) < + std::tie(RHS.code, RHS.range, RHS.message); } }; bool fromJSON(const llvm::json::Value &, Diagnostic &);