LLVM  10.0.0svn
AppendingTypeTableBuilder.h
Go to the documentation of this file.
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"
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 
28 
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:
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 
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
Optional< TypeIndex > getNext(TypeIndex Prev) override
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArrayRef< ArrayRef< uint8_t > > records() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
A 32-bit type reference.
Definition: TypeIndex.h:95
StringRef getTypeName(TypeIndex Index) override
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
ArrayRef< uint8_t > serialize(T &Record)
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48