PDBStringTableBuilder.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- PDBStringTableBuilder.h - PDB String Table Builder -------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file creates the "/names" stream.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
  18. #define LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
  19. #include "llvm/ADT/StringRef.h"
  20. #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
  21. #include "llvm/Support/Error.h"
  22. #include <cstdint>
  23. namespace llvm {
  24. class BinaryStreamWriter;
  25. class WritableBinaryStreamRef;
  26. namespace msf {
  27. struct MSFLayout;
  28. }
  29. namespace pdb {
  30. class PDBFileBuilder;
  31. class PDBStringTableBuilder;
  32. struct StringTableHashTraits {
  33. PDBStringTableBuilder *Table;
  34. explicit StringTableHashTraits(PDBStringTableBuilder &Table);
  35. uint32_t hashLookupKey(StringRef S) const;
  36. StringRef storageKeyToLookupKey(uint32_t Offset) const;
  37. uint32_t lookupKeyToStorageKey(StringRef S);
  38. };
  39. class PDBStringTableBuilder {
  40. public:
  41. // If string S does not exist in the string table, insert it.
  42. // Returns the ID for S.
  43. uint32_t insert(StringRef S);
  44. uint32_t getIdForString(StringRef S) const;
  45. StringRef getStringForId(uint32_t Id) const;
  46. uint32_t calculateSerializedSize() const;
  47. Error commit(BinaryStreamWriter &Writer) const;
  48. void setStrings(const codeview::DebugStringTableSubsection &Strings);
  49. private:
  50. uint32_t calculateHashTableSize() const;
  51. Error writeHeader(BinaryStreamWriter &Writer) const;
  52. Error writeStrings(BinaryStreamWriter &Writer) const;
  53. Error writeHashTable(BinaryStreamWriter &Writer) const;
  54. Error writeEpilogue(BinaryStreamWriter &Writer) const;
  55. codeview::DebugStringTableSubsection Strings;
  56. };
  57. } // end namespace pdb
  58. } // end namespace llvm
  59. #endif // LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLEBUILDER_H
  60. #ifdef __GNUC__
  61. #pragma GCC diagnostic pop
  62. #endif