[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
Tue Dec 19 12:53:44 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE321106: [clangd] Don't use the optional "severity" when comparing Diagnostic. (authored by hokein, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D41280?vs=127586&id=127595#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D41280
Files:
clangd/ClangdLSPServer.h
clangd/Protocol.h
Index: clangd/Protocol.h
===================================================================
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -322,14 +322,15 @@
/// 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);
+};
+/// 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
+struct LSPDiagnosticCompare {
+ bool operator()(const Diagnostic& LHS, const Diagnostic& RHS) const {
+ return std::tie(LHS.range, LHS.message) < std::tie(RHS.range, RHS.message);
}
};
bool fromJSON(const json::Expr &, Diagnostic &);
Index: clangd/ClangdLSPServer.h
===================================================================
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -88,7 +88,8 @@
bool IsDone = false;
std::mutex FixItsMutex;
- typedef std::map<clangd::Diagnostic, std::vector<TextEdit>>
+ typedef std::map<clangd::Diagnostic, std::vector<TextEdit>,
+ LSPDiagnosticCompare>
DiagnosticToReplacementMap;
/// Caches FixIts per file and diagnostics
llvm::StringMap<DiagnosticToReplacementMap> FixItsMap;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41280.127595.patch
Type: text/x-patch
Size: 1658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171219/e83de241/attachment.bin>
More information about the cfe-commits
mailing list