[PATCH] D77947: [clangd] Send the correct error code when cancelling requests.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 13 10:45:12 PDT 2020
sammccall marked an inline comment as done.
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/JSONTransport.cpp:28
+ [&](const CancelledError &C) -> llvm::Error {
+ switch (C.Reason) {
+ case static_cast<int>(ErrorCode::ContentModified):
----------------
kadircet wrote:
> Maybe `static_cast<ErrorCode>(C.Reason)` instead of casting cases.
>
> I know the reason is not necessarily LSP specific, but we seem to be defaulting to `ErrorCode::RequestCancelled` anyways.
Sadly this is UB if the value isn't an element of the enum (or in its range, or something). Whereas casting the cases leaves the code valid for arbitrary integers.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77947/new/
https://reviews.llvm.org/D77947
More information about the cfe-commits
mailing list