xref: /freebsd/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1 //===- ContinuationRecordBuilder.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_CONTINUATIONRECORDBUILDER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/CodeView/CVRecord.h"
15 #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
16 #include "llvm/Support/BinaryByteStream.h"
17 #include "llvm/Support/BinaryStreamWriter.h"
18 #include <cstdint>
19 #include <vector>
20 
21 namespace llvm {
22 namespace codeview {
23 class TypeIndex;
24 enum class ContinuationRecordKind { FieldList, MethodOverloadList };
25 
26 class ContinuationRecordBuilder {
27   SmallVector<uint32_t, 4> SegmentOffsets;
28   std::optional<ContinuationRecordKind> Kind;
29   AppendingBinaryByteStream Buffer;
30   BinaryStreamWriter SegmentWriter;
31   TypeRecordMapping Mapping;
32   ArrayRef<uint8_t> InjectedSegmentBytes;
33 
34   uint32_t getCurrentSegmentLength() const;
35 
36   void insertSegmentEnd(uint32_t Offset);
37   CVType createSegmentRecord(uint32_t OffBegin, uint32_t OffEnd,
38                              std::optional<TypeIndex> RefersTo);
39 
40 public:
41   ContinuationRecordBuilder();
42   ~ContinuationRecordBuilder();
43 
44   void begin(ContinuationRecordKind RecordKind);
45 
46   // This template is explicitly instantiated in the implementation file for all
47   // supported types.  The method itself is ugly, so inlining it into the header
48   // file clutters an otherwise straightforward interface.
49   template <typename RecordType> void writeMemberType(RecordType &Record);
50 
51   std::vector<CVType> end(TypeIndex Index);
52 };
53 } // namespace codeview
54 } // namespace llvm
55 
56 #endif
57