LLVM  8.0.1
GSIStreamBuilder.h
Go to the documentation of this file.
1 //===- GSIStreamBuilder.h - PDB Publics/Globals 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_GSISTREAMBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
12 
21 #include "llvm/Support/Endian.h"
22 #include "llvm/Support/Error.h"
23 
24 namespace llvm {
25 
26 template <> struct BinaryItemTraits<codeview::CVSymbol> {
27  static size_t length(const codeview::CVSymbol &Item) {
28  return Item.RecordData.size();
29  }
31  return Item.RecordData;
32  }
33 };
34 
35 namespace msf {
36 class MSFBuilder;
37 struct MSFLayout;
38 } // namespace msf
39 namespace pdb {
40 struct GSIHashStreamBuilder;
41 
43 
44 public:
45  explicit GSIStreamBuilder(msf::MSFBuilder &Msf);
47 
48  GSIStreamBuilder(const GSIStreamBuilder &) = delete;
49  GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete;
50 
51  Error finalizeMsfLayout();
52 
53  Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
54 
55  uint32_t getPublicsStreamIndex() const;
56  uint32_t getGlobalsStreamIndex() const;
57  uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
58 
59  void addPublicSymbol(const codeview::PublicSym32 &Pub);
60 
61  void addGlobalSymbol(const codeview::ProcRefSym &Sym);
62  void addGlobalSymbol(const codeview::DataSym &Sym);
63  void addGlobalSymbol(const codeview::ConstantSym &Sym);
64  void addGlobalSymbol(const codeview::CVSymbol &Sym);
65 
66 private:
67  uint32_t calculatePublicsHashStreamSize() const;
68  uint32_t calculateGlobalsHashStreamSize() const;
69  Error commitSymbolRecordStream(WritableBinaryStreamRef Stream);
70  Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
71  Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
72 
73  uint32_t RecordStreamIdx = kInvalidStreamIndex;
74  msf::MSFBuilder &Msf;
75  std::unique_ptr<GSIHashStreamBuilder> PSH;
76  std::unique_ptr<GSIHashStreamBuilder> GSH;
77 };
78 } // namespace pdb
79 } // namespace llvm
80 
81 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
CVRecord< SymbolKind > CVSymbol
Definition: SymbolRecord.h:987
uint32_t getRecordStreamIdx() const
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:20
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
ArrayRef< uint8_t > RecordData
Definition: CVRecord.h:49
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
static ArrayRef< uint8_t > bytes(const codeview::CVSymbol &Item)
static size_t length(const codeview::CVSymbol &Item)