1249259Sdim//===-- llvm-readobj.h ----------------------------------------------------===//
2249259Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6249259Sdim//
7249259Sdim//===----------------------------------------------------------------------===//
8249259Sdim
9280031Sdim#ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
10280031Sdim#define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
11249259Sdim
12249259Sdim#include "llvm/Support/CommandLine.h"
13296417Sdim#include "llvm/Support/Compiler.h"
14309124Sdim#include "llvm/Support/ErrorOr.h"
15309124Sdim#include "llvm/Support/Error.h"
16249259Sdim#include <string>
17249259Sdim
18249259Sdimnamespace llvm {
19249259Sdim  namespace object {
20249259Sdim    class RelocationRef;
21249259Sdim  }
22249259Sdim
23249259Sdim  // Various helper functions.
24360784Sdim  LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input);
25360784Sdim  void reportWarning(Error Err, StringRef Input);
26321369Sdim
27360784Sdim  template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) {
28309124Sdim    if (EO)
29309124Sdim      return *EO;
30360784Sdim    reportError(EO.takeError(), Input);
31309124Sdim  }
32249259Sdim} // namespace llvm
33249259Sdim
34249259Sdimnamespace opts {
35249259Sdim  extern llvm::cl::opt<bool> SectionRelocations;
36249259Sdim  extern llvm::cl::opt<bool> SectionSymbols;
37249259Sdim  extern llvm::cl::opt<bool> SectionData;
38251662Sdim  extern llvm::cl::opt<bool> ExpandRelocs;
39341825Sdim  extern llvm::cl::opt<bool> RawRelr;
40288943Sdim  extern llvm::cl::opt<bool> CodeViewSubsectionBytes;
41353358Sdim  extern llvm::cl::opt<bool> Demangle;
42309124Sdim  enum OutputStyleTy { LLVM, GNU };
43309124Sdim  extern llvm::cl::opt<OutputStyleTy> Output;
44249259Sdim} // namespace opts
45249259Sdim
46249259Sdim#define LLVM_READOBJ_ENUM_ENT(ns, enum) \
47249259Sdim  { #enum, ns::enum }
48249259Sdim
49309124Sdim#define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
50309124Sdim  { #enum, std::underlying_type<enum_class>::type(enum_class::enum) }
51309124Sdim
52249259Sdim#endif
53