Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- TypeTableCollection.cpp -------------------------------- *- 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/CodeView/TypeTableCollection.h"
11
12
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
13
#include "llvm/DebugInfo/CodeView/RecordName.h"
14
#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
15
#include "llvm/Support/BinaryByteStream.h"
16
#include "llvm/Support/BinaryStreamReader.h"
17
18
using namespace llvm;
19
using namespace llvm::codeview;
20
21
TypeTableCollection::TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records)
22
99
    : NameStorage(Allocator), Records(Records) {
23
99
  Names.resize(Records.size());
24
99
}
25
26
99
Optional<TypeIndex> TypeTableCollection::getFirst() {
27
99
  if (empty())
28
1
    return None;
29
98
  return TypeIndex::fromArrayIndex(0);
30
98
}
31
32
1.10k
Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
33
1.10k
  assert(contains(Prev));
34
1.10k
  ++Prev;
35
1.10k
  if (Prev.toArrayIndex() == size())
36
98
    return None;
37
1.00k
  return Prev;
38
1.00k
}
39
40
1.44k
CVType TypeTableCollection::getType(TypeIndex Index) {
41
1.44k
  assert(Index.toArrayIndex() < Records.size());
42
1.44k
  ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()];
43
1.44k
  const RecordPrefix *Prefix =
44
1.44k
      reinterpret_cast<const RecordPrefix *>(Bytes.data());
45
1.44k
  TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind));
46
1.44k
  return CVType(Kind, Bytes);
47
1.44k
}
48
49
877
StringRef TypeTableCollection::getTypeName(TypeIndex Index) {
50
877
  if (
Index.isNoneType() || 877
Index.isSimple()877
)
51
110
    return TypeIndex::simpleTypeName(Index);
52
767
53
767
  uint32_t I = Index.toArrayIndex();
54
767
  if (
Names[I].data() == nullptr767
) {
55
340
    StringRef Result = NameStorage.save(computeTypeName(*this, Index));
56
340
    Names[I] = Result;
57
340
  }
58
877
  return Names[I];
59
877
}
60
61
0
bool TypeTableCollection::contains(TypeIndex Index) {
62
0
  return Index.toArrayIndex() <= size();
63
0
}
64
65
1.19k
uint32_t TypeTableCollection::size() { return Records.size(); }
66
67
0
uint32_t TypeTableCollection::capacity() { return Records.size(); }