diff options
author | Rui Ueyama <ruiu@google.com> | 2016-06-16 18:39:17 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-06-16 18:39:17 +0000 |
commit | 74c4341dde8ac1c537b0950521953373cf3a506f (patch) | |
tree | 94ff6d2d059586e75289f52634cf7f66c2ff7576 | |
parent | 01ee3dae043e305adaf2f8b46dffdbfe901ce24e (diff) | |
download | bcm5719-llvm-74c4341dde8ac1c537b0950521953373cf3a506f.tar.gz bcm5719-llvm-74c4341dde8ac1c537b0950521953373cf3a506f.zip |
[codeview] Use hashBufferV8 to verify all type records.
Differential Revision: http://reviews.llvm.org/D21393
llvm-svn: 272930
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 46717f23a63..00ff6e445f7 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -65,22 +65,20 @@ TpiStream::TpiStream(const PDBFile &File, TpiStream::~TpiStream() {} // Computes a hash for a given TPI record. -template <typename T> static uint32_t getTpiHash(T &Rec) { +template <typename T> +static uint32_t getTpiHash(T &Rec, const CVRecord<TypeLeafKind> &RawRec) { auto Opts = static_cast<uint16_t>(Rec.getOptions()); - // We don't know how to calculate a hash value for this yet. - // Currently we just skip it. - if (Opts & static_cast<uint16_t>(ClassOptions::ForwardReference)) - return 0; + bool ForwardRef = + Opts & static_cast<uint16_t>(ClassOptions::ForwardReference); + bool Scoped = Opts & static_cast<uint16_t>(ClassOptions::Scoped); + bool UniqueName = Opts & static_cast<uint16_t>(ClassOptions::HasUniqueName); - if (!(Opts & static_cast<uint16_t>(ClassOptions::Scoped))) + if (!ForwardRef && !Scoped) return hashStringV1(Rec.getName()); - - if (Opts & static_cast<uint16_t>(ClassOptions::HasUniqueName)) + if (!ForwardRef && UniqueName) return hashStringV1(Rec.getUniqueName()); - - // This case is not implemented yet. - return 0; + return hashBufferV8(RawRec.RawData); } namespace { @@ -102,15 +100,16 @@ public: Error visitEnum(EnumRecord &Rec) override { return verify(Rec); } Error visitUnion(UnionRecord &Rec) override { return verify(Rec); } - Error visitTypeEnd(const CVRecord<TypeLeafKind> &Record) override { + Error visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) override { ++Index; + RawRecord = &Rec; return Error::success(); } private: template <typename T> Error verify(T &Rec) { - uint32_t Hash = getTpiHash(Rec); - if (Hash && Hash % NumHashBuckets != HashValues[Index]) + uint32_t Hash = getTpiHash(Rec, *RawRecord); + if (Hash % NumHashBuckets != HashValues[Index]) return make_error<RawError>(raw_error_code::invalid_tpi_hash); return Error::success(); } @@ -125,8 +124,9 @@ private: } FixedStreamArray<support::ulittle32_t> HashValues; + const CVRecord<TypeLeafKind> *RawRecord; uint32_t NumHashBuckets; - uint32_t Index = 0; + uint32_t Index = -1; }; } |