Coverage Report

Created: 2019-07-24 05:18

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