]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-objcopy/llvm-objcopy.h
MFV r316893:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-objcopy / llvm-objcopy.h
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
10 #ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H
11 #define LLVM_TOOLS_OBJCOPY_OBJCOPY_H
12
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>
18
19 namespace llvm {
20
21 LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message);
22
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);
33 }
34
35 } // end namespace llvm
36
37 #endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H