Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:39

0001 //===- AppendingTypeTableBuilder.h -------------------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H
0011 
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/SmallVector.h"
0014 #include "llvm/DebugInfo/CodeView/CVRecord.h"
0015 #include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h"
0016 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
0017 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
0018 #include "llvm/Support/Allocator.h"
0019 #include <cstdint>
0020 
0021 namespace llvm {
0022 namespace codeview {
0023 
0024 class ContinuationRecordBuilder;
0025 
0026 class AppendingTypeTableBuilder : public TypeCollection {
0027 
0028   BumpPtrAllocator &RecordStorage;
0029   SimpleTypeSerializer SimpleSerializer;
0030 
0031   /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
0032   SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
0033 
0034 public:
0035   explicit AppendingTypeTableBuilder(BumpPtrAllocator &Storage);
0036   ~AppendingTypeTableBuilder();
0037 
0038   // TypeCollection overrides
0039   std::optional<TypeIndex> getFirst() override;
0040   std::optional<TypeIndex> getNext(TypeIndex Prev) override;
0041   CVType getType(TypeIndex Index) override;
0042   StringRef getTypeName(TypeIndex Index) override;
0043   bool contains(TypeIndex Index) override;
0044   uint32_t size() override;
0045   uint32_t capacity() override;
0046   bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override;
0047 
0048   // public interface
0049   void reset();
0050   TypeIndex nextTypeIndex() const;
0051 
0052   BumpPtrAllocator &getAllocator() { return RecordStorage; }
0053 
0054   ArrayRef<ArrayRef<uint8_t>> records() const;
0055   TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
0056   TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
0057 
0058   template <typename T> TypeIndex writeLeafType(T &Record) {
0059     ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
0060     return insertRecordBytes(Data);
0061   }
0062 };
0063 
0064 } // end namespace codeview
0065 } // end namespace llvm
0066 
0067 #endif // LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H