From 5c7c2307a83665c4861e173a8f4ec4f514c0bbd6 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 1 Sep 2016 18:08:19 +0000 Subject: [PATCH] [codeview] Properly propagate the TypeLeafKind through the pipeline. llvm-svn: 280388 --- .../CodeView/TypeVisitorCallbackPipeline.h | 15 ++++++++++----- llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h b/llvm/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h index d158f42947c9..e60423360696 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h @@ -42,14 +42,19 @@ public: virtual Expected visitTypeBegin(const CVRecord &Record) override { - TypeLeafKind Kind = Record.Type; + // An implementation can calculate of visitTypeBegin() can calculate the + // kind based on an arbitrary factor, including the Type that is already + // specified in the Record. So, as we go through the pipeline invoking + // each visitor, update the state in a copy of the record so that each + // visitor in the pipeline sees the most recently value of the type. + CVRecord RecordCopy = Record; for (auto Visitor : Pipeline) { - if (auto ExpectedKind = Visitor->visitTypeBegin(Record)) - Kind = *ExpectedKind; - else + if (auto ExpectedKind = Visitor->visitTypeBegin(RecordCopy)) { + RecordCopy.Type = *ExpectedKind; + } else return ExpectedKind.takeError(); } - return Kind; + return RecordCopy.Type; } virtual Error visitTypeEnd(const CVRecord &Record) override { for (auto Visitor : Pipeline) { diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 7154b297b124..6214e633b740 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -124,13 +124,13 @@ public: Expected visitTypeBegin(const CVRecord &Rec) override { ++Index; - RawRecord = &Rec; + RawRecord = Rec; return Rec.Type; } private: template Error verify(T &Rec) { - uint32_t Hash = getTpiHash(Rec, *RawRecord); + uint32_t Hash = getTpiHash(Rec, RawRecord); if (Hash % NumHashBuckets != HashValues[Index]) return errorInvalidHash(); return Error::success(); @@ -152,7 +152,7 @@ private: } FixedStreamArray HashValues; - const CVRecord *RawRecord; + CVRecord RawRecord; uint32_t NumHashBuckets; uint32_t Index = -1; };