Fix the build bot break introduced by r320791.
[llvm-core.git] / tools / llvm-objcopy / llvm-objcopy.h
blob6732e410d8e05fd5c7dcaf05c6d1d78b89513677
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 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H
11 #define LLVM_TOOLS_OBJCOPY_OBJCOPY_H
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/Support/Compiler.h"
15 #include "llvm/Support/Error.h"
16 #include "llvm/Support/raw_ostream.h"
17 #include <string>
19 namespace llvm {
21 LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message);
23 // This is taken from llvm-readobj.
24 // [see here](llvm/tools/llvm-readobj/llvm-readobj.h:38)
25 template <class T> T unwrapOrError(Expected<T> EO) {
26 if (EO)
27 return *EO;
28 std::string Buf;
29 raw_string_ostream OS(Buf);
30 logAllUnhandledErrors(EO.takeError(), OS, "");
31 OS.flush();
32 error(Buf);
35 } // end namespace llvm
37 #endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H