[llvm] r280388 - [codeview] Properly propagate the TypeLeafKind through the pipeline.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 11:08:20 PDT 2016


Author: zturner
Date: Thu Sep  1 13:08:19 2016
New Revision: 280388

URL: http://llvm.org/viewvc/llvm-project?rev=280388&view=rev
Log:
[codeview] Properly propagate the TypeLeafKind through the pipeline.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h
    llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h?rev=280388&r1=280387&r2=280388&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h Thu Sep  1 13:08:19 2016
@@ -42,14 +42,19 @@ public:
 
   virtual Expected<TypeLeafKind>
   visitTypeBegin(const CVRecord<TypeLeafKind> &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<TypeLeafKind> 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<TypeLeafKind> &Record) override {
     for (auto Visitor : Pipeline) {

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=280388&r1=280387&r2=280388&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Thu Sep  1 13:08:19 2016
@@ -124,13 +124,13 @@ public:
   Expected<TypeLeafKind>
   visitTypeBegin(const CVRecord<TypeLeafKind> &Rec) override {
     ++Index;
-    RawRecord = &Rec;
+    RawRecord = Rec;
     return Rec.Type;
   }
 
 private:
   template <typename T> 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<support::ulittle32_t> HashValues;
-  const CVRecord<TypeLeafKind> *RawRecord;
+  CVRecord<TypeLeafKind> RawRecord;
   uint32_t NumHashBuckets;
   uint32_t Index = -1;
 };




More information about the llvm-commits mailing list