From 0373c768c56fc7ce6fe1efa48383f7b376e7bc2a Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Sat, 19 Sep 2020 18:53:44 +0300 Subject: [llvm-objcopy][NFC] refactor error handling. part 3. Remove usages of special error reporting functions(error(), reportError()). Errors are reported as Expected<>/Error returning values. This part is for ELF subfolder of llvm-objcopy. Testing: check-all. Differential Revision: https://reviews.llvm.org/D87987 --- llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp') diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index ee882ff..175f292 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm-objcopy.h" #include "Buffer.h" #include "COFF/COFFObjcopy.h" #include "CopyConfig.h" @@ -57,36 +56,6 @@ namespace objcopy { // The name this program was invoked as. StringRef ToolName; -LLVM_ATTRIBUTE_NORETURN void error(Twine Message) { - WithColor::error(errs(), ToolName) << Message << "\n"; - exit(1); -} - -LLVM_ATTRIBUTE_NORETURN void error(Error E) { - assert(E); - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(std::move(E), OS); - OS.flush(); - WithColor::error(errs(), ToolName) << Buf; - exit(1); -} - -LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) { - assert(EC); - error(createFileError(File, EC)); -} - -LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) { - assert(E); - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(std::move(E), OS); - OS.flush(); - WithColor::error(errs(), ToolName) << "'" << File << "': " << Buf; - exit(1); -} - ErrorSuccess reportWarning(Error E) { assert(E); WithColor::warning(errs(), ToolName) << toString(std::move(E)) << '\n'; -- cgit v1.1