Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 1 | //===- llvm-objcopy.h -------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | #ifndef LLVM_OBJCOPY_H |
| 10 | #define LLVM_OBJCOPY_H |
| 11 | |
| 12 | #include "llvm/ADT/Twine.h" |
| 13 | #include "llvm/Support/Error.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | |
Zachary Turner | 41a9ee9 | 2017-10-11 23:54:34 +0000 | [diff] [blame^] | 17 | LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message); |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 18 | |
| 19 | // This is taken from llvm-readobj. |
| 20 | // [see here](llvm/tools/llvm-readobj/llvm-readobj.h:38) |
| 21 | template <class T> T unwrapOrError(Expected<T> EO) { |
| 22 | if (EO) |
| 23 | return *EO; |
| 24 | std::string Buf; |
| 25 | raw_string_ostream OS(Buf); |
| 26 | logAllUnhandledErrors(EO.takeError(), OS, ""); |
| 27 | OS.flush(); |
| 28 | error(Buf); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | #endif |