LLVM  4.0.0
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 "Remote allocator does not exist";
35  return "Remote allocator Id already in use";
37  return "Remote mprotect call references unallocated memory";
39  return "Remote indirect stubs owner does not exist";
41  return "Remote indirect stubs owner Id already in use";
43  return "RPC response abandoned";
45  return "Unexpected RPC call";
47  return "Unexpected RPC response";
49  return "Unknown RPC function";
50  }
51  llvm_unreachable("Unhandled error code");
52  }
53 };
54 
55 static ManagedStatic<OrcErrorCategory> OrcErrCat;
56 }
57 
58 namespace llvm {
59 namespace orc {
60 
62  typedef std::underlying_type<OrcErrorCode>::type UT;
63  return errorCodeToError(
64  std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));
65 }
66 }
67 }
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
static ManagedStatic< _object_error_category > error_category
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
OrcErrorCode
Definition: OrcError.h:23
aarch64 promote const
static const char * name
Lightweight error class with error context and mandatory checking.
Error orcError(OrcErrorCode ErrCode)
Definition: OrcError.cpp:61
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:63