LLVM  4.0.0
TpiHashing.h
Go to the documentation of this file.
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/ADT/Optional.h"
14 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
22 #include <cstdint>
23 #include <string>
24 
25 namespace llvm {
26 namespace pdb {
27 
29 public:
30  TpiHashUpdater() = default;
31 
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(); \
37  }
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/TypeRecords.def"
42 
43 private:
44  template <typename RecordKind>
45  void visitKnownRecordImpl(codeview::CVType &CVR, RecordKind &Record) {
46  CVR.Hash = 0;
47  }
48 
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);
56 };
57 
59 public:
61  uint32_t NumHashBuckets)
62  : HashValues(HashValues), NumHashBuckets(NumHashBuckets) {}
63 
65  codeview::UdtSourceLineRecord &Rec) override;
67  codeview::UdtModSourceLineRecord &Rec) override;
69  codeview::ClassRecord &Rec) override;
71  codeview::EnumRecord &Rec) override;
73  codeview::UnionRecord &Rec) override;
74  Error visitTypeBegin(codeview::CVType &CVR) override;
75 
76 private:
77  Error verifySourceLine(codeview::TypeIndex TI);
78 
79  Error errorInvalidHash() {
80  return make_error<RawError>(
82  "Type index is 0x" +
84  }
85 
87  codeview::CVType RawRecord;
88  uint32_t NumHashBuckets;
89  uint32_t Index = -1;
90 };
91 
92 } // end namespace pdb
93 } // end namespace llvm
94 
95 #endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H
CVRecord< TypeLeafKind > CVType
Definition: TypeRecord.h:39
Error visitTypeBegin(codeview::CVType &CVR) override
Paired begin/end actions for all types.
Definition: TpiHashing.cpp:106
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:91
A 32-bit type reference.
Definition: TypeIndex.h:89
TpiHashVerifier(msf::FixedStreamArray< support::ulittle32_t > &HashValues, uint32_t NumHashBuckets)
Definition: TpiHashing.h:60
static std::string utohexstr(uint64_t X, bool LowerCase=false)
Definition: StringExtras.h:48
Lightweight error class with error context and mandatory checking.
Error visitKnownRecord(codeview::CVType &CVR, codeview::UdtSourceLineRecord &Rec) override
Definition: TpiHashing.cpp:72