]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/TpiHashing.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / TpiHashing.h
1 //===- TpiHashing.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEBUGINFO_PDB_TPIHASHING_H
11 #define LLVM_DEBUGINFO_PDB_TPIHASHING_H
12
13 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
14 #include "llvm/Support/Error.h"
15
16 namespace llvm {
17 namespace pdb {
18
19 Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type);
20
21 struct TagRecordHash {
22   explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full,
23                          uint32_t Forward)
24       : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) {
25     State = 0;
26   }
27
28   explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full,
29                          uint32_t Forward)
30       : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) {
31     State = 1;
32   }
33
34   explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full,
35                          uint32_t Forward)
36       : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) {
37     State = 2;
38   }
39
40   uint32_t FullRecordHash;
41   uint32_t ForwardDeclHash;
42
43   codeview::TagRecord &getRecord() {
44     switch (State) {
45     case 0:
46       return Class;
47     case 1:
48       return Enum;
49     case 2:
50       return Union;
51     }
52     llvm_unreachable("unreachable!");
53   }
54
55 private:
56   union {
57     codeview::ClassRecord Class;
58     codeview::EnumRecord Enum;
59     codeview::UnionRecord Union;
60   };
61
62   uint8_t State = 0;
63 };
64
65 /// Given a CVType referring to a class, structure, union, or enum, compute
66 /// the hash of its forward decl and full decl.
67 Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type);
68
69 } // end namespace pdb
70 } // end namespace llvm
71
72 #endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H