Deleted Added
full compact
Error.cpp (276479) Error.cpp (280031)
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"
15#include "llvm/Support/ErrorHandling.h"
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"
15#include "llvm/Support/ErrorHandling.h"
16#include "llvm/Support/ManagedStatic.h"
16
17using namespace llvm;
18using namespace object;
19
20namespace {
21class _object_error_category : public std::error_category {
22public:
23 const char* name() const LLVM_NOEXCEPT override;
24 std::string message(int ev) const override;
25};
26}
27
17
18using namespace llvm;
19using namespace object;
20
21namespace {
22class _object_error_category : public std::error_category {
23public:
24 const char* name() const LLVM_NOEXCEPT override;
25 std::string message(int ev) const override;
26};
27}
28
28const char *_object_error_category::name() const {
29const char *_object_error_category::name() const LLVM_NOEXCEPT {
29 return "llvm.object";
30}
31
32std::string _object_error_category::message(int EV) const {
33 object_error E = static_cast<object_error>(EV);
34 switch (E) {
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";
30 return "llvm.object";
31}
32
33std::string _object_error_category::message(int EV) const {
34 object_error E = static_cast<object_error>(EV);
35 switch (E) {
36 case object_error::success: return "Success";
37 case object_error::arch_not_found:
38 return "No object file for requested architecture";
39 case object_error::invalid_file_type:
40 return "The file was not recognized as a valid object file";
41 case object_error::parse_failed:
42 return "Invalid data was encountered while parsing the file";
43 case object_error::unexpected_eof:
44 return "The end of the file was unexpectedly encountered";
45 case object_error::bitcode_section_not_found:
46 return "Bitcode section not found in object file";
44 }
45 llvm_unreachable("An enumerator of object_error does not have a message "
46 "defined.");
47}
48
47 }
48 llvm_unreachable("An enumerator of object_error does not have a message "
49 "defined.");
50}
51
52static ManagedStatic<_object_error_category> error_category;
53
49const std::error_category &object::object_category() {
54const std::error_category &object::object_category() {
50 static _object_error_category o;
51 return o;
55 return *error_category;
52}
56}