LLVM  6.0.0svn
TpiStreamBuilder.h
Go to the documentation of this file.
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"
17 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/Error.h"
22 
23 #include <vector>
24 
25 namespace llvm {
26 class BinaryByteStream;
27 class WritableBinaryStreamRef;
28 
29 template <> struct BinaryItemTraits<llvm::codeview::CVType> {
30  static size_t length(const codeview::CVType &Item) { return Item.length(); }
32  return Item.data();
33  }
34 };
35 
36 namespace codeview {
37 class TypeRecord;
38 }
39 namespace msf {
40 class MSFBuilder;
41 struct MSFLayout;
42 }
43 namespace pdb {
44 class PDBFile;
45 class TpiStream;
46 struct TpiStreamHeader;
47 
49 public:
50  explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx);
52 
53  TpiStreamBuilder(const TpiStreamBuilder &) = delete;
54  TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete;
55 
56  void setVersionHeader(PdbRaw_TpiVer Version);
57  void addTypeRecord(ArrayRef<uint8_t> Type, Optional<uint32_t> Hash);
58 
59  Error finalizeMsfLayout();
60 
61  uint32_t getRecordCount() const { return TypeRecords.size(); }
62 
63  Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
64 
65  uint32_t calculateSerializedLength();
66 
67 private:
68  uint32_t calculateHashBufferSize() const;
69  uint32_t calculateIndexOffsetSize() const;
70  Error finalize();
71 
72  msf::MSFBuilder &Msf;
74 
75  size_t TypeRecordBytes = 0;
76 
78  std::vector<ArrayRef<uint8_t>> TypeRecords;
79  std::vector<uint32_t> TypeHashes;
80  std::vector<codeview::TypeIndexOffset> TypeIndexOffsets;
81  uint32_t HashStreamIndex = kInvalidStreamIndex;
82  std::unique_ptr<BinaryByteStream> HashValueStream;
83 
84  const TpiStreamHeader *Header;
85  uint32_t Idx;
86 };
87 }
88 }
89 
90 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
arc branch finalize
static ArrayRef< uint8_t > bytes(const codeview::CVType &Item)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
uint32_t length() const
Definition: CVRecord.h:36
ArrayRef< uint8_t > data() const
Definition: CVRecord.h:38
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:20
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
Basic Register Allocator
static size_t length(const codeview::CVType &Item)
uint32_t getRecordCount() const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
const uint64_t Version
Definition: InstrProf.h:867