InfoStreamBuilder.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- 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. #ifndef LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_INFOSTREAMBUILDER_H
  15. #include "llvm/ADT/Optional.h"
  16. #include "llvm/Support/Error.h"
  17. #include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
  18. #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
  19. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  20. #include "llvm/DebugInfo/PDB/PDBTypes.h"
  21. namespace llvm {
  22. class WritableBinaryStreamRef;
  23. namespace msf {
  24. class MSFBuilder;
  25. }
  26. namespace pdb {
  27. class PDBFile;
  28. class NamedStreamMap;
  29. class InfoStreamBuilder {
  30. public:
  31. InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams);
  32. InfoStreamBuilder(const InfoStreamBuilder &) = delete;
  33. InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete;
  34. void setVersion(PdbRaw_ImplVer V);
  35. void addFeature(PdbRaw_FeatureSig Sig);
  36. // If this is true, the PDB contents are hashed and this hash is used as
  37. // PDB GUID and as Signature. The age is always 1.
  38. void setHashPDBContentsToGUID(bool B);
  39. // These only have an effect if hashPDBContentsToGUID() is false.
  40. void setSignature(uint32_t S);
  41. void setAge(uint32_t A);
  42. void setGuid(codeview::GUID G);
  43. bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; }
  44. uint32_t getAge() const { return Age; }
  45. codeview::GUID getGuid() const { return Guid; }
  46. Optional<uint32_t> getSignature() const { return Signature; }
  47. uint32_t finalize();
  48. Error finalizeMsfLayout();
  49. Error commit(const msf::MSFLayout &Layout,
  50. WritableBinaryStreamRef Buffer) const;
  51. private:
  52. msf::MSFBuilder &Msf;
  53. std::vector<PdbRaw_FeatureSig> Features;
  54. PdbRaw_ImplVer Ver;
  55. uint32_t Age;
  56. Optional<uint32_t> Signature;
  57. codeview::GUID Guid;
  58. bool HashPDBContentsToGUID = false;
  59. NamedStreamMap &NamedStreams;
  60. };
  61. }
  62. }
  63. #endif
  64. #ifdef __GNUC__
  65. #pragma GCC diagnostic pop
  66. #endif