1 //===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This defines a new error_category for the Object library.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Object/Error.h"
15 #include "llvm/Support/ErrorHandling.h"
18 using namespace object;
21 class _object_error_category : public std::error_category {
23 const char* name() const LLVM_NOEXCEPT override;
24 std::string message(int ev) const override;
28 const char *_object_error_category::name() const LLVM_NOEXCEPT {
32 std::string _object_error_category::message(int EV) const {
33 object_error E = static_cast<object_error>(EV);
35 case object_error::success: return "Success";
36 case object_error::arch_not_found:
37 return "No object file for requested architecture";
38 case object_error::invalid_file_type:
39 return "The file was not recognized as a valid object file";
40 case object_error::parse_failed:
41 return "Invalid data was encountered while parsing the file";
42 case object_error::unexpected_eof:
43 return "The end of the file was unexpectedly encountered";
45 llvm_unreachable("An enumerator of object_error does not have a message "
49 const std::error_category &object::object_category() {
50 static _object_error_category o;