[InstCombine] Signed saturation patterns
[llvm-core.git] / lib / ExecutionEngine / Orc / OrcError.cpp
blobe6e9a095319ca5e0c9bd4bd91f543bc74fc5b14e
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.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ExecutionEngine/Orc/OrcError.h"
14 #include "llvm/Support/ErrorHandling.h"
15 #include "llvm/Support/ManagedStatic.h"
17 using namespace llvm;
18 using namespace llvm::orc;
20 namespace {
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"; }
29 std::string message(int condition) const override {
30 switch (static_cast<OrcErrorCode>(condition)) {
31 case OrcErrorCode::UnknownORCError:
32 return "Unknown ORC error";
33 case OrcErrorCode::DuplicateDefinition:
34 return "Duplicate symbol definition";
35 case OrcErrorCode::JITSymbolNotFound:
36 return "JIT symbol not found";
37 case OrcErrorCode::RemoteAllocatorDoesNotExist:
38 return "Remote allocator does not exist";
39 case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
40 return "Remote allocator Id already in use";
41 case OrcErrorCode::RemoteMProtectAddrUnrecognized:
42 return "Remote mprotect call references unallocated memory";
43 case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
44 return "Remote indirect stubs owner does not exist";
45 case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
46 return "Remote indirect stubs owner Id already in use";
47 case OrcErrorCode::RPCConnectionClosed:
48 return "RPC connection closed";
49 case OrcErrorCode::RPCCouldNotNegotiateFunction:
50 return "Could not negotiate RPC function";
51 case OrcErrorCode::RPCResponseAbandoned:
52 return "RPC response abandoned";
53 case OrcErrorCode::UnexpectedRPCCall:
54 return "Unexpected RPC call";
55 case OrcErrorCode::UnexpectedRPCResponse:
56 return "Unexpected RPC response";
57 case OrcErrorCode::UnknownErrorCodeFromRemote:
58 return "Unknown error returned from remote RPC function "
59 "(Use StringError to get error message)";
60 case OrcErrorCode::UnknownResourceHandle:
61 return "Unknown resource handle";
63 llvm_unreachable("Unhandled error code");
67 static ManagedStatic<OrcErrorCategory> OrcErrCat;
70 namespace llvm {
71 namespace orc {
73 char DuplicateDefinition::ID = 0;
74 char JITSymbolNotFound::ID = 0;
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);
82 DuplicateDefinition::DuplicateDefinition(std::string SymbolName)
83 : SymbolName(std::move(SymbolName)) {}
85 std::error_code DuplicateDefinition::convertToErrorCode() const {
86 return orcError(OrcErrorCode::DuplicateDefinition);
89 void DuplicateDefinition::log(raw_ostream &OS) const {
90 OS << "Duplicate definition of symbol '" << SymbolName << "'";
93 const std::string &DuplicateDefinition::getSymbolName() const {
94 return SymbolName;
97 JITSymbolNotFound::JITSymbolNotFound(std::string SymbolName)
98 : SymbolName(std::move(SymbolName)) {}
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);
106 void JITSymbolNotFound::log(raw_ostream &OS) const {
107 OS << "Could not find symbol '" << SymbolName << "'";
110 const std::string &JITSymbolNotFound::getSymbolName() const {
111 return SymbolName;