OSDN Git Service

[llvm-readobj] Install llvm-readelf alias
[android-x86/external-llvm.git] / tools / llvm-readobj / llvm-readobj.h
1 //===-- llvm-readobj.h ----------------------------------------------------===//
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_LLVM_READOBJ_LLVM_READOBJ_H
11 #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
12
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Support/Compiler.h"
15 #include "llvm/Support/ErrorOr.h"
16 #include "llvm/Support/Error.h"
17 #include <string>
18
19 namespace llvm {
20   namespace object {
21     class RelocationRef;
22   }
23
24   // Various helper functions.
25   LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
26   void error(std::error_code EC);
27   void error(llvm::Error EC);
28   template <typename T> T error(llvm::Expected<T> &&E) {
29     error(E.takeError());
30     return std::move(*E);
31   }
32
33   template <class T> T unwrapOrError(ErrorOr<T> EO) {
34     if (EO)
35       return *EO;
36     reportError(EO.getError().message());
37   }
38   template <class T> T unwrapOrError(Expected<T> EO) {
39     if (EO)
40       return *EO;
41     std::string Buf;
42     raw_string_ostream OS(Buf);
43     logAllUnhandledErrors(EO.takeError(), OS, "");
44     OS.flush();
45     reportError(Buf);
46   }
47   bool relocAddressLess(object::RelocationRef A,
48                         object::RelocationRef B);
49 } // namespace llvm
50
51 namespace opts {
52   extern llvm::cl::list<std::string> InputFilenames;
53   extern llvm::cl::opt<bool> FileHeaders;
54   extern llvm::cl::opt<bool> Sections;
55   extern llvm::cl::opt<bool> SectionRelocations;
56   extern llvm::cl::opt<bool> SectionSymbols;
57   extern llvm::cl::opt<bool> SectionData;
58   extern llvm::cl::opt<bool> Relocations;
59   extern llvm::cl::opt<bool> Symbols;
60   extern llvm::cl::opt<bool> DynamicSymbols;
61   extern llvm::cl::opt<bool> UnwindInfo;
62   extern llvm::cl::opt<bool> ExpandRelocs;
63   extern llvm::cl::opt<bool> CodeView;
64   extern llvm::cl::opt<bool> CodeViewSubsectionBytes;
65   extern llvm::cl::opt<bool> ARMAttributes;
66   extern llvm::cl::opt<bool> MipsPLTGOT;
67   enum OutputStyleTy { LLVM, GNU };
68   extern llvm::cl::opt<OutputStyleTy> Output;
69 } // namespace opts
70
71 #define LLVM_READOBJ_ENUM_ENT(ns, enum) \
72   { #enum, ns::enum }
73
74 #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
75   { #enum, std::underlying_type<enum_class>::type(enum_class::enum) }
76
77 #endif