Mercurial > hg > CbC > CbC_llvm
comparison tools/llvm-objcopy/llvm-objcopy.h @ 171:66f3bfe93da9
git version 2c4ca6832fa6b306ee6a7010bfb80a3f2596f824
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 11:07:02 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
150:1d019706d866 | 171:66f3bfe93da9 |
---|---|
1 //===- llvm-objcopy.h -------------------------------------------*- C++ -*-===// | |
2 // | |
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
4 // See https://llvm.org/LICENSE.txt for license information. | |
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
6 // | |
7 //===----------------------------------------------------------------------===// | |
8 | |
9 #ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H | |
10 #define LLVM_TOOLS_OBJCOPY_OBJCOPY_H | |
11 | |
12 #include "llvm/ADT/Twine.h" | |
13 #include "llvm/Support/Compiler.h" | |
14 #include "llvm/Support/Error.h" | |
15 #include "llvm/Support/raw_ostream.h" | |
16 #include <string> | |
17 | |
18 namespace llvm { | |
19 namespace objcopy { | |
20 | |
21 LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message); | |
22 LLVM_ATTRIBUTE_NORETURN extern void error(Error E); | |
23 LLVM_ATTRIBUTE_NORETURN extern void reportError(StringRef File, Error E); | |
24 LLVM_ATTRIBUTE_NORETURN extern void reportError(StringRef File, | |
25 std::error_code EC); | |
26 | |
27 // This is taken from llvm-readobj. | |
28 // [see here](llvm/tools/llvm-readobj/llvm-readobj.h:38) | |
29 template <class T> T unwrapOrError(Expected<T> EO) { | |
30 if (EO) | |
31 return *EO; | |
32 std::string Buf; | |
33 raw_string_ostream OS(Buf); | |
34 logAllUnhandledErrors(EO.takeError(), OS); | |
35 OS.flush(); | |
36 error(Buf); | |
37 } | |
38 | |
39 } // end namespace objcopy | |
40 } // end namespace llvm | |
41 | |
42 #endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H |