From: Rui Ueyama Date: Mon, 20 Jun 2016 07:31:29 +0000 (+0000) Subject: [codeview] Add an extra check for TPI hash values. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a94acfea8bfd6eb6b5809dd40f03e1fa42e673a;p=llvm [codeview] Add an extra check for TPI hash values. This patch adds a function that corresponds to `fUDTAnon` and use that to compute TPI hash values as the reference does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273139 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 00ff6e445f7..feb6f2b88d1 100644 --- a/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -64,6 +64,13 @@ TpiStream::TpiStream(const PDBFile &File, TpiStream::~TpiStream() {} +// Corresponds to `fUDTAnon`. +template static bool isAnonymous(T &Rec) { + StringRef Name = Rec.getUniqueName(); + return Name == "" || Name == "__unnamed" || + Name.endswith("::") || Name.endswith("::__unnamed"); +} + // Computes a hash for a given TPI record. template static uint32_t getTpiHash(T &Rec, const CVRecord &RawRec) { @@ -73,10 +80,11 @@ static uint32_t getTpiHash(T &Rec, const CVRecord &RawRec) { Opts & static_cast(ClassOptions::ForwardReference); bool Scoped = Opts & static_cast(ClassOptions::Scoped); bool UniqueName = Opts & static_cast(ClassOptions::HasUniqueName); + bool IsAnon = UniqueName && isAnonymous(Rec); - if (!ForwardRef && !Scoped) + if (!ForwardRef && !Scoped && !IsAnon) return hashStringV1(Rec.getName()); - if (!ForwardRef && UniqueName) + if (!ForwardRef && UniqueName && !IsAnon) return hashStringV1(Rec.getUniqueName()); return hashBufferV8(RawRec.RawData); }