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 &);
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 &);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits