/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/DebugInfo/PDB/Native/TpiHashing.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- TpiHashing.h ---------------------------------------------*- C++ -*-===// |
2 | | // |
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 |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #ifndef LLVM_DEBUGINFO_PDB_TPIHASHING_H |
10 | | #define LLVM_DEBUGINFO_PDB_TPIHASHING_H |
11 | | |
12 | | #include "llvm/DebugInfo/CodeView/TypeRecord.h" |
13 | | #include "llvm/Support/Error.h" |
14 | | |
15 | | namespace llvm { |
16 | | namespace pdb { |
17 | | |
18 | | Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type); |
19 | | |
20 | | struct TagRecordHash { |
21 | | explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full, |
22 | | uint32_t Forward) |
23 | 768 | : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) { |
24 | 768 | State = 0; |
25 | 768 | } |
26 | | |
27 | | explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full, |
28 | | uint32_t Forward) |
29 | 0 | : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) { |
30 | 0 | State = 1; |
31 | 0 | } |
32 | | |
33 | | explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full, |
34 | | uint32_t Forward) |
35 | 6 | : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) { |
36 | 6 | State = 2; |
37 | 6 | } |
38 | | |
39 | | uint32_t FullRecordHash; |
40 | | uint32_t ForwardDeclHash; |
41 | | |
42 | 770 | codeview::TagRecord &getRecord() { |
43 | 770 | switch (State) { |
44 | 770 | case 0: |
45 | 764 | return Class; |
46 | 770 | case 1: |
47 | 0 | return Enum; |
48 | 770 | case 2: |
49 | 6 | return Union; |
50 | 0 | } |
51 | 0 | llvm_unreachable("unreachable!"); |
52 | 0 | } |
53 | | |
54 | | private: |
55 | | union { |
56 | | codeview::ClassRecord Class; |
57 | | codeview::EnumRecord Enum; |
58 | | codeview::UnionRecord Union; |
59 | | }; |
60 | | |
61 | | uint8_t State = 0; |
62 | | }; |
63 | | |
64 | | /// Given a CVType referring to a class, structure, union, or enum, compute |
65 | | /// the hash of its forward decl and full decl. |
66 | | Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type); |
67 | | |
68 | | } // end namespace pdb |
69 | | } // end namespace llvm |
70 | | |
71 | | #endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H |