1 //===- ContinuationRecordBuilder.h ------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H 11 #define LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H 12 13 #include "llvm/ADT/ArrayRef.h" 14 #include "llvm/ADT/Optional.h" 15 #include "llvm/ADT/SmallVector.h" 16 #include "llvm/DebugInfo/CodeView/CodeView.h" 17 #include "llvm/DebugInfo/CodeView/RecordSerialization.h" 18 #include "llvm/DebugInfo/CodeView/TypeIndex.h" 19 #include "llvm/DebugInfo/CodeView/TypeRecord.h" 20 #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" 21 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" 22 #include "llvm/Support/Allocator.h" 23 #include "llvm/Support/BinaryByteStream.h" 24 #include "llvm/Support/BinaryStreamWriter.h" 25 #include "llvm/Support/Error.h" 26 #include <cassert> 27 #include <cstdint> 28 #include <memory> 29 #include <vector> 30 31 namespace llvm { 32 namespace codeview { 33 enum class ContinuationRecordKind { FieldList, MethodOverloadList }; 34 35 class ContinuationRecordBuilder { 36 SmallVector<uint32_t, 4> SegmentOffsets; 37 Optional<ContinuationRecordKind> Kind; 38 AppendingBinaryByteStream Buffer; 39 BinaryStreamWriter SegmentWriter; 40 TypeRecordMapping Mapping; 41 ArrayRef<uint8_t> InjectedSegmentBytes; 42 43 uint32_t getCurrentSegmentLength() const; 44 45 void insertSegmentEnd(uint32_t Offset); 46 CVType createSegmentRecord(uint32_t OffBegin, uint32_t OffEnd, 47 Optional<TypeIndex> RefersTo); 48 49 public: 50 ContinuationRecordBuilder(); 51 ~ContinuationRecordBuilder(); 52 53 void begin(ContinuationRecordKind RecordKind); 54 55 // This template is explicitly instantiated in the implementation file for all 56 // supported types. The method itself is ugly, so inlining it into the header 57 // file clutters an otherwise straightforward interface. 58 template <typename RecordType> void writeMemberType(RecordType &Record); 59 60 std::vector<CVType> end(TypeIndex Index); 61 }; 62 } // namespace codeview 63 } // namespace llvm 64 65 #endif