LCOV - code coverage report
Current view: top level - lib/ExecutionEngine/Orc - OrcError.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 13 41 31.7 %
Date: 2018-06-17 00:07:59 Functions: 5 13 38.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      14             : #include "llvm/ExecutionEngine/Orc/OrcError.h"
      15             : #include "llvm/Support/ErrorHandling.h"
      16             : #include "llvm/Support/ManagedStatic.h"
      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           5 : class OrcErrorCategory : public std::error_category {
      27             : public:
      28           0 :   const char *name() const noexcept override { return "orc"; }
      29             : 
      30           0 :   std::string message(int condition) const override {
      31           0 :     switch (static_cast<OrcErrorCode>(condition)) {
      32             :     case OrcErrorCode::UnknownORCError:
      33           0 :       return "Unknown ORC error";
      34             :     case OrcErrorCode::DuplicateDefinition:
      35           0 :       return "Duplicate symbol definition";
      36             :     case OrcErrorCode::JITSymbolNotFound:
      37           0 :       return "JIT symbol not found";
      38             :     case OrcErrorCode::RemoteAllocatorDoesNotExist:
      39           0 :       return "Remote allocator does not exist";
      40             :     case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
      41           0 :       return "Remote allocator Id already in use";
      42             :     case OrcErrorCode::RemoteMProtectAddrUnrecognized:
      43           0 :       return "Remote mprotect call references unallocated memory";
      44             :     case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
      45           0 :       return "Remote indirect stubs owner does not exist";
      46             :     case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
      47           0 :       return "Remote indirect stubs owner Id already in use";
      48             :     case OrcErrorCode::RPCConnectionClosed:
      49           0 :       return "RPC connection closed";
      50             :     case OrcErrorCode::RPCCouldNotNegotiateFunction:
      51           0 :       return "Could not negotiate RPC function";
      52             :     case OrcErrorCode::RPCResponseAbandoned:
      53           0 :       return "RPC response abandoned";
      54             :     case OrcErrorCode::UnexpectedRPCCall:
      55           0 :       return "Unexpected RPC call";
      56             :     case OrcErrorCode::UnexpectedRPCResponse:
      57           0 :       return "Unexpected RPC response";
      58             :     case OrcErrorCode::UnknownErrorCodeFromRemote:
      59             :       return "Unknown error returned from remote RPC function "
      60           0 :              "(Use StringError to get error message)";
      61             :     case OrcErrorCode::UnknownResourceHandle:
      62           0 :       return "Unknown resource handle";
      63             :     }
      64           0 :     llvm_unreachable("Unhandled error code");
      65             :   }
      66             : };
      67             : 
      68             : static ManagedStatic<OrcErrorCategory> OrcErrCat;
      69             : }
      70             : 
      71             : namespace llvm {
      72             : namespace orc {
      73             : 
      74             : char DuplicateDefinition::ID = 0;
      75             : char JITSymbolNotFound::ID = 0;
      76             : 
      77           7 : std::error_code orcError(OrcErrorCode ErrCode) {
      78             :   typedef std::underlying_type<OrcErrorCode>::type UT;
      79           7 :   return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
      80             : }
      81             : 
      82             : 
      83           1 : DuplicateDefinition::DuplicateDefinition(std::string SymbolName)
      84           2 :   : SymbolName(std::move(SymbolName)) {}
      85             : 
      86           0 : std::error_code DuplicateDefinition::convertToErrorCode() const {
      87           0 :   return orcError(OrcErrorCode::DuplicateDefinition);
      88             : }
      89             : 
      90           0 : void DuplicateDefinition::log(raw_ostream &OS) const {
      91           0 :   OS << "Duplicate definition of symbol '" << SymbolName << "'";
      92           0 : }
      93             : 
      94           0 : const std::string &DuplicateDefinition::getSymbolName() const {
      95           0 :   return SymbolName;
      96             : }
      97             : 
      98           2 : JITSymbolNotFound::JITSymbolNotFound(std::string SymbolName)
      99           4 :   : SymbolName(std::move(SymbolName)) {}
     100             : 
     101           2 : std::error_code JITSymbolNotFound::convertToErrorCode() const {
     102             :   typedef std::underlying_type<OrcErrorCode>::type UT;
     103           2 :   return std::error_code(static_cast<UT>(OrcErrorCode::JITSymbolNotFound),
     104           4 :                          *OrcErrCat);
     105             : }
     106             : 
     107           4 : void JITSymbolNotFound::log(raw_ostream &OS) const {
     108           8 :   OS << "Could not find symbol '" << SymbolName << "'";
     109           4 : }
     110             : 
     111           0 : const std::string &JITSymbolNotFound::getSymbolName() const {
     112           0 :   return SymbolName;
     113             : }
     114             : 
     115             : }
     116             : }

Generated by: LCOV version 1.13