aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorMichael Spencer <bigcheesegs@gmail.com>2024-03-08 23:30:33 -0800
committerGitHub <noreply@github.com>2024-03-08 23:30:33 -0800
commitba13fa2a5d57581bff1a7e9322234af30f4882f6 (patch)
tree9664647feae1b24a0519bf6ff0143c71b2badd2f /clang-tools-extra
parentabbf1f18825440338f6e08c94c54d8c8b4fe57d4 (diff)
downloadllvm-ba13fa2a5d57581bff1a7e9322234af30f4882f6.zip
llvm-ba13fa2a5d57581bff1a7e9322234af30f4882f6.tar.gz
llvm-ba13fa2a5d57581bff1a7e9322234af30f4882f6.tar.bz2
[llvm][Support] Add and use errnoAsErrorCode (#84423)
LLVM is inconsistent about how it converts `errno` to `std::error_code`. This can cause problems because values outside of `std::errc` compare differently if one is system and one is generic on POSIX systems. This is even more of a problem on Windows where use of the system category is just wrong, as that is for Windows errors, which have a completely different mapping than POSIX/generic errors. This patch fixes one instance of this mistake in `JSONTransport.cpp`. This patch adds `errnoAsErrorCode()` which makes it so people do not need to think about this issue in the future. It also cleans up a lot of usage of `errno` in LLVM and Clang.
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clangd/JSONTransport.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/JSONTransport.cpp b/clang-tools-extra/clangd/JSONTransport.cpp
index 346c7df..3c0e198 100644
--- a/clang-tools-extra/clangd/JSONTransport.cpp
+++ b/clang-tools-extra/clangd/JSONTransport.cpp
@@ -107,8 +107,7 @@ public:
return error(std::make_error_code(std::errc::operation_canceled),
"Got signal, shutting down");
if (ferror(In))
- return llvm::errorCodeToError(
- std::error_code(errno, std::system_category()));
+ return llvm::errorCodeToError(llvm::errnoAsErrorCode());
if (readRawMessage(JSON)) {
ThreadCrashReporter ScopedReporter([&JSON]() {
auto &OS = llvm::errs();