LLVM  7.0.0svn
OrcError.cpp
Go to the documentation of this file.
1 //===---------------- OrcError.cpp - Error codes for ORC ------------------===//
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 // Error codes for ORC.
11 //
12 //===----------------------------------------------------------------------===//
13 
17 
18 using namespace llvm;
19 using namespace llvm::orc;
20 
21 namespace {
22 
23 // FIXME: This class is only here to support the transition to llvm::Error. It
24 // will be removed once this transition is complete. Clients should prefer to
25 // deal with the Error value directly, rather than converting to error_code.
26 class OrcErrorCategory : public std::error_category {
27 public:
28  const char *name() const noexcept override { return "orc"; }
29 
30  std::string message(int condition) const override {
31  switch (static_cast<OrcErrorCode>(condition)) {
33  return "Duplicate symbol definition";
35  return "JIT symbol not found";
37  return "Remote allocator does not exist";
39  return "Remote allocator Id already in use";
41  return "Remote mprotect call references unallocated memory";
43  return "Remote indirect stubs owner does not exist";
45  return "Remote indirect stubs owner Id already in use";
47  return "RPC connection closed";
49  return "Could not negotiate RPC function";
51  return "RPC response abandoned";
53  return "Unexpected RPC call";
55  return "Unexpected RPC response";
57  return "Unknown error returned from remote RPC function "
58  "(Use StringError to get error message)";
60  return "Unknown resource handle";
61  }
62  llvm_unreachable("Unhandled error code");
63  }
64 };
65 
66 static ManagedStatic<OrcErrorCategory> OrcErrCat;
67 }
68 
69 namespace llvm {
70 namespace orc {
71 
73 char JITSymbolNotFound::ID = 0;
74 
75 std::error_code orcError(OrcErrorCode ErrCode) {
76  typedef std::underlying_type<OrcErrorCode>::type UT;
77  return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
78 }
79 
80 
82  : SymbolName(std::move(SymbolName)) {}
83 
84 std::error_code DuplicateDefinition::convertToErrorCode() const {
86 }
87 
89  OS << "Duplicate definition of symbol '" << SymbolName << "'";
90 }
91 
92 const std::string &DuplicateDefinition::getSymbolName() const {
93  return SymbolName;
94 }
95 
96 JITSymbolNotFound::JITSymbolNotFound(std::string SymbolName)
97  : SymbolName(std::move(SymbolName)) {}
98 
99 std::error_code JITSymbolNotFound::convertToErrorCode() const {
100  typedef std::underlying_type<OrcErrorCode>::type UT;
101  return std::error_code(static_cast<UT>(OrcErrorCode::JITSymbolNotFound),
102  *OrcErrCat);
103 }
104 
106  OS << "Could not find symbol '" << SymbolName << "'";
107 }
108 
109 const std::string &JITSymbolNotFound::getSymbolName() const {
110  return SymbolName;
111 }
112 
113 }
114 }
DuplicateDefinition(std::string SymbolName)
Definition: OrcError.cpp:81
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
const std::string & getSymbolName() const
Definition: OrcError.cpp:109
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:88
Definition: BitVector.h:920
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
std::error_code orcError(OrcErrorCode ErrCode)
Definition: OrcError.cpp:75
const std::string & getSymbolName() const
Definition: OrcError.cpp:92
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:84
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:105
static ManagedStatic< _object_error_category > error_category
Definition: Error.cpp:74
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
OrcErrorCode
Definition: OrcError.h:23
JITSymbolNotFound(std::string SymbolName)
Definition: OrcError.cpp:96
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:99
aarch64 promote const
static const char * name
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61