2017-08-01 02:33:58 +02:00
|
|
|
//===- llvm-objcopy.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-08-01 02:33:58 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-11-01 22:16:06 +01:00
|
|
|
|
|
|
|
#ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H
|
|
|
|
#define LLVM_TOOLS_OBJCOPY_OBJCOPY_H
|
2017-08-01 02:33:58 +02:00
|
|
|
|
|
|
|
#include "llvm/ADT/Twine.h"
|
2017-11-01 22:16:06 +01:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2017-08-01 02:33:58 +02:00
|
|
|
#include "llvm/Support/Error.h"
|
2017-11-01 22:16:06 +01:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <string>
|
2017-08-01 02:33:58 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2018-07-18 02:10:51 +02:00
|
|
|
namespace objcopy {
|
2017-08-01 02:33:58 +02:00
|
|
|
|
2017-10-12 01:54:34 +02:00
|
|
|
LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message);
|
2018-01-25 23:46:17 +01:00
|
|
|
LLVM_ATTRIBUTE_NORETURN extern void reportError(StringRef File, Error E);
|
|
|
|
LLVM_ATTRIBUTE_NORETURN extern void reportError(StringRef File,
|
|
|
|
std::error_code EC);
|
2017-08-01 02:33:58 +02:00
|
|
|
|
|
|
|
// This is taken from llvm-readobj.
|
|
|
|
// [see here](llvm/tools/llvm-readobj/llvm-readobj.h:38)
|
|
|
|
template <class T> T unwrapOrError(Expected<T> EO) {
|
|
|
|
if (EO)
|
|
|
|
return *EO;
|
|
|
|
std::string Buf;
|
|
|
|
raw_string_ostream OS(Buf);
|
2018-11-11 02:46:03 +01:00
|
|
|
logAllUnhandledErrors(EO.takeError(), OS);
|
2017-08-01 02:33:58 +02:00
|
|
|
OS.flush();
|
|
|
|
error(Buf);
|
|
|
|
}
|
|
|
|
|
2018-07-18 02:10:51 +02:00
|
|
|
} // end namespace objcopy
|
2017-11-01 22:16:06 +01:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H
|