<div dir="ltr">I'm getting an unused private member warning on the string table in <span style="font-size:12.8px">ModuleDebugInlineeLinesFragmen</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">t. Can you take a look?</span></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Wed, May 3, 2017 at 10:11 AM, Zachary Turner via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: zturner<br>
Date: Wed May  3 12:11:40 2017<br>
New Revision: 302053<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302053&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=302053&view=rev</a><br>
Log:<br>
[CodeView] Use actual strings for dealing with checksums and lines.<br>
<br>
The raw CodeView format references strings by "offsets", but it's<br>
confusing what table the offset refers to.  In the case of line<br>
number information, it's an offset into a buffer of records,<br>
and an indirection is required to get another offset into a<br>
different table to find the final string.  And in the case of<br>
checksum information, there is no indirection, and the offset<br>
refers directly to the location of the string in another buffer.<br>
<br>
This would be less confusing if we always just referred to the<br>
strings by their value, and have the library be smart enough<br>
to correctly resolve the offsets on its own from the right<br>
location.<br>
<br>
This patch makes that possible.  When either reading or writing,<br>
all the user deals with are strings, and the library does the<br>
appropriate translations behind the scenes.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>StringTable.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>PDBStringTableBuilder.h<br>
    llvm/trunk/include/llvm/<wbr>Support/BinaryStreamArray.h<br>
    llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.cpp<br>
    llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.cpp<br>
    llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugLineFragment.cpp<br>
    llvm/trunk/lib/DebugInfo/<wbr>CodeView/StringTable.cpp<br>
    llvm/trunk/tools/llvm-pdbdump/<wbr>llvm-pdbdump.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h?rev=302053&r1=302052&r2=<wbr>302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h Wed May  3 12:11:40 2017<br>
@@ -21,6 +21,8 @@<br>
 namespace llvm {<br>
 namespace codeview {<br>
<br>
+class StringTable;<br>
+<br>
 struct FileChecksumEntry {<br>
   uint32_t FileNameOffset;    // Byte offset of filename in global stringtable.<br>
   FileChecksumKind Kind;      // The type of checksum.<br>
@@ -66,20 +68,22 @@ private:<br>
<br>
 class ModuleDebugFileChecksumFragmen<wbr>t final : public ModuleDebugFragment {<br>
 public:<br>
-  ModuleDebugFileChecksumFragmen<wbr>t();<br>
+  explicit ModuleDebugFileChecksumFragmen<wbr>t(StringTable &Strings);<br>
<br>
   static bool classof(const ModuleDebugFragment *S) {<br>
     return S->kind() == ModuleDebugFragmentKind::<wbr>FileChecksums;<br>
   }<br>
<br>
-  void addChecksum(uint32_t StringTableOffset, FileChecksumKind Kind,<br>
+  void addChecksum(StringRef FileName, FileChecksumKind Kind,<br>
                    ArrayRef<uint8_t> Bytes);<br>
<br>
   uint32_t calculateSerializedLength() override;<br>
   Error commit(BinaryStreamWriter &Writer) override;<br>
-  uint32_t mapChecksumOffset(uint32_t StringTableOffset) const;<br>
+  uint32_t mapChecksumOffset(StringRef FileName) const;<br>
<br>
 private:<br>
+  StringTable &Strings;<br>
+<br>
   DenseMap<uint32_t, uint32_t> OffsetMap;<br>
   uint32_t SerializedSize = 0;<br>
   llvm::BumpPtrAllocator Storage;<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h?rev=302053&r1=302052&r2=<wbr>302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h Wed May  3 12:11:40 2017<br>
@@ -20,6 +20,8 @@ namespace llvm {<br>
 namespace codeview {<br>
<br>
 class ModuleDebugInlineeLineFragment<wbr>Ref;<br>
+class ModuleDebugFileChecksumFragmen<wbr>t;<br>
+class StringTable;<br>
<br>
 enum class InlineeLinesSignature : uint32_t {<br>
   Normal,    // CV_INLINEE_SOURCE_LINE_<wbr>SIGNATURE<br>
@@ -73,7 +75,8 @@ private:<br>
<br>
 class ModuleDebugInlineeLineFragment final : public ModuleDebugFragment {<br>
 public:<br>
-  explicit ModuleDebugInlineeLineFragment<wbr>(bool HasExtraFiles);<br>
+  ModuleDebugInlineeLineFragment<wbr>(<wbr>ModuleDebugFileChecksumFragmen<wbr>t &Checksums,<br>
+                                 StringTable &Strings, bool HasExtraFiles);<br>
<br>
   static bool classof(const ModuleDebugFragment *S) {<br>
     return S->kind() == ModuleDebugFragmentKind::<wbr>InlineeLines;<br>
@@ -82,11 +85,13 @@ public:<br>
   Error commit(BinaryStreamWriter &Writer) override;<br>
   uint32_t calculateSerializedLength() override;<br>
<br>
-  void addInlineSite(TypeIndex FuncId, uint32_t FileOffset,<br>
-                     uint32_t SourceLine);<br>
-  void addExtraFile(uint32_t FileOffset);<br>
+  void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);<br>
+  void addExtraFile(StringRef FileName);<br>
<br>
 private:<br>
+  ModuleDebugFileChecksumFragmen<wbr>t &Checksums;<br>
+  StringTable &Strings;<br>
+<br>
   bool HasExtraFiles = false;<br>
   uint32_t ExtraFileCount = 0;<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h?rev=<wbr>302053&r1=302052&r2=302053&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h Wed May  3 12:11:40 2017<br>
@@ -19,6 +19,9 @@<br>
 namespace llvm {<br>
 namespace codeview {<br>
<br>
+class ModuleDebugFileChecksumFragmen<wbr>t;<br>
+class StringTable;<br>
+<br>
 // Corresponds to the `CV_DebugSLinesHeader_t` structure.<br>
 struct LineFragmentHeader {<br>
   support::ulittle32_t RelocOffset;  // Code offset of line contribution.<br>
@@ -104,13 +107,14 @@ class ModuleDebugLineFragment final : pu<br>
   };<br>
<br>
 public:<br>
-  ModuleDebugLineFragment();<br>
+  ModuleDebugLineFragment(<wbr>ModuleDebugFileChecksumFragmen<wbr>t &Checksums,<br>
+                          StringTable &Strings);<br>
<br>
   static bool classof(const ModuleDebugFragment *S) {<br>
     return S->kind() == ModuleDebugFragmentKind::<wbr>Lines;<br>
   }<br>
<br>
-  void createBlock(uint32_t ChecksumBufferOffset);<br>
+  void createBlock(StringRef FileName);<br>
   void addLineInfo(uint32_t Offset, const LineInfo &Line);<br>
   void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line,<br>
                             uint32_t ColStart, uint32_t ColEnd);<br>
@@ -125,6 +129,9 @@ public:<br>
   bool hasColumnInfo() const;<br>
<br>
 private:<br>
+  ModuleDebugFileChecksumFragmen<wbr>t &Checksums;<br>
+  StringTable &Strings;<br>
+<br>
   uint16_t RelocOffset = 0;<br>
   uint16_t RelocSegment = 0;<br>
   uint32_t CodeSize = 0;<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>StringTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StringTable.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/CodeView/<wbr>StringTable.h?rev=302053&r1=<wbr>302052&r2=302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>StringTable.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/CodeView/<wbr>StringTable.h Wed May  3 12:11:40 2017<br>
@@ -53,6 +53,9 @@ public:<br>
   // Returns the ID for S.<br>
   uint32_t insert(StringRef S);<br>
<br>
+  // Return the ID for string S.  Assumes S exists in the table.<br>
+  uint32_t getStringId(StringRef S) const;<br>
+<br>
   uint32_t calculateSerializedSize() const;<br>
   Error commit(BinaryStreamWriter &Writer) const;<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>PDBStringTableBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/PDB/Native/<wbr>PDBStringTableBuilder.h?rev=<wbr>302053&r1=302052&r2=302053&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>PDBStringTableBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>PDBStringTableBuilder.h Wed May  3 12:11:40 2017<br>
@@ -41,6 +41,9 @@ public:<br>
   uint32_t calculateSerializedSize() const;<br>
   Error commit(BinaryStreamWriter &Writer) const;<br>
<br>
+  codeview::StringTable &getStrings() { return Strings; }<br>
+  const codeview::StringTable &getStrings() const { return Strings; }<br>
+<br>
 private:<br>
   uint32_t calculateHashTableSize() const;<br>
   Error writeHeader(BinaryStreamWriter &Writer) const;<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>Support/BinaryStreamArray.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/BinaryStreamArray.h?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Support/<wbr>BinaryStreamArray.h?rev=<wbr>302053&r1=302052&r2=302053&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>Support/BinaryStreamArray.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>Support/BinaryStreamArray.h Wed May  3 12:11:40 2017<br>
@@ -223,6 +223,8 @@ public:<br>
     return Iterator(*this, Ctx, Stream, HadError);<br>
   }<br>
<br>
+  bool valid() const { return Stream.valid(); }<br>
+<br>
   Iterator end() const { return Iterator(Ctx); }<br>
<br>
   bool empty() const { return Stream.getLength() == 0; }<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.cpp?rev=302053&r1=302052&r2=<wbr>302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.cpp Wed May  3 12:11:40 2017<br>
@@ -10,6 +10,7 @@<br>
 #include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h"<br>
<br>
 #include "llvm/DebugInfo/CodeView/<wbr>CodeViewError.h"<br>
+#include "llvm/DebugInfo/CodeView/<wbr>StringTable.h"<br>
 #include "llvm/Support/<wbr>BinaryStreamReader.h"<br>
<br>
 using namespace llvm;<br>
@@ -49,10 +50,12 @@ Error ModuleDebugFileChecksumFragmen<wbr>tRef<br>
   return Error::success();<br>
 }<br>
<br>
-<wbr>ModuleDebugFileChecksumFragmen<wbr>t::<wbr>ModuleDebugFileChecksumFragmen<wbr>t()<br>
-    : ModuleDebugFragment(<wbr>ModuleDebugFragmentKind::<wbr>FileChecksums) {}<br>
+<wbr>ModuleDebugFileChecksumFragmen<wbr>t::<wbr>ModuleDebugFileChecksumFragmen<wbr>t(<br>
+    StringTable &Strings)<br>
+    : ModuleDebugFragment(<wbr>ModuleDebugFragmentKind::<wbr>FileChecksums),<br>
+      Strings(Strings) {}<br>
<br>
-void ModuleDebugFileChecksumFragmen<wbr>t::addChecksum(uint32_t StringTableOffset,<br>
+void ModuleDebugFileChecksumFragmen<wbr>t::addChecksum(StringRef FileName,<br>
                                                   FileChecksumKind Kind,<br>
                                                   ArrayRef<uint8_t> Bytes) {<br>
   FileChecksumEntry Entry;<br>
@@ -61,13 +64,14 @@ void ModuleDebugFileChecksumFragmen<wbr>t::ad<br>
     ::memcpy(Copy, Bytes.data(), Bytes.size());<br>
     Entry.Checksum = makeArrayRef(Copy, Bytes.size());<br>
   }<br>
-  Entry.FileNameOffset = StringTableOffset;<br>
+<br>
+  Entry.FileNameOffset = Strings.insert(FileName);<br>
   Entry.Kind = Kind;<br>
   Checksums.push_back(Entry);<br>
<br>
   // This maps the offset of this string in the string table to the offset<br>
   // of this checksum entry in the checksum buffer.<br>
-  OffsetMap[StringTableOffset] = SerializedSize;<br>
+  OffsetMap[Entry.<wbr>FileNameOffset] = SerializedSize;<br>
   assert(SerializedSize % 4 == 0);<br>
<br>
   uint32_t Len = alignTo(sizeof(<wbr>FileChecksumEntryHeader) + Bytes.size(), 4);<br>
@@ -94,9 +98,10 @@ Error ModuleDebugFileChecksumFragmen<wbr>t::c<br>
   return Error::success();<br>
 }<br>
<br>
-uint32_t ModuleDebugFileChecksumFragmen<wbr>t::mapChecksumOffset(<br>
-    uint32_t StringTableOffset) const {<br>
-  auto Iter = OffsetMap.find(<wbr>StringTableOffset);<br>
+uint32_t<br>
+<wbr>ModuleDebugFileChecksumFragmen<wbr>t::mapChecksumOffset(StringRef FileName) const {<br>
+  uint32_t Offset = Strings.getStringId(FileName);<br>
+  auto Iter = OffsetMap.find(Offset);<br>
   assert(Iter != OffsetMap.end());<br>
   return Iter->second;<br>
 }<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.cpp?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.cpp?rev=302053&r1=302052&r2=<wbr>302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.cpp Wed May  3 12:11:40 2017<br>
@@ -10,7 +10,9 @@<br>
 #include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugInlineeLinesFragmen<wbr>t.h"<br>
<br>
 #include "llvm/DebugInfo/CodeView/<wbr>CodeViewError.h"<br>
+#include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h"<br>
 #include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugFragmentRecord.h"<br>
+#include "llvm/DebugInfo/CodeView/<wbr>StringTable.h"<br>
<br>
 using namespace llvm;<br>
 using namespace llvm::codeview;<br>
@@ -55,9 +57,10 @@ bool ModuleDebugInlineeLineFragment<wbr>Ref::<br>
 }<br>
<br>
 ModuleDebugInlineeLineFragment<wbr>::<wbr>ModuleDebugInlineeLineFragment<wbr>(<br>
+    ModuleDebugFileChecksumFragmen<wbr>t &Checksums, StringTable &Strings,<br>
     bool HasExtraFiles)<br>
     : ModuleDebugFragment(<wbr>ModuleDebugFragmentKind::<wbr>InlineeLines),<br>
-      HasExtraFiles(HasExtraFiles) {}<br>
+      Checksums(Checksums), Strings(Strings), HasExtraFiles(HasExtraFiles) {}<br>
<br>
 uint32_t ModuleDebugInlineeLineFragment<wbr>::calculateSerializedLength() {<br>
   // 4 bytes for the signature<br>
@@ -100,18 +103,22 @@ Error ModuleDebugInlineeLineFragment<wbr>::co<br>
   return Error::success();<br>
 }<br>
<br>
-void ModuleDebugInlineeLineFragment<wbr>::addExtraFile(uint32_t FileOffset) {<br>
+void ModuleDebugInlineeLineFragment<wbr>::addExtraFile(StringRef FileName) {<br>
+  uint32_t Offset = Checksums.mapChecksumOffset(<wbr>FileName);<br>
+<br>
   auto &Entry = Entries.back();<br>
-  Entry.ExtraFiles.push_back(<wbr>ulittle32_t(FileOffset));<br>
+  Entry.ExtraFiles.push_back(<wbr>ulittle32_t(Offset));<br>
   ++ExtraFileCount;<br>
 }<br>
<br>
 void ModuleDebugInlineeLineFragment<wbr>::addInlineSite(TypeIndex FuncId,<br>
-                                                   uint32_t FileOffset,<br>
+                                                   StringRef FileName,<br>
                                                    uint32_t SourceLine) {<br>
+  uint32_t Offset = Checksums.mapChecksumOffset(<wbr>FileName);<br>
+<br>
   Entries.emplace_back();<br>
   auto &Entry = Entries.back();<br>
-  Entry.Header.FileID = FileOffset;<br>
+  Entry.Header.FileID = Offset;<br>
   Entry.Header.SourceLineNum = SourceLine;<br>
   Entry.Header.Inlinee = FuncId;<br>
 }<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugLineFragment.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.cpp?<wbr>rev=302053&r1=302052&r2=<wbr>302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugLineFragment.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/<wbr>CodeView/<wbr>ModuleDebugLineFragment.cpp Wed May  3 12:11:40 2017<br>
@@ -10,7 +10,9 @@<br>
 #include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugLineFragment.h"<br>
<br>
 #include "llvm/DebugInfo/CodeView/<wbr>CodeViewError.h"<br>
+#include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugFileChecksumFragmen<wbr>t.h"<br>
 #include "llvm/DebugInfo/CodeView/<wbr>ModuleDebugFragmentRecord.h"<br>
+#include "llvm/DebugInfo/CodeView/<wbr>StringTable.h"<br>
<br>
 using namespace llvm;<br>
 using namespace llvm::codeview;<br>
@@ -65,11 +67,15 @@ bool ModuleDebugLineFragmentRef::<wbr>hasColu<br>
   return !!(Header->Flags & LF_HaveColumns);<br>
 }<br>
<br>
-ModuleDebugLineFragment::<wbr>ModuleDebugLineFragment()<br>
-    : ModuleDebugFragment(<wbr>ModuleDebugFragmentKind::<wbr>Lines) {}<br>
+ModuleDebugLineFragment::<wbr>ModuleDebugLineFragment(<br>
+    ModuleDebugFileChecksumFragmen<wbr>t &Checksums, StringTable &Strings)<br>
+    : ModuleDebugFragment(<wbr>ModuleDebugFragmentKind::<wbr>Lines), Checksums(Checksums),<br>
+      Strings(Strings) {}<br>
<br>
-void ModuleDebugLineFragment::<wbr>createBlock(uint32_t ChecksumBufferOffset) {<br>
-  Blocks.emplace_back(<wbr>ChecksumBufferOffset);<br>
+void ModuleDebugLineFragment::<wbr>createBlock(StringRef FileName) {<br>
+  uint32_t Offset = Checksums.mapChecksumOffset(<wbr>FileName);<br>
+<br>
+  Blocks.emplace_back(Offset);<br>
 }<br>
<br>
 void ModuleDebugLineFragment::<wbr>addLineInfo(uint32_t Offset,<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/<wbr>CodeView/StringTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StringTable.cpp?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/CodeView/<wbr>StringTable.cpp?rev=302053&r1=<wbr>302052&r2=302053&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/<wbr>CodeView/StringTable.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/<wbr>CodeView/StringTable.cpp Wed May  3 12:11:40 2017<br>
@@ -63,3 +63,9 @@ Error StringTable::commit(<wbr>BinaryStreamWr<br>
 }<br>
<br>
 uint32_t StringTable::size() const { return Strings.size(); }<br>
+<br>
+uint32_t StringTable::getStringId(<wbr>StringRef S) const {<br>
+  auto P = Strings.find(S);<br>
+  assert(P != Strings.end());<br>
+  return P->second;<br>
+}<br>
<br>
Modified: llvm/trunk/tools/llvm-pdbdump/<wbr>llvm-pdbdump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=302053&r1=302052&r2=302053&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/tools/llvm-<wbr>pdbdump/llvm-pdbdump.cpp?rev=<wbr>302053&r1=302052&r2=302053&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/tools/llvm-pdbdump/<wbr>llvm-pdbdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-pdbdump/<wbr>llvm-pdbdump.cpp Wed May  3 12:11:40 2017<br>
@@ -424,21 +424,6 @@ cl::list<std::string> InputFilename(cl::<br>
<br>
 static ExitOnError ExitOnErr;<br>
<br>
-static uint32_t<br>
-getFileChecksumOffset(<wbr>StringRef FileName,<br>
-                      ModuleDebugFileChecksumFragmen<wbr>t &Checksums,<br>
-                      PDBStringTableBuilder &Strings) {<br>
-  // The offset in the line info record is the offset of the checksum<br>
-  // entry for the corresponding file.  That entry then contains an<br>
-  // offset into the global string table of the file name.  So to<br>
-  // compute the proper offset to write into the line info record, we<br>
-  // must first get its offset in the global string table, then ask the<br>
-  // checksum builder to find the offset in its serialized buffer that<br>
-  // it mapped that filename string table offset to.<br>
-  uint32_t StringOffset = Strings.insert(FileName);<br>
-  return Checksums.mapChecksumOffset(<wbr>StringOffset);<br>
-}<br>
-<br>
 static void yamlToPdb(StringRef Path) {<br>
   BumpPtrAllocator Allocator;<br>
   ErrorOr<std::unique_ptr<<wbr>MemoryBuffer>> ErrorOrBuffer =<br>
@@ -490,6 +475,8 @@ static void yamlToPdb(StringRef Path) {<br>
   for (auto F : Info.Features)<br>
     InfoBuilder.addFeature(F);<br>
<br>
+  auto &Strings = Builder.getStringTableBuilder(<wbr>).getStrings();<br>
+<br>
   const auto &Dbi = YamlObj.DbiStream.getValueOr(<wbr>DefaultDbiStream);<br>
   auto &DbiBuilder = Builder.getDbiBuilder();<br>
   DbiBuilder.setAge(Dbi.Age);<br>
@@ -516,35 +503,24 @@ static void yamlToPdb(StringRef Path) {<br>
       // File Checksums must be emitted before line information, because line<br>
       // info records use offsets into the checksum buffer to reference a file's<br>
       // source file name.<br>
-      auto Checksums = llvm::make_unique<<wbr>ModuleDebugFileChecksumFragmen<wbr>t>();<br>
+      auto Checksums =<br>
+          llvm::make_unique<<wbr>ModuleDebugFileChecksumFragmen<wbr>t>(Strings);<br>
       auto &ChecksumRef = *Checksums;<br>
       if (!FLI.FileChecksums.empty()) {<br>
-        auto &Strings = Builder.getStringTableBuilder(<wbr>);<br>
-        for (auto &FC : FLI.FileChecksums) {<br>
-          uint32_t STOffset = Strings.insert(FC.FileName);<br>
-          Checksums->addChecksum(<wbr>STOffset, FC.Kind, FC.ChecksumBytes.Bytes);<br>
-        }<br>
+        for (auto &FC : FLI.FileChecksums)<br>
+          Checksums->addChecksum(FC.<wbr>FileName, FC.Kind, FC.ChecksumBytes.Bytes);<br>
       }<br>
       ModiBuilder.<wbr>setC13FileChecksums(std::move(<wbr>Checksums));<br>
<br>
-      // FIXME: StringTable / StringTableBuilder should really be in<br>
-      // DebugInfoCodeView.  This would allow us to construct the<br>
-      // ModuleDebugLineFragment with a reference to the string table,<br>
-      // and we could just pass strings around rather than having to<br>
-      // remember how to calculate the right offset.<br>
-      auto &Strings = Builder.getStringTableBuilder(<wbr>);<br>
-<br>
       for (const auto &Fragment : FLI.LineFragments) {<br>
-        auto Lines = llvm::make_unique<<wbr>ModuleDebugLineFragment>();<br>
+        auto Lines =<br>
+            llvm::make_unique<<wbr>ModuleDebugLineFragment>(<wbr>ChecksumRef, Strings);<br>
         Lines->setCodeSize(Fragment.<wbr>CodeSize);<br>
         Lines->setRelocationAddress(<wbr>Fragment.RelocSegment,<br>
                                     Fragment.RelocOffset);<br>
         Lines->setFlags(Fragment.<wbr>Flags);<br>
         for (const auto &LC : Fragment.Blocks) {<br>
-          uint32_t ChecksumOffset =<br>
-              getFileChecksumOffset(LC.<wbr>FileName, ChecksumRef, Strings);<br>
-<br>
-          Lines->createBlock(<wbr>ChecksumOffset);<br>
+          Lines->createBlock(LC.<wbr>FileName);<br>
           if (Lines->hasColumnInfo()) {<br>
             for (const auto &Item : zip(LC.Lines, LC.Columns)) {<br>
               auto &L = std::get<0>(Item);<br>
@@ -567,18 +543,15 @@ static void yamlToPdb(StringRef Path) {<br>
<br>
       for (const auto &Inlinee : FLI.Inlinees) {<br>
         auto Inlinees = llvm::make_unique<<wbr>ModuleDebugInlineeLineFragment<wbr>>(<br>
-            Inlinee.HasExtraFiles);<br>
+            ChecksumRef, Strings, Inlinee.HasExtraFiles);<br>
         for (const auto &Site : Inlinee.Sites) {<br>
-          uint32_t FileOff =<br>
-              getFileChecksumOffset(Site.<wbr>FileName, ChecksumRef, Strings);<br>
-<br>
-          Inlinees->addInlineSite(Site.<wbr>Inlinee, FileOff, Site.SourceLineNum);<br>
+          Inlinees->addInlineSite(Site.<wbr>Inlinee, Site.FileName,<br>
+                                  Site.SourceLineNum);<br>
           if (!Inlinee.HasExtraFiles)<br>
             continue;<br>
<br>
           for (auto EF : Site.ExtraFiles) {<br>
-            FileOff = getFileChecksumOffset(EF, ChecksumRef, Strings);<br>
-            Inlinees->addExtraFile(<wbr>FileOff);<br>
+            Inlinees->addExtraFile(EF);<br>
           }<br>
         }<br>
         ModiBuilder.addC13Fragment(<wbr>std::move(Inlinees));<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>