1//===- PDBStringTableBuilder.h - PDB String Table Builder -------*- 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// This file creates the "/names" stream.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
14#define LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
15
16#include "llvm/ADT/StringRef.h"
17#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
18#include "llvm/Support/Error.h"
19#include <cstdint>
20
21namespace llvm {
22class BinaryStreamWriter;
23class WritableBinaryStreamRef;
24
25namespace msf {
26struct MSFLayout;
27}
28
29namespace pdb {
30
31class PDBFileBuilder;
32class PDBStringTableBuilder;
33
34struct StringTableHashTraits {
35 PDBStringTableBuilder *Table;
36
37 explicit StringTableHashTraits(PDBStringTableBuilder &Table);
38 uint32_t hashLookupKey(StringRef S) const;
39 StringRef storageKeyToLookupKey(uint32_t Offset) const;
40 uint32_t lookupKeyToStorageKey(StringRef S);
41};
42
43class PDBStringTableBuilder {
44public:
45 // If string S does not exist in the string table, insert it.
46 // Returns the ID for S.
47 uint32_t insert(StringRef S);
48
49 uint32_t getIdForString(StringRef S) const;
50 StringRef getStringForId(uint32_t Id) const;
51
52 uint32_t calculateSerializedSize() const;
53 Error commit(BinaryStreamWriter &Writer) const;
54
55 void setStrings(const codeview::DebugStringTableSubsection &Strings);
56
57private:
58 uint32_t calculateHashTableSize() const;
59 Error writeHeader(BinaryStreamWriter &Writer) const;
60 Error writeStrings(BinaryStreamWriter &Writer) const;
61 Error writeHashTable(BinaryStreamWriter &Writer) const;
62 Error writeEpilogue(BinaryStreamWriter &Writer) const;
63
64 codeview::DebugStringTableSubsection Strings;
65};
66
67} // end namespace pdb
68} // end namespace llvm
69
70#endif // LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
71

source code of llvm/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h