LLVM  3.7.0
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"
17 
18 using namespace llvm;
19 using namespace object;
20 
21 namespace {
22 class _object_error_category : public std::error_category {
23 public:
24  const char* name() const LLVM_NOEXCEPT override;
25  std::string message(int ev) const override;
26 };
27 }
28 
29 const char *_object_error_category::name() const LLVM_NOEXCEPT {
30  return "llvm.object";
31 }
32 
33 std::string _object_error_category::message(int EV) const {
34  object_error E = static_cast<object_error>(EV);
35  switch (E) {
37  return "No object file for requested architecture";
39  return "The file was not recognized as a valid object file";
41  return "Invalid data was encountered while parsing the file";
43  return "The end of the file was unexpectedly encountered";
45  return "String table must end with a null terminator";
47  return "Invalid section index";
49  return "Bitcode section not found in object file";
51  return "Mach-O load command with size < 8 bytes";
53  return "Mach-O segment load command contains too many sections";
55  return "Mach-O segment load command size is too small";
56  }
57  llvm_unreachable("An enumerator of object_error does not have a message "
58  "defined.");
59 }
60 
62 
64  return *error_category;
65 }
const std::error_category & object_category()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
#define LLVM_NOEXCEPT
Definition: Compiler.h:70
static ManagedStatic< _object_error_category > error_category
aarch64 promote const
static const char * name
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61