1 //===- TypeTableCollection.cpp -------------------------------- *- C++ --*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/CodeView/TypeTableCollection.h"
11 #include "llvm/DebugInfo/CodeView/CodeView.h"
12 #include "llvm/DebugInfo/CodeView/RecordName.h"
13 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
14 #include "llvm/Support/ErrorHandling.h"
17 using namespace llvm::codeview
;
19 TypeTableCollection::TypeTableCollection(ArrayRef
<ArrayRef
<uint8_t>> Records
)
20 : NameStorage(Allocator
), Records(Records
) {
21 Names
.resize(Records
.size());
24 std::optional
<TypeIndex
> TypeTableCollection::getFirst() {
27 return TypeIndex::fromArrayIndex(0);
30 std::optional
<TypeIndex
> TypeTableCollection::getNext(TypeIndex Prev
) {
31 assert(contains(Prev
));
33 if (Prev
.toArrayIndex() == size())
38 CVType
TypeTableCollection::getType(TypeIndex Index
) {
39 assert(Index
.toArrayIndex() < Records
.size());
40 return CVType(Records
[Index
.toArrayIndex()]);
43 StringRef
TypeTableCollection::getTypeName(TypeIndex Index
) {
44 if (Index
.isNoneType() || Index
.isSimple())
45 return TypeIndex::simpleTypeName(Index
);
47 uint32_t I
= Index
.toArrayIndex();
48 if (Names
[I
].data() == nullptr) {
49 StringRef Result
= NameStorage
.save(computeTypeName(*this, Index
));
55 bool TypeTableCollection::contains(TypeIndex Index
) {
56 return Index
.toArrayIndex() <= size();
59 uint32_t TypeTableCollection::size() { return Records
.size(); }
61 uint32_t TypeTableCollection::capacity() { return Records
.size(); }
63 bool TypeTableCollection::replaceType(TypeIndex
&Index
, CVType Data
,
65 llvm_unreachable("Method cannot be called");