LLVM  6.0.0svn
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::UDTSym &Sym);
65  void addGlobalSymbol(const codeview::CVSymbol &Sym);
66 
67 private:
68  uint32_t calculatePublicsHashStreamSize() const;
69  uint32_t calculateGlobalsHashStreamSize() const;
70  Error commitSymbolRecordStream(WritableBinaryStreamRef Stream);
71  Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
72  Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
73 
74  uint32_t RecordStreamIdx = kInvalidStreamIndex;
75  msf::MSFBuilder &Msf;
76  std::unique_ptr<GSIHashStreamBuilder> PSH;
77  std::unique_ptr<GSIHashStreamBuilder> GSH;
78 };
79 } // namespace pdb
80 } // namespace llvm
81 
82 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
CVRecord< SymbolKind > CVSymbol
Definition: SymbolRecord.h:947
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:53
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
static ArrayRef< uint8_t > bytes(const codeview::CVSymbol &Item)
static size_t length(const codeview::CVSymbol &Item)