[lit] Add argument check: --timeout must be non-negative integer
[llvm-core.git] / tools / llvm-objcopy / llvm-objcopy.h
blob18a789ca1f83bbe030fd05953366d43f79ab1dae
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H
10 #define LLVM_TOOLS_OBJCOPY_OBJCOPY_H
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>
18 namespace llvm {
19 namespace objcopy {
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);
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);
39 } // end namespace objcopy
40 } // end namespace llvm
42 #endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H