LLVM  10.0.0svn
OrcError.cpp
Go to the documentation of this file.
1 //===---------------- OrcError.cpp - Error codes for ORC ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Error codes for ORC.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 
17 using namespace llvm;
18 using namespace llvm::orc;
19 
20 namespace {
21 
22 // FIXME: This class is only here to support the transition to llvm::Error. It
23 // will be removed once this transition is complete. Clients should prefer to
24 // deal with the Error value directly, rather than converting to error_code.
25 class OrcErrorCategory : public std::error_category {
26 public:
27  const char *name() const noexcept override { return "orc"; }
28 
29  std::string message(int condition) const override {
30  switch (static_cast<OrcErrorCode>(condition)) {
32  return "Unknown ORC error";
34  return "Duplicate symbol definition";
36  return "JIT symbol not found";
38  return "Remote allocator does not exist";
40  return "Remote allocator Id already in use";
42  return "Remote mprotect call references unallocated memory";
44  return "Remote indirect stubs owner does not exist";
46  return "Remote indirect stubs owner Id already in use";
48  return "RPC connection closed";
50  return "Could not negotiate RPC function";
52  return "RPC response abandoned";
54  return "Unexpected RPC call";
56  return "Unexpected RPC response";
58  return "Unknown error returned from remote RPC function "
59  "(Use StringError to get error message)";
61  return "Unknown resource handle";
62  }
63  llvm_unreachable("Unhandled error code");
64  }
65 };
66 
67 static ManagedStatic<OrcErrorCategory> OrcErrCat;
68 }
69 
70 namespace llvm {
71 namespace orc {
72 
74 char JITSymbolNotFound::ID = 0;
75 
76 std::error_code orcError(OrcErrorCode ErrCode) {
77  typedef std::underlying_type<OrcErrorCode>::type UT;
78  return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
79 }
80 
81 
83  : SymbolName(std::move(SymbolName)) {}
84 
85 std::error_code DuplicateDefinition::convertToErrorCode() const {
87 }
88 
90  OS << "Duplicate definition of symbol '" << SymbolName << "'";
91 }
92 
93 const std::string &DuplicateDefinition::getSymbolName() const {
94  return SymbolName;
95 }
96 
97 JITSymbolNotFound::JITSymbolNotFound(std::string SymbolName)
98  : SymbolName(std::move(SymbolName)) {}
99 
100 std::error_code JITSymbolNotFound::convertToErrorCode() const {
101  typedef std::underlying_type<OrcErrorCode>::type UT;
102  return std::error_code(static_cast<UT>(OrcErrorCode::JITSymbolNotFound),
103  *OrcErrCat);
104 }
105 
107  OS << "Could not find symbol '" << SymbolName << "'";
108 }
109 
110 const std::string &JITSymbolNotFound::getSymbolName() const {
111  return SymbolName;
112 }
113 
114 }
115 }
DuplicateDefinition(std::string SymbolName)
Definition: OrcError.cpp:82
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const std::string & getSymbolName() const
Definition: OrcError.cpp:110
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:89
Definition: BitVector.h:937
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
std::error_code orcError(OrcErrorCode ErrCode)
Definition: OrcError.cpp:76
const std::string & getSymbolName() const
Definition: OrcError.cpp:93
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:85
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:106
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:22
JITSymbolNotFound(std::string SymbolName)
Definition: OrcError.cpp:97
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:100
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:45
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83