Line data Source code
1 : //===- TpiStreamBuilder.h - PDB Tpi Stream Creation -------------*- 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_PDB_RAW_PDBTPISTREAMBUILDER_H
11 : #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAMBUILDER_H
12 :
13 : #include "llvm/ADT/Optional.h"
14 : #include "llvm/DebugInfo/CodeView/TypeRecord.h"
15 : #include "llvm/DebugInfo/MSF/ByteStream.h"
16 : #include "llvm/DebugInfo/MSF/SequencedItemStream.h"
17 : #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
18 : #include "llvm/Support/Allocator.h"
19 : #include "llvm/Support/Error.h"
20 :
21 : #include <vector>
22 :
23 : namespace llvm {
24 : namespace codeview {
25 : class TypeRecord;
26 : }
27 : namespace msf {
28 : class ByteStream;
29 : class MSFBuilder;
30 : struct MSFLayout;
31 : class ReadableStreamRef;
32 : class WritableStream;
33 :
34 : template <> struct SequencedItemTraits<llvm::codeview::CVType> {
35 6187 : static size_t length(const codeview::CVType &Item) { return Item.length(); }
36 : static ArrayRef<uint8_t> bytes(const codeview::CVType &Item) {
37 0 : return Item.data();
38 : }
39 : };
40 : }
41 : namespace pdb {
42 : class PDBFile;
43 : class TpiStream;
44 : struct TpiStreamHeader;
45 :
46 30 : class TpiStreamBuilder {
47 : public:
48 : explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx);
49 : ~TpiStreamBuilder();
50 :
51 : TpiStreamBuilder(const TpiStreamBuilder &) = delete;
52 : TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete;
53 :
54 : void setVersionHeader(PdbRaw_TpiVer Version);
55 : void addTypeRecord(const codeview::CVType &Record);
56 :
57 : Error finalizeMsfLayout();
58 :
59 : Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);
60 :
61 : uint32_t calculateSerializedLength() const;
62 :
63 : private:
64 : uint32_t calculateHashBufferSize() const;
65 : Error finalize();
66 :
67 : msf::MSFBuilder &Msf;
68 : BumpPtrAllocator &Allocator;
69 :
70 : Optional<PdbRaw_TpiVer> VerHeader;
71 : std::vector<codeview::CVType> TypeRecords;
72 : msf::SequencedItemStream<codeview::CVType> TypeRecordStream;
73 : uint32_t HashStreamIndex = kInvalidStreamIndex;
74 : std::unique_ptr<msf::ByteStream> HashValueStream;
75 :
76 : const TpiStreamHeader *Header;
77 : uint32_t Idx;
78 : };
79 : }
80 : }
81 :
82 : #endif
|