[PATCH] D41280: [clangd] Don't use the optional "severity" when comparing Diagnostic.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 03:55:00 PST 2017


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: ilya-biryukov, klimek.

We use Diagnostic as a key to find the corresponding FixIt when we do
the "apply-fix", but the "severity" field could be omitted, in some cases,
the codeAction request sent from LSP clients (e.g. VScode) doesn't include the
`severity` field, which makes clangd fail to find the FixIt.

Test the following code in VScode, before the fix, no FixIt shown.

  void main() {}
  ^~~~


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41280

Files:
  clangd/Protocol.h


Index: clangd/Protocol.h
===================================================================
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -323,13 +323,8 @@
   /// The diagnostic's message.
   std::string message;
 
-  friend bool operator==(const Diagnostic &LHS, const Diagnostic &RHS) {
-    return std::tie(LHS.range, LHS.severity, LHS.message) ==
-           std::tie(RHS.range, RHS.severity, RHS.message);
-  }
   friend bool operator<(const Diagnostic &LHS, const Diagnostic &RHS) {
-    return std::tie(LHS.range, LHS.severity, LHS.message) <
-           std::tie(RHS.range, RHS.severity, RHS.message);
+    return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message);
   }
 };
 bool fromJSON(const json::Expr &, Diagnostic &);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41280.127095.patch
Type: text/x-patch
Size: 752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171215/6a035922/attachment.bin>


More information about the cfe-commits mailing list