LCOV - code coverage report
Current view: top level - lib/ExecutionEngine/Orc - OrcError.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 11 30 36.7 %
Date: 2017-09-14 15:23:50 Functions: 4 9 44.4 %
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::RemoteAllocatorDoesNotExist:
      33           0 :       return "Remote allocator does not exist";
      34             :     case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
      35           0 :       return "Remote allocator Id already in use";
      36             :     case OrcErrorCode::RemoteMProtectAddrUnrecognized:
      37           0 :       return "Remote mprotect call references unallocated memory";
      38             :     case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
      39           0 :       return "Remote indirect stubs owner does not exist";
      40             :     case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
      41           0 :       return "Remote indirect stubs owner Id already in use";
      42             :     case OrcErrorCode::RPCConnectionClosed:
      43           0 :       return "RPC connection closed";
      44             :     case OrcErrorCode::RPCCouldNotNegotiateFunction:
      45           0 :       return "Could not negotiate RPC function";
      46             :     case OrcErrorCode::RPCResponseAbandoned:
      47           0 :       return "RPC response abandoned";
      48             :     case OrcErrorCode::JITSymbolNotFound:
      49           0 :       return "JIT symbol not found";
      50             :     case OrcErrorCode::UnexpectedRPCCall:
      51           0 :       return "Unexpected RPC call";
      52             :     case OrcErrorCode::UnexpectedRPCResponse:
      53           0 :       return "Unexpected RPC response";
      54             :     case OrcErrorCode::UnknownErrorCodeFromRemote:
      55             :       return "Unknown error returned from remote RPC function "
      56           0 :              "(Use StringError to get error message)";
      57             :     case OrcErrorCode::UnknownResourceHandle:
      58           0 :       return "Unknown resource handle";
      59             :     }
      60           0 :     llvm_unreachable("Unhandled error code");
      61             :   }
      62             : };
      63             : 
      64             : static ManagedStatic<OrcErrorCategory> OrcErrCat;
      65             : }
      66             : 
      67             : namespace llvm {
      68             : namespace orc {
      69             : 
      70             : char JITSymbolNotFound::ID = 0;
      71             : 
      72           7 : std::error_code orcError(OrcErrorCode ErrCode) {
      73             :   typedef std::underlying_type<OrcErrorCode>::type UT;
      74           7 :   return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
      75             : }
      76             : 
      77           2 : JITSymbolNotFound::JITSymbolNotFound(std::string SymbolName)
      78           6 :   : SymbolName(std::move(SymbolName)) {}
      79             : 
      80           2 : std::error_code JITSymbolNotFound::convertToErrorCode() const {
      81             :   typedef std::underlying_type<OrcErrorCode>::type UT;
      82           2 :   return std::error_code(static_cast<UT>(OrcErrorCode::JITSymbolNotFound),
      83           4 :                          *OrcErrCat);
      84             : }
      85             : 
      86           4 : void JITSymbolNotFound::log(raw_ostream &OS) const {
      87           8 :   OS << "Could not find symbol '" << SymbolName << "'";
      88           4 : }
      89             : 
      90           0 : const std::string &JITSymbolNotFound::getSymbolName() const {
      91           0 :   return SymbolName;
      92             : }
      93             : 
      94             : }
      95             : }

Generated by: LCOV version 1.13