Coverage Report

Created: 2017-02-28 18:21

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/DebugInfo/MSF/MSFError.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- MSFError.cpp - Error extensions for MSF files ------------*- 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/DebugInfo/MSF/MSFError.h"
11
#include "llvm/Support/ErrorHandling.h"
12
#include "llvm/Support/ManagedStatic.h"
13
14
using namespace llvm;
15
using namespace llvm::msf;
16
17
namespace {
18
// FIXME: This class is only here to support the transition to llvm::Error. It
19
// will be removed once this transition is complete. Clients should prefer to
20
// deal with the Error value directly, rather than converting to error_code.
21
class MSFErrorCategory : public std::error_category {
22
public:
23
0
  const char *name() const noexcept override { return "llvm.msf"; }
24
25
159
  std::string message(int Condition) const override {
26
159
    switch (static_cast<msf_error_code>(Condition)) {
27
0
    case msf_error_code::unspecified:
28
0
      return "An unknown error has occurred.";
29
155
    case msf_error_code::insufficient_buffer:
30
155
      return "The buffer is not large enough to read the requested number of "
31
155
             "bytes.";
32
0
    case msf_error_code::not_writable:
33
0
      return "The specified stream is not writable.";
34
0
    case msf_error_code::no_stream:
35
0
      return "The specified stream does not exist.";
36
4
    case msf_error_code::invalid_format:
37
4
      return "The data is in an unexpected format.";
38
0
    case msf_error_code::block_in_use:
39
0
      return "The block is already in use.";
40
159
    }
41
0
    
llvm_unreachable0
("Unrecognized msf_error_code");0
42
0
  }
43
};
44
} // end anonymous namespace
45
46
static ManagedStatic<MSFErrorCategory> Category;
47
48
char MSFError::ID = 0;
49
50
155
MSFError::MSFError(msf_error_code C) : MSFError(C, "") {}
Unexecuted instantiation: llvm::msf::MSFError::MSFError(llvm::msf::msf_error_code)
llvm::msf::MSFError::MSFError(llvm::msf::msf_error_code)
Line
Count
Source
50
155
MSFError::MSFError(msf_error_code C) : MSFError(C, "") {}
51
52
MSFError::MSFError(const std::string &Context)
53
0
    : MSFError(msf_error_code::unspecified, Context) {}
Unexecuted instantiation: llvm::msf::MSFError::MSFError(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Unexecuted instantiation: llvm::msf::MSFError::MSFError(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
54
55
160
MSFError::MSFError(msf_error_code C, const std::string &Context) : Code(C) {
56
160
  ErrMsg = "MSF Error: ";
57
160
  std::error_code EC = convertToErrorCode();
58
160
  if (Code != msf_error_code::unspecified)
59
159
    ErrMsg += EC.message() + "  ";
60
160
  if (!Context.empty())
61
5
    ErrMsg += Context;
62
160
}
63
64
0
void MSFError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
65
66
0
const std::string &MSFError::getErrorMessage() const { return ErrMsg; }
67
68
160
std::error_code MSFError::convertToErrorCode() const {
69
160
  return std::error_code(static_cast<int>(Code), *Category);
70
160
}