File indexing completed on 2026-05-10 08:44:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_OBJECT_ERROR_H
0014 #define LLVM_OBJECT_ERROR_H
0015
0016 #include "llvm/Support/Error.h"
0017 #include <system_error>
0018
0019 namespace llvm {
0020
0021 class Twine;
0022
0023 namespace object {
0024
0025 const std::error_category &object_category();
0026
0027 enum class object_error {
0028
0029 arch_not_found = 1,
0030 invalid_file_type,
0031 parse_failed,
0032 unexpected_eof,
0033 string_table_non_null_end,
0034 invalid_section_index,
0035 bitcode_section_not_found,
0036 invalid_symbol_index,
0037 section_stripped,
0038 };
0039
0040 inline std::error_code make_error_code(object_error e) {
0041 return std::error_code(static_cast<int>(e), object_category());
0042 }
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 class BinaryError : public ErrorInfo<BinaryError, ECError> {
0053 void anchor() override;
0054 public:
0055 static char ID;
0056 BinaryError() {
0057
0058 setErrorCode(make_error_code(object_error::parse_failed));
0059 }
0060 };
0061
0062
0063
0064
0065
0066 class GenericBinaryError : public ErrorInfo<GenericBinaryError, BinaryError> {
0067 public:
0068 static char ID;
0069 GenericBinaryError(const Twine &Msg);
0070 GenericBinaryError(const Twine &Msg, object_error ECOverride);
0071 const std::string &getMessage() const { return Msg; }
0072 void log(raw_ostream &OS) const override;
0073 private:
0074 std::string Msg;
0075 };
0076
0077
0078
0079
0080
0081
0082 Error isNotObjectErrorInvalidFileType(llvm::Error Err);
0083
0084 inline Error createError(const Twine &Err) {
0085 return make_error<StringError>(Err, object_error::parse_failed);
0086 }
0087
0088 }
0089
0090 }
0091
0092 namespace std {
0093 template <>
0094 struct is_error_code_enum<llvm::object::object_error> : std::true_type {};
0095 }
0096
0097 #endif