LLVM  9.0.0svn
GSIStreamBuilder.h
Go to the documentation of this file.
1 //===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
10 #define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
11 
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
22 
23 namespace llvm {
24 
25 template <> struct BinaryItemTraits<codeview::CVSymbol> {
26  static size_t length(const codeview::CVSymbol &Item) {
27  return Item.RecordData.size();
28  }
30  return Item.RecordData;
31  }
32 };
33 
34 namespace msf {
35 class MSFBuilder;
36 struct MSFLayout;
37 } // namespace msf
38 namespace pdb {
39 struct GSIHashStreamBuilder;
40 
42 
43 public:
44  explicit GSIStreamBuilder(msf::MSFBuilder &Msf);
46 
47  GSIStreamBuilder(const GSIStreamBuilder &) = delete;
48  GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete;
49 
50  Error finalizeMsfLayout();
51 
52  Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
53 
54  uint32_t getPublicsStreamIndex() const;
55  uint32_t getGlobalsStreamIndex() const;
56  uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
57 
58  void addPublicSymbol(const codeview::PublicSym32 &Pub);
59 
60  void addGlobalSymbol(const codeview::ProcRefSym &Sym);
61  void addGlobalSymbol(const codeview::DataSym &Sym);
62  void addGlobalSymbol(const codeview::ConstantSym &Sym);
63  void addGlobalSymbol(const codeview::CVSymbol &Sym);
64 
65 private:
66  uint32_t calculatePublicsHashStreamSize() const;
67  uint32_t calculateGlobalsHashStreamSize() const;
68  Error commitSymbolRecordStream(WritableBinaryStreamRef Stream);
69  Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
70  Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
71 
72  uint32_t RecordStreamIdx = kInvalidStreamIndex;
73  msf::MSFBuilder &Msf;
74  std::unique_ptr<GSIHashStreamBuilder> PSH;
75  std::unique_ptr<GSIHashStreamBuilder> GSH;
76 };
77 } // namespace pdb
78 } // namespace llvm
79 
80 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
CVRecord< SymbolKind > CVSymbol
Definition: SymbolRecord.h:995
uint32_t getRecordStreamIdx() const
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:19
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:148
ArrayRef< uint8_t > RecordData
Definition: CVRecord.h:61
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:30
static ArrayRef< uint8_t > bytes(const codeview::CVSymbol &Item)
static size_t length(const codeview::CVSymbol &Item)