[llvm-commits] [PATCH] System: Move system_error from KillTheDoctor.

Michael Spencer bigcheesegs at gmail.com
Tue Nov 16 00:25:30 PST 2010


This is the first step in adding sane error handling support to LLVMSystem.

The system API's will be shifted over to returning an error_code, and returning
other return values as out parameters to the function.

Code that needs to check error conditions will use the errc enum values which
are the same as the posix_errno defines (EBADF, E2BIG, etc...), and
are compatable
with the error codes in WinError.h due to some magic in system_error.

An example would be:

if ((error_code ec = KillEvil("Java")) != errc::success) {
  if (ec == kill_error::too_much_evil)
    std::terminate();
  errs() << ":O There was an error! " << ec.message();
}

---
 .../llvm/System}/system_error.h                    |  139 ++++------
 lib/System/CMakeLists.txt                          |    3 +
 lib/System/Unix/system_error.inc                   |   34 +++
 lib/System/Win32/system_error.inc                  |  140 ++++++++++
 lib/System/system_error.cpp                        |  121 ++++++++
 utils/KillTheDoctor/CMakeLists.txt                 |    1 -
 utils/KillTheDoctor/KillTheDoctor.cpp              |    2 +-
 utils/KillTheDoctor/system_error.cpp               |  287 --------------------
 8 files changed, 359 insertions(+), 368 deletions(-)
 rename {utils/KillTheDoctor => include/llvm/System}/system_error.h (88%)
 create mode 100644 lib/System/Unix/system_error.inc
 create mode 100644 lib/System/Win32/system_error.inc
 create mode 100644 lib/System/system_error.cpp
 delete mode 100644 utils/KillTheDoctor/system_error.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-System-Move-system_error-from-KillTheDoctor.patch
Type: text/x-patch
Size: 32355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101116/966e7d5d/attachment.bin>


More information about the llvm-commits mailing list