TpiHashing.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- TpiHashing.h ---------------------------------------------*- 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_TPIHASHING_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_TPIHASHING_H
  15. #include "llvm/DebugInfo/CodeView/TypeRecord.h"
  16. #include "llvm/Support/Error.h"
  17. namespace llvm {
  18. namespace pdb {
  19. Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type);
  20. struct TagRecordHash {
  21. explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full,
  22. uint32_t Forward)
  23. : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) {
  24. State = 0;
  25. }
  26. explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full,
  27. uint32_t Forward)
  28. : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) {
  29. State = 1;
  30. }
  31. explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full,
  32. uint32_t Forward)
  33. : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) {
  34. State = 2;
  35. }
  36. uint32_t FullRecordHash;
  37. uint32_t ForwardDeclHash;
  38. codeview::TagRecord &getRecord() {
  39. switch (State) {
  40. case 0:
  41. return Class;
  42. case 1:
  43. return Enum;
  44. case 2:
  45. return Union;
  46. }
  47. llvm_unreachable("unreachable!");
  48. }
  49. private:
  50. union {
  51. codeview::ClassRecord Class;
  52. codeview::EnumRecord Enum;
  53. codeview::UnionRecord Union;
  54. };
  55. uint8_t State = 0;
  56. };
  57. /// Given a CVType referring to a class, structure, union, or enum, compute
  58. /// the hash of its forward decl and full decl.
  59. Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type);
  60. } // end namespace pdb
  61. } // end namespace llvm
  62. #endif // LLVM_DEBUGINFO_PDB_NATIVE_TPIHASHING_H
  63. #ifdef __GNUC__
  64. #pragma GCC diagnostic pop
  65. #endif