Hmm, it's probably not needed and I suppose it got added as boilerplate when i was creating new files but didn't remove it when it turned out the contents were empty.<br><br>Feel free to remove, or I'll be in in a few hours and i can do it.<br><div class="gmail_quote"><div dir="ltr">On Tue, May 9, 2017 at 7:20 AM Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Apr 27, 2017 at 12:12 PM, Zachary Turner via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: zturner<br>
> Date: Thu Apr 27 11:12:16 2017<br>
> New Revision: 301557<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=301557&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=301557&view=rev</a><br>
> Log:<br>
> [CodeView] Isolate Debug Info Fragments into standalone classes.<br>
><br>
> Previously parsing of these were all grouped together into a<br>
> single master class that could parse any type of debug info<br>
> fragment.<br>
><br>
> With writing forthcoming, the complexity of each individual<br>
> fragment is enough to warrant them having their own classes so<br>
> that reading and writing of each fragment type can be grouped<br>
> together, but isolated from the code for reading and writing<br>
> other fragment types.<br>
><br>
> In doing so, I found a place where parsing code was duplicated<br>
> for the FileChecksums fragment, across llvm-readobj and the<br>
> CodeView library, and one of the implementations had a bug.<br>
> Now that the codepaths are merged, the bug is resolved.<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D32547" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32547</a><br>
><br>
> Added:<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp<br>
> Modified:<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h<br>
>     llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h<br>
>     llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h<br>
>     llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp<br>
>     llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp<br>
>     llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp<br>
>     llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp<br>
>     llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp<br>
>     llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h Thu Apr 27 11:12:16 2017<br>
> @@ -141,13 +141,6 @@ struct InlineeSourceLine {<br>
>    //   ulittle32_t Files[];<br>
>  };<br>
><br>
> -struct FileChecksum {<br>
> -  ulittle32_t FileNameOffset; // Byte offset of filename in global string table.<br>
> -  uint8_t ChecksumSize;       // Number of bytes of checksum.<br>
> -  uint8_t ChecksumKind;       // FileChecksumKind<br>
> -  // Checksum bytes follow.<br>
> -};<br>
> -<br>
>  } // namespace codeview<br>
>  } // namespace llvm<br>
><br>
><br>
> Added: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h (added)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,65 @@<br>
> +//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H<br>
> +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H<br>
> +<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
> +#include "llvm/Support/BinaryStreamArray.h"<br>
> +#include "llvm/Support/BinaryStreamReader.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +<br>
> +struct FileChecksumEntry {<br>
> +  uint32_t FileNameOffset;    // Byte offset of filename in global stringtable.<br>
> +  FileChecksumKind Kind;      // The type of checksum.<br>
> +  ArrayRef<uint8_t> Checksum; // The bytes of the checksum.<br>
> +};<br>
> +}<br>
> +}<br>
> +<br>
> +namespace llvm {<br>
> +template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {<br>
> +public:<br>
> +  typedef void ContextType;<br>
> +<br>
> +  static Error extract(BinaryStreamRef Stream, uint32_t &Len,<br>
> +                       codeview::FileChecksumEntry &Item, void *Ctx);<br>
> +};<br>
> +}<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment {<br>
> +  typedef VarStreamArray<FileChecksumEntry> FileChecksumArray;<br>
> +  typedef FileChecksumArray::Iterator Iterator;<br>
> +<br>
> +public:<br>
> +  ModuleDebugFileChecksumFragment()<br>
> +      : ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {}<br>
> +<br>
> +  static bool classof(const ModuleDebugFragment *S) {<br>
> +    return S->kind() == ModuleDebugFragmentKind::FileChecksums;<br>
> +  }<br>
> +<br>
> +  Error initialize(BinaryStreamReader Reader);<br>
> +<br>
> +  Iterator begin() const { return Checksums.begin(); }<br>
> +  Iterator end() const { return Checksums.end(); }<br>
> +<br>
> +private:<br>
> +  FileChecksumArray Checksums;<br>
> +};<br>
> +}<br>
> +}<br>
> +<br>
> +#endif<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h Thu Apr 27 11:12:16 2017<br>
> @@ -11,79 +11,23 @@<br>
>  #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H<br>
><br>
>  #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> -#include "llvm/Support/BinaryStreamArray.h"<br>
> -#include "llvm/Support/BinaryStreamRef.h"<br>
> -#include "llvm/Support/Endian.h"<br>
> -#include "llvm/Support/Error.h"<br>
> +#include "llvm/Support/Casting.h"<br>
><br>
>  namespace llvm {<br>
>  namespace codeview {<br>
><br>
> -// Corresponds to the `CV_DebugSSubsectionHeader_t` structure.<br>
> -struct ModuleDebugFragmentHeader {<br>
> -  support::ulittle32_t Kind;   // codeview::ModuleDebugFragmentKind enum<br>
> -  support::ulittle32_t Length; // number of bytes occupied by this record.<br>
> -};<br>
> -<br>
> -// Corresponds to the `CV_DebugSLinesHeader_t` structure.<br>
> -struct LineFragmentHeader {<br>
> -  support::ulittle32_t RelocOffset;  // Code offset of line contribution.<br>
> -  support::ulittle16_t RelocSegment; // Code segment of line contribution.<br>
> -  support::ulittle16_t Flags;        // See LineFlags enumeration.<br>
> -  support::ulittle32_t CodeSize;     // Code size of this line contribution.<br>
> -};<br>
> -<br>
> -// Corresponds to the `CV_DebugSLinesFileBlockHeader_t` structure.<br>
> -struct LineBlockFragmentHeader {<br>
> -  support::ulittle32_t NameIndex; // Index in DBI name buffer of filename.<br>
> -  support::ulittle32_t NumLines;  // Number of lines<br>
> -  support::ulittle32_t BlockSize; // Code size of block, in bytes.<br>
> -  // The following two variable length arrays appear immediately after the<br>
> -  // header.  The structure definitions follow.<br>
> -  // LineNumberEntry   Lines[NumLines];<br>
> -  // ColumnNumberEntry Columns[NumLines];<br>
> -};<br>
> -<br>
> -// Corresponds to `CV_Line_t` structure<br>
> -struct LineNumberEntry {<br>
> -  support::ulittle32_t Offset; // Offset to start of code bytes for line number<br>
> -  support::ulittle32_t Flags;  // Start:24, End:7, IsStatement:1<br>
> -};<br>
> -<br>
> -// Corresponds to `CV_Column_t` structure<br>
> -struct ColumnNumberEntry {<br>
> -  support::ulittle16_t StartColumn;<br>
> -  support::ulittle16_t EndColumn;<br>
> -};<br>
> -<br>
>  class ModuleDebugFragment {<br>
>  public:<br>
> -  ModuleDebugFragment();<br>
> -  ModuleDebugFragment(ModuleDebugFragmentKind Kind, BinaryStreamRef Data);<br>
> -  static Error initialize(BinaryStreamRef Stream, ModuleDebugFragment &Info);<br>
> -  uint32_t getRecordLength() const;<br>
> -  ModuleDebugFragmentKind kind() const;<br>
> -  BinaryStreamRef getRecordData() const;<br>
> +  explicit ModuleDebugFragment(ModuleDebugFragmentKind Kind) : Kind(Kind) {}<br>
> +<br>
> +  virtual ~ModuleDebugFragment();<br>
> +  ModuleDebugFragmentKind kind() const { return Kind; }<br>
><br>
> -private:<br>
> +protected:<br>
>    ModuleDebugFragmentKind Kind;<br>
> -  BinaryStreamRef Data;<br>
>  };<br>
><br>
> -typedef VarStreamArray<ModuleDebugFragment> ModuleDebugFragmentArray;<br>
>  } // namespace codeview<br>
> -<br>
> -template <> struct VarStreamArrayExtractor<codeview::ModuleDebugFragment> {<br>
> -  typedef void ContextType;<br>
> -<br>
> -  static Error extract(BinaryStreamRef Stream, uint32_t &Length,<br>
> -                       codeview::ModuleDebugFragment &Info, void *Ctx) {<br>
> -    if (auto EC = codeview::ModuleDebugFragment::initialize(Stream, Info))<br>
> -      return EC;<br>
> -    Length = Info.getRecordLength();<br>
> -    return Error::success();<br>
> -  }<br>
> -};<br>
>  } // namespace llvm<br>
><br>
>  #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H<br>
><br>
> Added: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h (added)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,62 @@<br>
> +//===- ModuleDebugFragment.h ------------------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H<br>
> +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/CodeView.h"<br>
> +#include "llvm/Support/BinaryStreamArray.h"<br>
> +#include "llvm/Support/BinaryStreamRef.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +<br>
> +// Corresponds to the `CV_DebugSSubsectionHeader_t` structure.<br>
> +struct ModuleDebugFragmentHeader {<br>
> +  support::ulittle32_t Kind;   // codeview::ModuleDebugFragmentKind enum<br>
> +  support::ulittle32_t Length; // number of bytes occupied by this record.<br>
> +};<br>
> +<br>
> +class ModuleDebugFragmentRecord {<br>
> +public:<br>
> +  ModuleDebugFragmentRecord();<br>
> +  ModuleDebugFragmentRecord(ModuleDebugFragmentKind Kind, BinaryStreamRef Data);<br>
> +<br>
> +  static Error initialize(BinaryStreamRef Stream,<br>
> +                          ModuleDebugFragmentRecord &Info);<br>
> +  uint32_t getRecordLength() const;<br>
> +  ModuleDebugFragmentKind kind() const;<br>
> +  BinaryStreamRef getRecordData() const;<br>
> +<br>
> +private:<br>
> +  ModuleDebugFragmentKind Kind;<br>
> +  BinaryStreamRef Data;<br>
> +};<br>
> +<br>
> +typedef VarStreamArray<ModuleDebugFragmentRecord> ModuleDebugFragmentArray;<br>
> +<br>
> +} // namespace codeview<br>
> +<br>
> +template <><br>
> +struct VarStreamArrayExtractor<codeview::ModuleDebugFragmentRecord> {<br>
> +  typedef void ContextType;<br>
> +<br>
> +  static Error extract(BinaryStreamRef Stream, uint32_t &Length,<br>
> +                       codeview::ModuleDebugFragmentRecord &Info, void *Ctx) {<br>
> +    if (auto EC = codeview::ModuleDebugFragmentRecord::initialize(Stream, Info))<br>
> +      return EC;<br>
> +    Length = Info.getRecordLength();<br>
> +    return Error::success();<br>
> +  }<br>
> +};<br>
> +} // namespace llvm<br>
> +<br>
> +#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h Thu Apr 27 11:12:16 2017<br>
> @@ -14,7 +14,10 @@<br>
>  #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
>  #include "llvm/DebugInfo/CodeView/CodeViewError.h"<br>
>  #include "llvm/DebugInfo/CodeView/Line.h"<br>
> -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"<br>
>  #include "llvm/Support/BinaryStreamArray.h"<br>
>  #include "llvm/Support/BinaryStreamReader.h"<br>
>  #include "llvm/Support/BinaryStreamRef.h"<br>
> @@ -26,105 +29,26 @@ namespace llvm {<br>
><br>
>  namespace codeview {<br>
><br>
> -struct LineColumnEntry {<br>
> -  support::ulittle32_t NameIndex;<br>
> -  FixedStreamArray<LineNumberEntry> LineNumbers;<br>
> -  FixedStreamArray<ColumnNumberEntry> Columns;<br>
> -};<br>
> -<br>
> -struct FileChecksumEntry {<br>
> -  uint32_t FileNameOffset;    // Byte offset of filename in global stringtable.<br>
> -  FileChecksumKind Kind;      // The type of checksum.<br>
> -  ArrayRef<uint8_t> Checksum; // The bytes of the checksum.<br>
> -};<br>
> -<br>
> -typedef VarStreamArray<LineColumnEntry> LineInfoArray;<br>
> -typedef VarStreamArray<FileChecksumEntry> FileChecksumArray;<br>
> -<br>
>  class ModuleDebugFragmentVisitor {<br>
>  public:<br>
>    virtual ~ModuleDebugFragmentVisitor() = default;<br>
><br>
> -  virtual Error visitUnknown(ModuleDebugFragmentKind Kind,<br>
> -                             BinaryStreamRef Data) = 0;<br>
> -  virtual Error visitSymbols(BinaryStreamRef Data);<br>
> -  virtual Error visitLines(BinaryStreamRef Data,<br>
> -                           const LineFragmentHeader *Header,<br>
> -                           const LineInfoArray &Lines);<br>
> -  virtual Error visitStringTable(BinaryStreamRef Data);<br>
> -  virtual Error visitFileChecksums(BinaryStreamRef Data,<br>
> -                                   const FileChecksumArray &Checksums);<br>
> -  virtual Error visitFrameData(BinaryStreamRef Data);<br>
> -  virtual Error visitInlineeLines(BinaryStreamRef Data);<br>
> -  virtual Error visitCrossScopeImports(BinaryStreamRef Data);<br>
> -  virtual Error visitCrossScopeExports(BinaryStreamRef Data);<br>
> -  virtual Error visitILLines(BinaryStreamRef Data);<br>
> -  virtual Error visitFuncMDTokenMap(BinaryStreamRef Data);<br>
> -  virtual Error visitTypeMDTokenMap(BinaryStreamRef Data);<br>
> -  virtual Error visitMergedAssemblyInput(BinaryStreamRef Data);<br>
> -  virtual Error visitCoffSymbolRVA(BinaryStreamRef Data);<br>
> -};<br>
> -<br>
> -Error visitModuleDebugFragment(const ModuleDebugFragment &R,<br>
> -                               ModuleDebugFragmentVisitor &V);<br>
> -} // end namespace codeview<br>
> -<br>
> -template <> class VarStreamArrayExtractor<codeview::LineColumnEntry> {<br>
> -public:<br>
> -  typedef const codeview::LineFragmentHeader ContextType;<br>
> -<br>
> -  static Error extract(BinaryStreamRef Stream, uint32_t &Len,<br>
> -                       codeview::LineColumnEntry &Item, ContextType *Header) {<br>
> -    using namespace codeview;<br>
> -    const LineBlockFragmentHeader *BlockHeader;<br>
> -    BinaryStreamReader Reader(Stream);<br>
> -    if (auto EC = Reader.readObject(BlockHeader))<br>
> -      return EC;<br>
> -    bool HasColumn = Header->Flags & uint32_t(LineFlags::HaveColumns);<br>
> -    uint32_t LineInfoSize =<br>
> -        BlockHeader->NumLines *<br>
> -        (sizeof(LineNumberEntry) + (HasColumn ? sizeof(ColumnNumberEntry) : 0));<br>
> -    if (BlockHeader->BlockSize < sizeof(LineBlockFragmentHeader))<br>
> -      return make_error<CodeViewError>(cv_error_code::corrupt_record,<br>
> -                                       "Invalid line block record size");<br>
> -    uint32_t Size = BlockHeader->BlockSize - sizeof(LineBlockFragmentHeader);<br>
> -    if (LineInfoSize > Size)<br>
> -      return make_error<CodeViewError>(cv_error_code::corrupt_record,<br>
> -                                       "Invalid line block record size");<br>
> -    // The value recorded in BlockHeader->BlockSize includes the size of<br>
> -    // LineBlockFragmentHeader.<br>
> -    Len = BlockHeader->BlockSize;<br>
> -    Item.NameIndex = BlockHeader->NameIndex;<br>
> -    if (auto EC = Reader.readArray(Item.LineNumbers, BlockHeader->NumLines))<br>
> -      return EC;<br>
> -    if (HasColumn) {<br>
> -      if (auto EC = Reader.readArray(Item.Columns, BlockHeader->NumLines))<br>
> -        return EC;<br>
> -    }<br>
> +  virtual Error visitUnknown(ModuleDebugUnknownFragment &Unknown) {<br>
> +    return Error::success();<br>
> +  }<br>
> +  virtual Error visitLines(ModuleDebugLineFragment &Lines) {<br>
>      return Error::success();<br>
>    }<br>
> -};<br>
> -<br>
> -template <> class VarStreamArrayExtractor<codeview::FileChecksumEntry> {<br>
> -public:<br>
> -  typedef void ContextType;<br>
><br>
> -  static Error extract(BinaryStreamRef Stream, uint32_t &Len,<br>
> -                       codeview::FileChecksumEntry &Item, void *Ctx) {<br>
> -    using namespace codeview;<br>
> -    const FileChecksum *Header;<br>
> -    BinaryStreamReader Reader(Stream);<br>
> -    if (auto EC = Reader.readObject(Header))<br>
> -      return EC;<br>
> -    Item.FileNameOffset = Header->FileNameOffset;<br>
> -    Item.Kind = static_cast<FileChecksumKind>(Header->ChecksumKind);<br>
> -    if (auto EC = Reader.readBytes(Item.Checksum, Header->ChecksumSize))<br>
> -      return EC;<br>
> -    Len = sizeof(FileChecksum) + Header->ChecksumSize;<br>
> +  virtual Error visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) {<br>
>      return Error::success();<br>
>    }<br>
>  };<br>
><br>
> +Error visitModuleDebugFragment(const ModuleDebugFragmentRecord &R,<br>
> +                               ModuleDebugFragmentVisitor &V);<br>
> +} // end namespace codeview<br>
> +<br>
>  } // end namespace llvm<br>
><br>
>  #endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H<br>
><br>
> Added: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h (added)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,92 @@<br>
> +//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H<br>
> +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
> +#include "llvm/Support/BinaryStreamArray.h"<br>
> +#include "llvm/Support/BinaryStreamReader.h"<br>
> +#include "llvm/Support/Error.h"<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +<br>
> +// Corresponds to the `CV_DebugSLinesHeader_t` structure.<br>
> +struct LineFragmentHeader {<br>
> +  support::ulittle32_t RelocOffset;  // Code offset of line contribution.<br>
> +  support::ulittle16_t RelocSegment; // Code segment of line contribution.<br>
> +  support::ulittle16_t Flags;        // See LineFlags enumeration.<br>
> +  support::ulittle32_t CodeSize;     // Code size of this line contribution.<br>
> +};<br>
> +<br>
> +// Corresponds to the `CV_DebugSLinesFileBlockHeader_t` structure.<br>
> +struct LineBlockFragmentHeader {<br>
> +  support::ulittle32_t NameIndex; // Index in DBI name buffer of filename.<br>
> +  support::ulittle32_t NumLines;  // Number of lines<br>
> +  support::ulittle32_t BlockSize; // Code size of block, in bytes.<br>
> +  // The following two variable length arrays appear immediately after the<br>
> +  // header.  The structure definitions follow.<br>
> +  // LineNumberEntry   Lines[NumLines];<br>
> +  // ColumnNumberEntry Columns[NumLines];<br>
> +};<br>
> +<br>
> +// Corresponds to `CV_Line_t` structure<br>
> +struct LineNumberEntry {<br>
> +  support::ulittle32_t Offset; // Offset to start of code bytes for line number<br>
> +  support::ulittle32_t Flags;  // Start:24, End:7, IsStatement:1<br>
> +};<br>
> +<br>
> +// Corresponds to `CV_Column_t` structure<br>
> +struct ColumnNumberEntry {<br>
> +  support::ulittle16_t StartColumn;<br>
> +  support::ulittle16_t EndColumn;<br>
> +};<br>
> +<br>
> +struct LineColumnEntry {<br>
> +  support::ulittle32_t NameIndex;<br>
> +  FixedStreamArray<LineNumberEntry> LineNumbers;<br>
> +  FixedStreamArray<ColumnNumberEntry> Columns;<br>
> +};<br>
> +<br>
> +class LineColumnExtractor {<br>
> +public:<br>
> +  typedef const LineFragmentHeader ContextType;<br>
> +<br>
> +  static Error extract(BinaryStreamRef Stream, uint32_t &Len,<br>
> +                       LineColumnEntry &Item, const LineFragmentHeader *Header);<br>
> +};<br>
> +<br>
> +class ModuleDebugLineFragment final : public ModuleDebugFragment {<br>
> +  friend class LineColumnExtractor;<br>
> +  typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray;<br>
> +  typedef LineInfoArray::Iterator Iterator;<br>
> +<br>
> +public:<br>
> +  ModuleDebugLineFragment();<br>
> +<br>
> +  static bool classof(const ModuleDebugFragment *S) {<br>
> +    return S->kind() == ModuleDebugFragmentKind::Lines;<br>
> +  }<br>
> +<br>
> +  Error initialize(BinaryStreamReader Reader);<br>
> +<br>
> +  Iterator begin() const { return LinesAndColumns.begin(); }<br>
> +  Iterator end() const { return LinesAndColumns.end(); }<br>
> +<br>
> +  const LineFragmentHeader *header() const { return Header; }<br>
> +<br>
> +private:<br>
> +  const LineFragmentHeader *Header = nullptr;<br>
> +  LineInfoArray LinesAndColumns;<br>
> +};<br>
> +}<br>
> +}<br>
> +<br>
> +#endif<br>
><br>
> Added: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h (added)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,32 @@<br>
> +//===- ModuleDebugUnknownFragment.h -----------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H<br>
> +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
> +#include "llvm/Support/BinaryStreamRef.h"<br>
> +<br>
> +namespace llvm {<br>
> +namespace codeview {<br>
> +<br>
> +class ModuleDebugUnknownFragment final : public ModuleDebugFragment {<br>
> +public:<br>
> +  ModuleDebugUnknownFragment(ModuleDebugFragmentKind Kind, BinaryStreamRef Data)<br>
> +      : ModuleDebugFragment(Kind), Data(Data) {}<br>
> +<br>
> +  BinaryStreamRef getData() const { return Data; }<br>
> +<br>
> +private:<br>
> +  BinaryStreamRef Data;<br>
> +};<br>
> +}<br>
> +}<br>
> +<br>
> +#endif<br>
><br>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h (original)<br>
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h Thu Apr 27 11:12:16 2017<br>
> @@ -12,7 +12,7 @@<br>
><br>
>  #include "llvm/ADT/iterator_range.h"<br>
>  #include "llvm/DebugInfo/CodeView/CVRecord.h"<br>
> -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"<br>
>  #include "llvm/DebugInfo/CodeView/SymbolRecord.h"<br>
>  #include "llvm/DebugInfo/MSF/MappedBlockStream.h"<br>
>  #include "llvm/Support/BinaryStreamArray.h"<br>
> @@ -25,6 +25,9 @@ class PDBFile;<br>
>  class DbiModuleDescriptor;<br>
><br>
>  class ModuleDebugStream {<br>
> +  typedef codeview::ModuleDebugFragmentArray::Iterator<br>
> +      LinesAndChecksumsIterator;<br>
> +<br>
>  public:<br>
>    ModuleDebugStream(const DbiModuleDescriptor &Module,<br>
>                      std::unique_ptr<msf::MappedBlockStream> Stream);<br>
> @@ -37,8 +40,7 @@ public:<br>
>    iterator_range<codeview::CVSymbolArray::Iterator><br>
>    symbols(bool *HadError) const;<br>
><br>
> -  iterator_range<codeview::ModuleDebugFragmentArray::Iterator><br>
> -  lines(bool *HadError) const;<br>
> +  llvm::iterator_range<LinesAndChecksumsIterator> linesAndChecksums() const;<br>
><br>
>    bool hasLineInfo() const;<br>
><br>
> @@ -56,7 +58,7 @@ private:<br>
>    BinaryStreamRef C13LinesSubstream;<br>
>    BinaryStreamRef GlobalRefsSubstream;<br>
><br>
> -  codeview::ModuleDebugFragmentArray LineInfo;<br>
> +  codeview::ModuleDebugFragmentArray LinesAndChecksums;<br>
>  };<br>
>  }<br>
>  }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Thu Apr 27 11:12:16 2017<br>
> @@ -7,8 +7,12 @@ add_llvm_library(LLVMDebugInfoCodeView<br>
>    EnumTables.cpp<br>
>    Formatters.cpp<br>
>    Line.cpp<br>
> +  ModuleDebugFileChecksumFragment.cpp<br>
>    ModuleDebugFragment.cpp<br>
> +  ModuleDebugFragmentRecord.cpp<br>
>    ModuleDebugFragmentVisitor.cpp<br>
> +  ModuleDebugLineFragment.cpp<br>
> +  ModuleDebugUnknownFragment.cpp<br>
>    RecordSerialization.cpp<br>
>    SymbolRecordMapping.cpp<br>
>    SymbolDumper.cpp<br>
><br>
> Added: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp (added)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,49 @@<br>
> +//===- ModuleDebugFileChecksumFragment.cpp ----------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/CodeViewError.h"<br>
> +#include "llvm/Support/BinaryStreamReader.h"<br>
> +<br>
> +using namespace llvm;<br>
> +using namespace llvm::codeview;<br>
> +<br>
> +struct FileChecksumEntryHeader {<br>
> +  using ulittle32_t = support::ulittle32_t;<br>
> +<br>
> +  ulittle32_t FileNameOffset; // Byte offset of filename in global string table.<br>
> +  uint8_t ChecksumSize;       // Number of bytes of checksum.<br>
> +  uint8_t ChecksumKind;       // FileChecksumKind<br>
> +                              // Checksum bytes follow.<br>
> +};<br>
> +<br>
> +Error llvm::VarStreamArrayExtractor<FileChecksumEntry>::extract(<br>
> +    BinaryStreamRef Stream, uint32_t &Len, FileChecksumEntry &Item, void *Ctx) {<br>
> +  BinaryStreamReader Reader(Stream);<br>
> +<br>
> +  const FileChecksumEntryHeader *Header;<br>
> +  if (auto EC = Reader.readObject(Header))<br>
> +    return EC;<br>
> +<br>
> +  Item.FileNameOffset = Header->FileNameOffset;<br>
> +  Item.Kind = static_cast<FileChecksumKind>(Header->ChecksumKind);<br>
> +  if (auto EC = Reader.readBytes(Item.Checksum, Header->ChecksumSize))<br>
> +    return EC;<br>
> +<br>
> +  Len = alignTo(Header->ChecksumSize + sizeof(FileChecksumEntryHeader), 4);<br>
> +  return Error::success();<br>
> +}<br>
> +<br>
> +Error ModuleDebugFileChecksumFragment::initialize(BinaryStreamReader Reader) {<br>
> +  if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))<br>
> +    return EC;<br>
> +<br>
> +  return Error::success();<br>
> +}<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -1,5 +1,4 @@<br>
> -//===- ModuleDebugFragment.cpp --------------------------------------*- C++<br>
> -//-*-===//<br>
> +//===- ModuleDebugFragment.cpp -----------------------------------*- C++-*-===//<br>
>  //<br>
>  //                     The LLVM Compiler Infrastructure<br>
>  //<br>
> @@ -10,37 +9,6 @@<br>
><br>
>  #include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
><br>
> -#include "llvm/Support/BinaryStreamReader.h"<br>
> -<br>
> -using namespace llvm;<br>
>  using namespace llvm::codeview;<br>
><br>
> -ModuleDebugFragment::ModuleDebugFragment()<br>
> -    : Kind(ModuleDebugFragmentKind::None) {}<br>
> -<br>
> -ModuleDebugFragment::ModuleDebugFragment(ModuleDebugFragmentKind Kind,<br>
> -                                         BinaryStreamRef Data)<br>
> -    : Kind(Kind), Data(Data) {}<br>
> -<br>
> -Error ModuleDebugFragment::initialize(BinaryStreamRef Stream,<br>
> -                                      ModuleDebugFragment &Info) {<br>
> -  const ModuleDebugFragmentHeader *Header;<br>
> -  BinaryStreamReader Reader(Stream);<br>
> -  if (auto EC = Reader.readObject(Header))<br>
> -    return EC;<br>
> -<br>
> -  ModuleDebugFragmentKind Kind =<br>
> -      static_cast<ModuleDebugFragmentKind>(uint32_t(Header->Kind));<br>
> -  if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))<br>
> -    return EC;<br>
> -  Info.Kind = Kind;<br>
> -  return Error::success();<br>
> -}<br>
> -<br>
> -uint32_t ModuleDebugFragment::getRecordLength() const {<br>
> -  return sizeof(ModuleDebugFragmentHeader) + Data.getLength();<br>
> -}<br>
> -<br>
> -ModuleDebugFragmentKind ModuleDebugFragment::kind() const { return Kind; }<br>
> -<br>
> -BinaryStreamRef ModuleDebugFragment::getRecordData() const { return Data; }<br>
> +ModuleDebugFragment::~ModuleDebugFragment() {}<br>
><br>
> Added: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp (added)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,47 @@<br>
> +//===- ModuleDebugFragmentRecord.cpp -----------------------------*- C++-*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"<br>
> +<br>
> +#include "llvm/Support/BinaryStreamReader.h"<br>
> +<br>
> +using namespace llvm;<br>
> +using namespace llvm::codeview;<br>
> +<br>
> +ModuleDebugFragmentRecord::ModuleDebugFragmentRecord()<br>
> +    : Kind(ModuleDebugFragmentKind::None) {}<br>
> +<br>
> +ModuleDebugFragmentRecord::ModuleDebugFragmentRecord(<br>
> +    ModuleDebugFragmentKind Kind, BinaryStreamRef Data)<br>
> +    : Kind(Kind), Data(Data) {}<br>
> +<br>
> +Error ModuleDebugFragmentRecord::initialize(BinaryStreamRef Stream,<br>
> +                                            ModuleDebugFragmentRecord &Info) {<br>
> +  const ModuleDebugFragmentHeader *Header;<br>
> +  BinaryStreamReader Reader(Stream);<br>
> +  if (auto EC = Reader.readObject(Header))<br>
> +    return EC;<br>
> +<br>
> +  ModuleDebugFragmentKind Kind =<br>
> +      static_cast<ModuleDebugFragmentKind>(uint32_t(Header->Kind));<br>
> +  if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))<br>
> +    return EC;<br>
> +  Info.Kind = Kind;<br>
> +  return Error::success();<br>
> +}<br>
> +<br>
> +uint32_t ModuleDebugFragmentRecord::getRecordLength() const {<br>
> +  return sizeof(ModuleDebugFragmentHeader) + Data.getLength();<br>
> +}<br>
> +<br>
> +ModuleDebugFragmentKind ModuleDebugFragmentRecord::kind() const { return Kind; }<br>
> +<br>
> +BinaryStreamRef ModuleDebugFragmentRecord::getRecordData() const {<br>
> +  return Data;<br>
> +}<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -8,99 +8,36 @@<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
>  #include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"<br>
>  #include "llvm/Support/BinaryStreamReader.h"<br>
>  #include "llvm/Support/BinaryStreamRef.h"<br>
><br>
>  using namespace llvm;<br>
>  using namespace llvm::codeview;<br>
><br>
> -Error ModuleDebugFragmentVisitor::visitSymbols(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::Symbols, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitLines(BinaryStreamRef Data,<br>
> -                                             const LineFragmentHeader *Header,<br>
> -                                             const LineInfoArray &Lines) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::Lines, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitStringTable(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::StringTable, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitFileChecksums(<br>
> -    BinaryStreamRef Data, const FileChecksumArray &Checksums) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::FileChecksums, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitFrameData(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::FrameData, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitInlineeLines(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::InlineeLines, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitCrossScopeImports(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::CrossScopeExports, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitCrossScopeExports(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::CrossScopeImports, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitILLines(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::ILLines, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::FuncMDTokenMap, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::TypeMDTokenMap, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitMergedAssemblyInput(<br>
> -    BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::MergedAssemblyInput, Data);<br>
> -}<br>
> -Error ModuleDebugFragmentVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) {<br>
> -  return visitUnknown(ModuleDebugFragmentKind::CoffSymbolRVA, Data);<br>
> -}<br>
> -<br>
> -Error llvm::codeview::visitModuleDebugFragment(const ModuleDebugFragment &R,<br>
> -                                               ModuleDebugFragmentVisitor &V) {<br>
> +Error llvm::codeview::visitModuleDebugFragment(<br>
> +    const ModuleDebugFragmentRecord &R, ModuleDebugFragmentVisitor &V) {<br>
> +  BinaryStreamReader Reader(R.getRecordData());<br>
>    switch (R.kind()) {<br>
> -  case ModuleDebugFragmentKind::Symbols:<br>
> -    return V.visitSymbols(R.getRecordData());<br>
>    case ModuleDebugFragmentKind::Lines: {<br>
> -    BinaryStreamReader Reader(R.getRecordData());<br>
> -    const LineFragmentHeader *Header;<br>
> -    if (auto EC = Reader.readObject(Header))<br>
> +    ModuleDebugLineFragment Fragment;<br>
> +    if (auto EC = Fragment.initialize(Reader))<br>
>        return EC;<br>
> -    LineInfoArray LineInfos;<br>
> -    if (auto EC = Reader.readArray(LineInfos, Reader.bytesRemaining(), Header))<br>
> -      return EC;<br>
> -    return V.visitLines(R.getRecordData(), Header, LineInfos);<br>
> +<br>
> +    return V.visitLines(Fragment);<br>
>    }<br>
> -  case ModuleDebugFragmentKind::StringTable:<br>
> -    return V.visitStringTable(R.getRecordData());<br>
>    case ModuleDebugFragmentKind::FileChecksums: {<br>
> -    BinaryStreamReader Reader(R.getRecordData());<br>
> -    FileChecksumArray Checksums;<br>
> -    if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))<br>
> +    ModuleDebugFileChecksumFragment Fragment;<br>
> +    if (auto EC = Fragment.initialize(Reader))<br>
>        return EC;<br>
> -    return V.visitFileChecksums(R.getRecordData(), Checksums);<br>
> +<br>
> +    return V.visitFileChecksums(Fragment);<br>
> +  }<br>
> +  default: {<br>
> +    ModuleDebugUnknownFragment Fragment(R.kind(), R.getRecordData());<br>
> +    return V.visitUnknown(Fragment);<br>
>    }<br>
> -  case ModuleDebugFragmentKind::FrameData:<br>
> -    return V.visitFrameData(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::InlineeLines:<br>
> -    return V.visitInlineeLines(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::CrossScopeImports:<br>
> -    return V.visitCrossScopeImports(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::CrossScopeExports:<br>
> -    return V.visitCrossScopeExports(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::ILLines:<br>
> -    return V.visitILLines(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::FuncMDTokenMap:<br>
> -    return V.visitFuncMDTokenMap(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::TypeMDTokenMap:<br>
> -    return V.visitTypeMDTokenMap(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::MergedAssemblyInput:<br>
> -    return V.visitMergedAssemblyInput(R.getRecordData());<br>
> -  case ModuleDebugFragmentKind::CoffSymbolRVA:<br>
> -    return V.visitCoffSymbolRVA(R.getRecordData());<br>
> -  default:<br>
> -    return V.visitUnknown(R.kind(), R.getRecordData());<br>
>    }<br>
>  }<br>
><br>
> Added: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp (added)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugLineFragment.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,63 @@<br>
> +//===- ModuleDebugLineFragment.cpp --------------------------------*- C++<br>
> +//-*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/CodeViewError.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"<br>
> +<br>
> +using namespace llvm;<br>
> +using namespace llvm::codeview;<br>
> +<br>
> +Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len,<br>
> +                                   LineColumnEntry &Item,<br>
> +                                   const LineFragmentHeader *Header) {<br>
> +  using namespace codeview;<br>
> +  const LineBlockFragmentHeader *BlockHeader;<br>
> +  BinaryStreamReader Reader(Stream);<br>
> +  if (auto EC = Reader.readObject(BlockHeader))<br>
> +    return EC;<br>
> +  bool HasColumn = Header->Flags & uint32_t(LineFlags::HaveColumns);<br>
> +  uint32_t LineInfoSize =<br>
> +      BlockHeader->NumLines *<br>
> +      (sizeof(LineNumberEntry) + (HasColumn ? sizeof(ColumnNumberEntry) : 0));<br>
> +  if (BlockHeader->BlockSize < sizeof(LineBlockFragmentHeader))<br>
> +    return make_error<CodeViewError>(cv_error_code::corrupt_record,<br>
> +                                     "Invalid line block record size");<br>
> +  uint32_t Size = BlockHeader->BlockSize - sizeof(LineBlockFragmentHeader);<br>
> +  if (LineInfoSize > Size)<br>
> +    return make_error<CodeViewError>(cv_error_code::corrupt_record,<br>
> +                                     "Invalid line block record size");<br>
> +  // The value recorded in BlockHeader->BlockSize includes the size of<br>
> +  // LineBlockFragmentHeader.<br>
> +  Len = BlockHeader->BlockSize;<br>
> +  Item.NameIndex = BlockHeader->NameIndex;<br>
> +  if (auto EC = Reader.readArray(Item.LineNumbers, BlockHeader->NumLines))<br>
> +    return EC;<br>
> +  if (HasColumn) {<br>
> +    if (auto EC = Reader.readArray(Item.Columns, BlockHeader->NumLines))<br>
> +      return EC;<br>
> +  }<br>
> +  return Error::success();<br>
> +}<br>
> +<br>
> +ModuleDebugLineFragment::ModuleDebugLineFragment()<br>
> +    : ModuleDebugFragment(ModuleDebugFragmentKind::Lines) {}<br>
> +<br>
> +Error ModuleDebugLineFragment::initialize(BinaryStreamReader Reader) {<br>
> +  if (auto EC = Reader.readObject(Header))<br>
> +    return EC;<br>
> +<br>
> +  if (auto EC =<br>
> +          Reader.readArray(LinesAndColumns, Reader.bytesRemaining(), Header))<br>
> +    return EC;<br>
> +<br>
> +  return Error::success();<br>
> +}<br>
><br>
> Added: llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp?rev=301557&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp?rev=301557&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp (added)<br>
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleDebugUnknownFragment.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -0,0 +1,10 @@<br>
> +//===- ModuleDebugUnknownFragment.cpp ---------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"<br>
> \ No newline at end of file<br>
<br>
This file was commit with no newline, but more importantly, why is<br>
this file needed at all? It's generating diagnostics with link.exe<br>
because the resulting object file contains no previously undefined<br>
public symbols.<br>
<br>
~Aaron<br>
<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -21,6 +21,7 @@<br>
>  #include <cstdint><br>
><br>
>  using namespace llvm;<br>
> +using namespace llvm::codeview;<br>
>  using namespace llvm::msf;<br>
>  using namespace llvm::pdb;<br>
><br>
> @@ -54,7 +55,8 @@ Error ModuleDebugStream::reload() {<br>
>      return EC;<br>
><br>
>    BinaryStreamReader LineReader(C13LinesSubstream);<br>
> -  if (auto EC = LineReader.readArray(LineInfo, LineReader.bytesRemaining()))<br>
> +  if (auto EC =<br>
> +          LineReader.readArray(LinesAndChecksums, LineReader.bytesRemaining()))<br>
>      return EC;<br>
><br>
>    uint32_t GlobalRefsSize;<br>
> @@ -77,13 +79,13 @@ ModuleDebugStream::symbols(bool *HadErro<br>
>    return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());<br>
>  }<br>
><br>
> -iterator_range<codeview::ModuleDebugFragmentArray::Iterator><br>
> -ModuleDebugStream::lines(bool *HadError) const {<br>
> -  return make_range(LineInfo.begin(HadError), LineInfo.end());<br>
> +llvm::iterator_range<ModuleDebugStream::LinesAndChecksumsIterator><br>
> +ModuleDebugStream::linesAndChecksums() const {<br>
> +  return make_range(LinesAndChecksums.begin(), LinesAndChecksums.end());<br>
>  }<br>
><br>
>  bool ModuleDebugStream::hasLineInfo() const {<br>
> -  return C13LinesSubstream.getLength() > 0 || LinesSubstream.getLength() > 0;<br>
> +  return C13LinesSubstream.getLength() > 0;<br>
>  }<br>
><br>
>  Error ModuleDebugStream::commit() { return Error::success(); }<br>
><br>
> Modified: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -16,7 +16,10 @@<br>
>  #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"<br>
>  #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"<br>
>  #include "llvm/DebugInfo/CodeView/EnumTables.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
>  #include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"<br>
>  #include "llvm/DebugInfo/CodeView/SymbolDumper.h"<br>
>  #include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"<br>
>  #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"<br>
> @@ -633,17 +636,15 @@ Error LLVMOutputStyle::dumpDbiStream() {<br>
>          }<br>
>          if (opts::raw::DumpLineInfo) {<br>
>            ListScope SS(P, "LineInfo");<br>
> -          bool HadError = false;<br>
>            // Define a locally scoped visitor to print the different<br>
>            // substream types types.<br>
>            class RecordVisitor : public codeview::ModuleDebugFragmentVisitor {<br>
>            public:<br>
>              RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}<br>
> -            Error visitUnknown(ModuleDebugFragmentKind Kind,<br>
> -                               BinaryStreamRef Stream) override {<br>
> +            Error visitUnknown(ModuleDebugUnknownFragment &Fragment) override {<br>
>                DictScope DD(P, "Unknown");<br>
>                ArrayRef<uint8_t> Data;<br>
> -              BinaryStreamReader R(Stream);<br>
> +              BinaryStreamReader R(Fragment.getData());<br>
>                if (auto EC = R.readBytes(Data, R.bytesRemaining())) {<br>
>                  return make_error<RawError>(<br>
>                      raw_error_code::corrupt_file,<br>
> @@ -652,9 +653,8 @@ Error LLVMOutputStyle::dumpDbiStream() {<br>
>                P.printBinaryBlock("Data", Data);<br>
>                return Error::success();<br>
>              }<br>
> -            Error<br>
> -            visitFileChecksums(BinaryStreamRef Data,<br>
> -                               const FileChecksumArray &Checksums) override {<br>
> +            Error visitFileChecksums(<br>
> +                ModuleDebugFileChecksumFragment &Checksums) override {<br>
>                DictScope DD(P, "FileChecksums");<br>
>                for (const auto &C : Checksums) {<br>
>                  DictScope DDD(P, "Checksum");<br>
> @@ -669,9 +669,7 @@ Error LLVMOutputStyle::dumpDbiStream() {<br>
>                return Error::success();<br>
>              }<br>
><br>
> -            Error visitLines(BinaryStreamRef Data,<br>
> -                             const LineFragmentHeader *Header,<br>
> -                             const LineInfoArray &Lines) override {<br>
> +            Error visitLines(ModuleDebugLineFragment &Lines) override {<br>
>                DictScope DD(P, "Lines");<br>
>                for (const auto &L : Lines) {<br>
>                  if (auto Result = getFileNameForOffset2(L.NameIndex))<br>
> @@ -720,7 +718,7 @@ Error LLVMOutputStyle::dumpDbiStream() {<br>
>            };<br>
><br>
>            RecordVisitor V(P, File);<br>
> -          for (const auto &L : ModS.lines(&HadError)) {<br>
> +          for (const auto &L : ModS.linesAndChecksums()) {<br>
>              if (auto EC = codeview::visitModuleDebugFragment(L, V))<br>
>                return EC;<br>
>            }<br>
><br>
> Modified: llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -13,8 +13,11 @@<br>
>  #include "llvm-pdbdump.h"<br>
><br>
>  #include "llvm/DebugInfo/CodeView/Line.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
>  #include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"<br>
>  #include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"<br>
>  #include "llvm/DebugInfo/MSF/MappedBlockStream.h"<br>
>  #include "llvm/DebugInfo/PDB/Native/DbiStream.h"<br>
>  #include "llvm/DebugInfo/PDB/Native/InfoStream.h"<br>
> @@ -24,6 +27,7 @@<br>
>  #include "llvm/DebugInfo/PDB/Native/TpiStream.h"<br>
><br>
>  using namespace llvm;<br>
> +using namespace llvm::codeview;<br>
>  using namespace llvm::pdb;<br>
><br>
>  YAMLOutputStyle::YAMLOutputStyle(PDBFile &File)<br>
> @@ -75,19 +79,17 @@ Error YAMLOutputStyle::dump() {<br>
>  }<br>
><br>
>  namespace {<br>
> -class C13SubstreamVisitor : public codeview::ModuleDebugFragmentVisitor {<br>
> +class C13SubstreamVisitor : public ModuleDebugFragmentVisitor {<br>
>  public:<br>
>    C13SubstreamVisitor(llvm::pdb::yaml::PdbSourceFileInfo &Info, PDBFile &F)<br>
>        : Info(Info), F(F) {}<br>
><br>
> -  Error visitUnknown(codeview::ModuleDebugFragmentKind Kind,<br>
> -                     BinaryStreamRef Stream) override {<br>
> +  Error visitUnknown(ModuleDebugUnknownFragment &Fragment) override {<br>
>      return Error::success();<br>
>    }<br>
><br>
>    Error<br>
> -  visitFileChecksums(BinaryStreamRef Data,<br>
> -                     const codeview::FileChecksumArray &Checksums) override {<br>
> +  visitFileChecksums(ModuleDebugFileChecksumFragment &Checksums) override {<br>
>      for (const auto &C : Checksums) {<br>
>        llvm::pdb::yaml::PdbSourceFileChecksumEntry Entry;<br>
>        if (auto Result = getGlobalString(C.FileNameOffset))<br>
> @@ -102,15 +104,13 @@ public:<br>
>      return Error::success();<br>
>    }<br>
><br>
> -  Error visitLines(BinaryStreamRef Data,<br>
> -                   const codeview::LineFragmentHeader *Header,<br>
> -                   const codeview::LineInfoArray &Lines) override {<br>
> +  Error visitLines(ModuleDebugLineFragment &Lines) override {<br>
><br>
> -    Info.Lines.CodeSize = Header->CodeSize;<br>
> +    Info.Lines.CodeSize = Lines.header()->CodeSize;<br>
>      Info.Lines.Flags =<br>
> -        static_cast<codeview::LineFlags>(uint16_t(Header->Flags));<br>
> -    Info.Lines.RelocOffset = Header->RelocOffset;<br>
> -    Info.Lines.RelocSegment = Header->RelocSegment;<br>
> +        static_cast<codeview::LineFlags>(uint16_t(Lines.header()->Flags));<br>
> +    Info.Lines.RelocOffset = Lines.header()->RelocOffset;<br>
> +    Info.Lines.RelocSegment = Lines.header()->RelocSegment;<br>
><br>
>      for (const auto &L : Lines) {<br>
>        llvm::pdb::yaml::PdbSourceLineBlock Block;<br>
> @@ -170,9 +170,8 @@ YAMLOutputStyle::getFileLineInfo(const p<br>
>      return None;<br>
><br>
>    yaml::PdbSourceFileInfo Info;<br>
> -  bool Error = false;<br>
>    C13SubstreamVisitor Visitor(Info, File);<br>
> -  for (auto &Frag : ModS.lines(&Error)) {<br>
> +  for (auto &Frag : ModS.linesAndChecksums()) {<br>
>      if (auto E = codeview::visitModuleDebugFragment(Frag, Visitor))<br>
>        return std::move(E);<br>
>    }<br>
><br>
> Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=301557&r1=301556&r2=301557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=301557&r1=301556&r2=301557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Thu Apr 27 11:12:16 2017<br>
> @@ -25,6 +25,7 @@<br>
>  #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"<br>
>  #include "llvm/DebugInfo/CodeView/CodeView.h"<br>
>  #include "llvm/DebugInfo/CodeView/Line.h"<br>
> +#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"<br>
>  #include "llvm/DebugInfo/CodeView/RecordSerialization.h"<br>
>  #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"<br>
>  #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"<br>
> @@ -985,29 +986,22 @@ void COFFDumper::printCodeViewSymbolsSub<br>
>  void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {<br>
>    BinaryByteStream S(Subsection, llvm::support::little);<br>
>    BinaryStreamReader SR(S);<br>
> -  while (!SR.empty()) {<br>
> +  ModuleDebugFileChecksumFragment Checksums;<br>
> +  error(Checksums.initialize(SR));<br>
> +<br>
> +  for (auto &FC : Checksums) {<br>
>      DictScope S(W, "FileChecksum");<br>
> -    const FileChecksum *FC;<br>
> -    error(SR.readObject(FC));<br>
> -    if (FC->FileNameOffset >= CVStringTable.size())<br>
> +<br>
> +    if (FC.FileNameOffset >= CVStringTable.size())<br>
>        error(object_error::parse_failed);<br>
>      StringRef Filename =<br>
> -        CVStringTable.drop_front(FC->FileNameOffset).split('\0').first;<br>
> -    W.printHex("Filename", Filename, FC->FileNameOffset);<br>
> -    W.printHex("ChecksumSize", FC->ChecksumSize);<br>
> -    W.printEnum("ChecksumKind", uint8_t(FC->ChecksumKind),<br>
> +        CVStringTable.drop_front(FC.FileNameOffset).split('\0').first;<br>
> +    W.printHex("Filename", Filename, FC.FileNameOffset);<br>
> +    W.printHex("ChecksumSize", FC.Checksum.size());<br>
> +    W.printEnum("ChecksumKind", uint8_t(FC.Kind),<br>
>                  makeArrayRef(FileChecksumKindNames));<br>
> -    if (FC->ChecksumSize >= SR.bytesRemaining())<br>
> -      error(object_error::parse_failed);<br>
> -    ArrayRef<uint8_t> ChecksumBytes;<br>
> -    error(SR.readBytes(ChecksumBytes, FC->ChecksumSize));<br>
> -    W.printBinary("ChecksumBytes", ChecksumBytes);<br>
> -    unsigned PaddedSize = alignTo(FC->ChecksumSize + sizeof(FileChecksum), 4) -<br>
> -                          sizeof(FileChecksum);<br>
> -    PaddedSize -= ChecksumBytes.size();<br>
> -    if (PaddedSize > SR.bytesRemaining())<br>
> -      error(object_error::parse_failed);<br>
> -    error(SR.skip(PaddedSize));<br>
> +<br>
> +    W.printBinary("ChecksumBytes", FC.Checksum);<br>
>    }<br>
>  }<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>