1 //===- TpiHashing.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_PDB_TPIHASHING_H
11 #define LLVM_DEBUGINFO_PDB_TPIHASHING_H
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/StringExtras.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
18 #include "llvm/DebugInfo/PDB/Native/RawError.h"
19 #include "llvm/Support/BinaryStreamArray.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
28 class TpiHashUpdater : public codeview::TypeVisitorCallbacks {
30 TpiHashUpdater() = default;
32 #define TYPE_RECORD(EnumName, EnumVal, Name) \
33 virtual Error visitKnownRecord(codeview::CVType &CVR, \
34 codeview::Name##Record &Record) override { \
35 visitKnownRecordImpl(CVR, Record); \
36 return Error::success(); \
38 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
39 #define MEMBER_RECORD(EnumName, EnumVal, Name)
40 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
41 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
44 template <typename RecordKind>
45 void visitKnownRecordImpl(codeview::CVType &CVR, RecordKind &Record) {
49 void visitKnownRecordImpl(codeview::CVType &CVR,
50 codeview::UdtSourceLineRecord &Rec);
51 void visitKnownRecordImpl(codeview::CVType &CVR,
52 codeview::UdtModSourceLineRecord &Rec);
53 void visitKnownRecordImpl(codeview::CVType &CVR, codeview::ClassRecord &Rec);
54 void visitKnownRecordImpl(codeview::CVType &CVR, codeview::EnumRecord &Rec);
55 void visitKnownRecordImpl(codeview::CVType &CVR, codeview::UnionRecord &Rec);
58 class TpiHashVerifier : public codeview::TypeVisitorCallbacks {
60 TpiHashVerifier(FixedStreamArray<support::ulittle32_t> &HashValues,
61 uint32_t NumHashBuckets)
62 : HashValues(HashValues), NumHashBuckets(NumHashBuckets) {}
64 Error visitKnownRecord(codeview::CVType &CVR,
65 codeview::UdtSourceLineRecord &Rec) override;
66 Error visitKnownRecord(codeview::CVType &CVR,
67 codeview::UdtModSourceLineRecord &Rec) override;
68 Error visitKnownRecord(codeview::CVType &CVR,
69 codeview::ClassRecord &Rec) override;
70 Error visitKnownRecord(codeview::CVType &CVR,
71 codeview::EnumRecord &Rec) override;
72 Error visitKnownRecord(codeview::CVType &CVR,
73 codeview::UnionRecord &Rec) override;
74 Error visitTypeBegin(codeview::CVType &CVR) override;
77 Error verifySourceLine(codeview::TypeIndex TI);
79 Error errorInvalidHash() {
80 return make_error<RawError>(
81 raw_error_code::invalid_tpi_hash,
83 utohexstr(codeview::TypeIndex::FirstNonSimpleIndex + Index));
86 FixedStreamArray<support::ulittle32_t> HashValues;
87 codeview::CVType RawRecord;
88 uint32_t NumHashBuckets;
92 } // end namespace pdb
93 } // end namespace llvm
95 #endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H