[CodeView] Isolate Debug Info Fragments into standalone classes.

Previously parsing of these were all grouped together into a
single master class that could parse any type of debug info
fragment.

With writing forthcoming, the complexity of each individual
fragment is enough to warrant them having their own classes so
that reading and writing of each fragment type can be grouped
together, but isolated from the code for reading and writing
other fragment types.

In doing so, I found a place where parsing code was duplicated
for the FileChecksums fragment, across llvm-readobj and the
CodeView library, and one of the implementations had a bug.
Now that the codepaths are merged, the bug is resolved.

Differential Revision: https://reviews.llvm.org/D32547

llvm-svn: 301557
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index a4df5d0..20223ac 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -16,7 +16,10 @@
 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
 #include "llvm/DebugInfo/CodeView/EnumTables.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
 #include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"
+#include "llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h"
 #include "llvm/DebugInfo/CodeView/SymbolDumper.h"
 #include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
@@ -633,17 +636,15 @@
         }
         if (opts::raw::DumpLineInfo) {
           ListScope SS(P, "LineInfo");
-          bool HadError = false;
           // Define a locally scoped visitor to print the different
           // substream types types.
           class RecordVisitor : public codeview::ModuleDebugFragmentVisitor {
           public:
             RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}
-            Error visitUnknown(ModuleDebugFragmentKind Kind,
-                               BinaryStreamRef Stream) override {
+            Error visitUnknown(ModuleDebugUnknownFragment &Fragment) override {
               DictScope DD(P, "Unknown");
               ArrayRef<uint8_t> Data;
-              BinaryStreamReader R(Stream);
+              BinaryStreamReader R(Fragment.getData());
               if (auto EC = R.readBytes(Data, R.bytesRemaining())) {
                 return make_error<RawError>(
                     raw_error_code::corrupt_file,
@@ -652,9 +653,8 @@
               P.printBinaryBlock("Data", Data);
               return Error::success();
             }
-            Error
-            visitFileChecksums(BinaryStreamRef Data,
-                               const FileChecksumArray &Checksums) override {
+            Error visitFileChecksums(
+                ModuleDebugFileChecksumFragment &Checksums) override {
               DictScope DD(P, "FileChecksums");
               for (const auto &C : Checksums) {
                 DictScope DDD(P, "Checksum");
@@ -669,9 +669,7 @@
               return Error::success();
             }
 
-            Error visitLines(BinaryStreamRef Data,
-                             const LineFragmentHeader *Header,
-                             const LineInfoArray &Lines) override {
+            Error visitLines(ModuleDebugLineFragment &Lines) override {
               DictScope DD(P, "Lines");
               for (const auto &L : Lines) {
                 if (auto Result = getFileNameForOffset2(L.NameIndex))
@@ -720,7 +718,7 @@
           };
 
           RecordVisitor V(P, File);
-          for (const auto &L : ModS.lines(&HadError)) {
+          for (const auto &L : ModS.linesAndChecksums()) {
             if (auto EC = codeview::visitModuleDebugFragment(L, V))
               return EC;
           }