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