]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h
Move all sources from the llvm project into contrib/llvm-project.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / include / llvm / DebugInfo / CodeView / AppendingTypeTableBuilder.h
1 //===- AppendingTypeTableBuilder.h -------------------------------*- 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 #ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
11
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"
19 #include <cassert>
20 #include <cstdint>
21 #include <memory>
22 #include <vector>
23
24 namespace llvm {
25 namespace codeview {
26
27 class ContinuationRecordBuilder;
28
29 class AppendingTypeTableBuilder : public TypeCollection {
30
31   BumpPtrAllocator &RecordStorage;
32   SimpleTypeSerializer SimpleSerializer;
33
34   /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
35   SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
36
37 public:
38   explicit AppendingTypeTableBuilder(BumpPtrAllocator &Storage);
39   ~AppendingTypeTableBuilder();
40
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;
49
50   // public interface
51   void reset();
52   TypeIndex nextTypeIndex() const;
53
54   BumpPtrAllocator &getAllocator() { return RecordStorage; }
55
56   ArrayRef<ArrayRef<uint8_t>> records() const;
57   TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
58   TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
59
60   template <typename T> TypeIndex writeLeafType(T &Record) {
61     ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
62     return insertRecordBytes(Data);
63   }
64 };
65
66 } // end namespace codeview
67 } // end namespace llvm
68
69 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H