[all-commits] [llvm/llvm-project] ba13fa: [llvm][Support] Add and use errnoAsErrorCode (#84423)

Michael Spencer via All-commits all-commits at lists.llvm.org
Fri Mar 8 23:30:54 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ba13fa2a5d57581bff1a7e9322234af30f4882f6
      https://github.com/llvm/llvm-project/commit/ba13fa2a5d57581bff1a7e9322234af30f4882f6
  Author: Michael Spencer <bigcheesegs at gmail.com>
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
    M clang-tools-extra/clangd/JSONTransport.cpp
    M clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
    M llvm/include/llvm/Support/Error.h
    M llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
    M llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
    M llvm/lib/Object/ArchiveWriter.cpp
    M llvm/lib/Support/AutoConvert.cpp
    M llvm/lib/Support/LockFileManager.cpp
    M llvm/lib/Support/Path.cpp
    M llvm/lib/Support/RandomNumberGenerator.cpp
    M llvm/lib/Support/Unix/Memory.inc
    M llvm/lib/Support/Unix/Path.inc
    M llvm/lib/Support/Unix/Process.inc
    M llvm/lib/Support/Windows/Process.inc
    M llvm/lib/Support/Windows/Program.inc
    M llvm/lib/Support/raw_ostream.cpp
    M llvm/lib/Support/raw_socket_stream.cpp

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list