LLVM  4.0.0
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"
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  static size_t length(const codeview::CVType &Item) { return Item.length(); }
37  return Item.data();
38  }
39 };
40 }
41 namespace pdb {
42 class PDBFile;
43 class TpiStream;
44 struct TpiStreamHeader;
45 
47 public:
48  explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx);
50 
51  TpiStreamBuilder(const TpiStreamBuilder &) = delete;
52  TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete;
53 
56 
58 
59  Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer);
60 
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;
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
static size_t length(const codeview::CVType &Item)
ArrayRef< uint8_t > data() const
Definition: CVRecord.h:34
static ArrayRef< uint8_t > bytes(const codeview::CVType &Item)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
uint32_t calculateSerializedLength() const
void addTypeRecord(const codeview::CVType &Record)
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:20
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
TpiStreamBuilder & operator=(const TpiStreamBuilder &)=delete
void setVersionHeader(PdbRaw_TpiVer Version)
uint32_t length() const
Definition: CVRecord.h:32
TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx)
Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer)
Lightweight error class with error context and mandatory checking.
const uint64_t Version
Definition: InstrProf.h:799