xref: /freebsd/contrib/llvm-project/llvm/include/llvm/TextAPI/TextAPIError.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- llvm/TextAPI/TextAPIError.h - TAPI Error -----------------*- 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 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// \brief Define TAPI specific error codes.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TEXTAPI_TEXTAPIERROR_H
15 #define LLVM_TEXTAPI_TEXTAPIERROR_H
16 
17 #include "llvm/Support/Compiler.h"
18 #include "llvm/Support/Error.h"
19 
20 namespace llvm::MachO {
21 enum class TextAPIErrorCode {
22   NoSuchArchitecture,
23   EmptyResults,
24   GenericFrontendError,
25   InvalidInputFormat,
26   UnsupportedTarget
27 };
28 
29 class LLVM_ABI TextAPIError : public llvm::ErrorInfo<TextAPIError> {
30 public:
31   static char ID;
32   TextAPIErrorCode EC;
33   std::string Msg;
34 
TextAPIError(TextAPIErrorCode EC)35   TextAPIError(TextAPIErrorCode EC) : EC(EC) {}
TextAPIError(TextAPIErrorCode EC,std::string Msg)36   TextAPIError(TextAPIErrorCode EC, std::string Msg)
37       : EC(EC), Msg(std::move(Msg)) {}
38 
39   void log(raw_ostream &OS) const override;
40   std::error_code convertToErrorCode() const override;
41 };
42 
43 } // namespace llvm::MachO
44 #endif // LLVM_TEXTAPI_TEXTAPIERROR_H
45