LLVM  8.0.1
PDBStringTableBuilder.h
Go to the documentation of this file.
1 //===- PDBStringTableBuilder.h - PDB String Table Builder -------*- 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 // This file creates the "/names" stream.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
15 #define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Error.h"
21 #include <vector>
22 
23 namespace llvm {
24 class BinaryStreamWriter;
25 class WritableBinaryStreamRef;
26 
27 namespace msf {
28 struct MSFLayout;
29 }
30 
31 namespace pdb {
32 
33 class PDBFileBuilder;
34 class PDBStringTableBuilder;
35 
38 
40  uint32_t hashLookupKey(StringRef S) const;
41  StringRef storageKeyToLookupKey(uint32_t Offset) const;
42  uint32_t lookupKeyToStorageKey(StringRef S);
43 };
44 
46 public:
47  // If string S does not exist in the string table, insert it.
48  // Returns the ID for S.
49  uint32_t insert(StringRef S);
50 
51  uint32_t getIdForString(StringRef S) const;
52  StringRef getStringForId(uint32_t Id) const;
53 
54  uint32_t calculateSerializedSize() const;
55  Error commit(BinaryStreamWriter &Writer) const;
56 
57  void setStrings(const codeview::DebugStringTableSubsection &Strings);
58 
59 private:
60  uint32_t calculateHashTableSize() const;
61  Error writeHeader(BinaryStreamWriter &Writer) const;
62  Error writeStrings(BinaryStreamWriter &Writer) const;
63  Error writeHashTable(BinaryStreamWriter &Writer) const;
64  Error writeEpilogue(BinaryStreamWriter &Writer) const;
65 
67 };
68 
69 } // end namespace pdb
70 } // end namespace llvm
71 
72 #endif // LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Provides write only access to a subclass of WritableBinaryStream.
Represents a read-write view of a CodeView string table.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49