blob: de7bf367ac87b46293bb51eeed07c4985c481cf5 [file] [log] [blame]
Petr Hosek05a04cb2017-08-01 00:33:58 +00001//===- 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#ifndef LLVM_OBJCOPY_H
10#define LLVM_OBJCOPY_H
11
12#include "llvm/ADT/Twine.h"
13#include "llvm/Support/Error.h"
14
15namespace llvm {
16
Zachary Turner41a9ee92017-10-11 23:54:34 +000017LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message);
Petr Hosek05a04cb2017-08-01 00:33:58 +000018
19// This is taken from llvm-readobj.
20// [see here](llvm/tools/llvm-readobj/llvm-readobj.h:38)
21template <class T> T unwrapOrError(Expected<T> EO) {
22 if (EO)
23 return *EO;
24 std::string Buf;
25 raw_string_ostream OS(Buf);
26 logAllUnhandledErrors(EO.takeError(), OS, "");
27 OS.flush();
28 error(Buf);
29}
30}
31
32#endif