[PATCH] D63316: [clangd] Include the diagnostics's code when comparing diagnostics

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 22:55:38 PDT 2019


nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

This fixes https://github.com/clangd/clangd/issues/60


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63316

Files:
  clang-tools-extra/clangd/Protocol.h


Index: clang-tools-extra/clangd/Protocol.h
===================================================================
--- clang-tools-extra/clangd/Protocol.h
+++ 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 &);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63316.204702.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190614/e5508c27/attachment.bin>


More information about the cfe-commits mailing list