LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Object/Error.cpp
Go to the documentation of this file.
1 //===- Error.cpp - system_error extensions for Object -----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This defines a new error_category for the Object library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/Object/Error.h"
16 
17 using namespace llvm;
18 using namespace object;
19 
20 namespace {
21 class _object_error_category : public _do_message {
22 public:
23  virtual const char* name() const;
24  virtual std::string message(int ev) const;
25  virtual error_condition default_error_condition(int ev) const;
26 };
27 }
28 
29 const char *_object_error_category::name() const {
30  return "llvm.object";
31 }
32 
33 std::string _object_error_category::message(int ev) const {
34  object_error::Impl E = static_cast<object_error::Impl>(ev);
35  switch (E) {
36  case object_error::success: return "Success";
38  return "No object file for requested architecture";
40  return "The file was not recognized as a valid object file";
42  return "Invalid data was encountered while parsing the file";
44  return "The end of the file was unexpectedly encountered";
45  }
46  llvm_unreachable("An enumerator of object_error does not have a message "
47  "defined.");
48 }
49 
50 error_condition _object_error_category::default_error_condition(int ev) const {
51  if (ev == object_error::success)
52  return errc::success;
54 }
55 
57  static _object_error_category o;
58  return o;
59 }
#define llvm_unreachable(msg)
const error_category & object_category()