1 //===- AppendingTypeTableBuilder.h -------------------------------*- 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 #ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/CodeView/CodeView.h"
15 #include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h"
16 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
17 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
18 #include "llvm/Support/Allocator.h"
27 class ContinuationRecordBuilder
;
29 class AppendingTypeTableBuilder
: public TypeCollection
{
31 BumpPtrAllocator
&RecordStorage
;
32 SimpleTypeSerializer SimpleSerializer
;
34 /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
35 SmallVector
<ArrayRef
<uint8_t>, 2> SeenRecords
;
38 explicit AppendingTypeTableBuilder(BumpPtrAllocator
&Storage
);
39 ~AppendingTypeTableBuilder();
41 // TypeTableCollection overrides
42 Optional
<TypeIndex
> getFirst() override
;
43 Optional
<TypeIndex
> getNext(TypeIndex Prev
) override
;
44 CVType
getType(TypeIndex Index
) override
;
45 StringRef
getTypeName(TypeIndex Index
) override
;
46 bool contains(TypeIndex Index
) override
;
47 uint32_t size() override
;
48 uint32_t capacity() override
;
52 TypeIndex
nextTypeIndex() const;
54 BumpPtrAllocator
&getAllocator() { return RecordStorage
; }
56 ArrayRef
<ArrayRef
<uint8_t>> records() const;
57 TypeIndex
insertRecordBytes(ArrayRef
<uint8_t> &Record
);
58 TypeIndex
insertRecord(ContinuationRecordBuilder
&Builder
);
60 template <typename T
> TypeIndex
writeLeafType(T
&Record
) {
61 ArrayRef
<uint8_t> Data
= SimpleSerializer
.serialize(Record
);
62 return insertRecordBytes(Data
);
66 } // end namespace codeview
67 } // end namespace llvm
69 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H