1 //===- Error.cpp - system_error extensions for llvm-readobj -----*- 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 llvm-readobj tool.
12 //===----------------------------------------------------------------------===//
15 #include "llvm/Support/ErrorHandling.h"
20 class _readobj_error_category : public std::error_category {
22 const char* name() const LLVM_NOEXCEPT override;
23 std::string message(int ev) const override;
27 const char *_readobj_error_category::name() const {
28 return "llvm.readobj";
31 std::string _readobj_error_category::message(int EV) const {
32 switch (static_cast<readobj_error>(EV)) {
33 case readobj_error::success: return "Success";
34 case readobj_error::file_not_found:
35 return "No such file.";
36 case readobj_error::unsupported_file_format:
37 return "The file was not recognized as a valid object file.";
38 case readobj_error::unrecognized_file_format:
39 return "Unrecognized file type.";
40 case readobj_error::unsupported_obj_file_format:
41 return "Unsupported object file format.";
42 case readobj_error::unknown_symbol:
43 return "Unknown symbol.";
45 llvm_unreachable("An enumerator of readobj_error does not have a message "
50 const std::error_category &readobj_category() {
51 static _readobj_error_category o;