LCOV - code coverage report
Current view: top level - lib/Support - BinaryStreamError.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 13 26 50.0 %
Date: 2017-09-14 15:23:50 Functions: 3 6 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- BinaryStreamError.cpp - Error extensions for streams -----*- C++ -*-===//
       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             : #include "llvm/Support/BinaryStreamError.h"
      11             : #include "llvm/Support/ErrorHandling.h"
      12             : 
      13             : using namespace llvm;
      14             : 
      15             : char BinaryStreamError::ID = 0;
      16             : 
      17         217 : BinaryStreamError::BinaryStreamError(stream_error_code C)
      18         217 :     : BinaryStreamError(C, "") {}
      19             : 
      20           0 : BinaryStreamError::BinaryStreamError(StringRef Context)
      21           0 :     : BinaryStreamError(stream_error_code::unspecified, Context) {}
      22             : 
      23         217 : BinaryStreamError::BinaryStreamError(stream_error_code C, StringRef Context)
      24         651 :     : Code(C) {
      25         434 :   ErrMsg = "Stream Error: ";
      26         217 :   switch (C) {
      27           0 :   case stream_error_code::unspecified:
      28           0 :     ErrMsg += "An unspecified error has occurred.";
      29             :     break;
      30         211 :   case stream_error_code::stream_too_short:
      31         211 :     ErrMsg += "The stream is too short to perform the requested operation.";
      32             :     break;
      33           0 :   case stream_error_code::invalid_array_size:
      34           0 :     ErrMsg += "The buffer size is not a multiple of the array element size.";
      35             :     break;
      36           6 :   case stream_error_code::invalid_offset:
      37           6 :     ErrMsg += "The specified offset is invalid for the current stream.";
      38             :     break;
      39           0 :   case stream_error_code::filesystem_error:
      40           0 :     ErrMsg += "An I/O error occurred on the file system.";
      41             :     break;
      42             :   }
      43             : 
      44         217 :   if (!Context.empty()) {
      45           0 :     ErrMsg += "  ";
      46           0 :     ErrMsg += Context;
      47             :   }
      48         217 : }
      49             : 
      50         122 : void BinaryStreamError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
      51             : 
      52           0 : StringRef BinaryStreamError::getErrorMessage() const { return ErrMsg; }
      53             : 
      54           0 : std::error_code BinaryStreamError::convertToErrorCode() const {
      55           0 :   return inconvertibleErrorCode();
      56             : }

Generated by: LCOV version 1.13