1 //===- PDBStringTableBuilder.h - PDB String Table Builder -------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file creates the "/names" stream.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
14 #define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
19 #include "llvm/Support/Error.h"
23 class BinaryStreamWriter
;
24 class WritableBinaryStreamRef
;
33 class PDBStringTableBuilder
;
35 struct StringTableHashTraits
{
36 PDBStringTableBuilder
*Table
;
38 explicit StringTableHashTraits(PDBStringTableBuilder
&Table
);
39 uint32_t hashLookupKey(StringRef S
) const;
40 StringRef
storageKeyToLookupKey(uint32_t Offset
) const;
41 uint32_t lookupKeyToStorageKey(StringRef S
);
44 class PDBStringTableBuilder
{
46 // If string S does not exist in the string table, insert it.
47 // Returns the ID for S.
48 uint32_t insert(StringRef S
);
50 uint32_t getIdForString(StringRef S
) const;
51 StringRef
getStringForId(uint32_t Id
) const;
53 uint32_t calculateSerializedSize() const;
54 Error
commit(BinaryStreamWriter
&Writer
) const;
56 void setStrings(const codeview::DebugStringTableSubsection
&Strings
);
59 uint32_t calculateHashTableSize() const;
60 Error
writeHeader(BinaryStreamWriter
&Writer
) const;
61 Error
writeStrings(BinaryStreamWriter
&Writer
) const;
62 Error
writeHashTable(BinaryStreamWriter
&Writer
) const;
63 Error
writeEpilogue(BinaryStreamWriter
&Writer
) const;
65 codeview::DebugStringTableSubsection Strings
;
68 } // end namespace pdb
69 } // end namespace llvm
71 #endif // LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H