Rename some PDB classes.

We have a lot of very similarly named classes related to
dealing with module debug info.  This patch has NFC, it just
renames some classes to be more descriptive (albeit slightly
more to type).  The mapping from old to new class names is as
follows:

   Old          |        New
ModInfo         | DbiModuleDescriptor
ModuleSubstream | ModuleDebugFragment
ModStream       | ModuleDebugStream

With the corresponding Builder classes renamed accordingly.

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

llvm-svn: 301555
diff --git a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
index 6e9214d..5dae51e 100644
--- a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
@@ -7,8 +7,8 @@
   EnumTables.cpp
   Formatters.cpp
   Line.cpp
-  ModuleSubstream.cpp
-  ModuleSubstreamVisitor.cpp
+  ModuleDebugFragment.cpp
+  ModuleDebugFragmentVisitor.cpp
   RecordSerialization.cpp
   SymbolRecordMapping.cpp
   SymbolDumper.cpp
diff --git a/llvm/lib/DebugInfo/CodeView/EnumTables.cpp b/llvm/lib/DebugInfo/CodeView/EnumTables.cpp
index 0e20bcb..fc6008b 100644
--- a/llvm/lib/DebugInfo/CodeView/EnumTables.cpp
+++ b/llvm/lib/DebugInfo/CodeView/EnumTables.cpp
@@ -245,20 +245,20 @@
 };
 
 static const EnumEntry<uint32_t> ModuleSubstreamKindNames[] = {
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, None),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, Symbols),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, Lines),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, StringTable),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, FileChecksums),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, FrameData),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, InlineeLines),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, CrossScopeImports),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, CrossScopeExports),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, ILLines),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, FuncMDTokenMap),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, TypeMDTokenMap),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, MergedAssemblyInput),
-    CV_ENUM_CLASS_ENT(ModuleSubstreamKind, CoffSymbolRVA),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, None),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, Symbols),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, Lines),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, StringTable),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, FileChecksums),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, FrameData),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, InlineeLines),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, CrossScopeImports),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, CrossScopeExports),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, ILLines),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, FuncMDTokenMap),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, TypeMDTokenMap),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, MergedAssemblyInput),
+    CV_ENUM_CLASS_ENT(ModuleDebugFragmentKind, CoffSymbolRVA),
 };
 
 static const EnumEntry<uint16_t> ExportSymFlagNames[] = {
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp
new file mode 100644
index 0000000..1329f8c
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragment.cpp
@@ -0,0 +1,46 @@
+//===- ModuleDebugFragment.cpp --------------------------------------*- C++
+//-*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
+
+#include "llvm/Support/BinaryStreamReader.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+ModuleDebugFragment::ModuleDebugFragment()
+    : Kind(ModuleDebugFragmentKind::None) {}
+
+ModuleDebugFragment::ModuleDebugFragment(ModuleDebugFragmentKind Kind,
+                                         BinaryStreamRef Data)
+    : Kind(Kind), Data(Data) {}
+
+Error ModuleDebugFragment::initialize(BinaryStreamRef Stream,
+                                      ModuleDebugFragment &Info) {
+  const ModuleDebugFragmentHeader *Header;
+  BinaryStreamReader Reader(Stream);
+  if (auto EC = Reader.readObject(Header))
+    return EC;
+
+  ModuleDebugFragmentKind Kind =
+      static_cast<ModuleDebugFragmentKind>(uint32_t(Header->Kind));
+  if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
+    return EC;
+  Info.Kind = Kind;
+  return Error::success();
+}
+
+uint32_t ModuleDebugFragment::getRecordLength() const {
+  return sizeof(ModuleDebugFragmentHeader) + Data.getLength();
+}
+
+ModuleDebugFragmentKind ModuleDebugFragment::kind() const { return Kind; }
+
+BinaryStreamRef ModuleDebugFragment::getRecordData() const { return Data; }
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp
new file mode 100644
index 0000000..8db17b9
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentVisitor.cpp
@@ -0,0 +1,107 @@
+//===- ModuleDebugFragmentVisitor.cpp ---------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h"
+#include "llvm/Support/BinaryStreamReader.h"
+#include "llvm/Support/BinaryStreamRef.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+Error ModuleDebugFragmentVisitor::visitSymbols(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::Symbols, Data);
+}
+Error ModuleDebugFragmentVisitor::visitLines(BinaryStreamRef Data,
+                                             const LineFragmentHeader *Header,
+                                             const LineInfoArray &Lines) {
+  return visitUnknown(ModuleDebugFragmentKind::Lines, Data);
+}
+Error ModuleDebugFragmentVisitor::visitStringTable(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::StringTable, Data);
+}
+Error ModuleDebugFragmentVisitor::visitFileChecksums(
+    BinaryStreamRef Data, const FileChecksumArray &Checksums) {
+  return visitUnknown(ModuleDebugFragmentKind::FileChecksums, Data);
+}
+Error ModuleDebugFragmentVisitor::visitFrameData(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::FrameData, Data);
+}
+Error ModuleDebugFragmentVisitor::visitInlineeLines(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::InlineeLines, Data);
+}
+Error ModuleDebugFragmentVisitor::visitCrossScopeImports(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::CrossScopeExports, Data);
+}
+Error ModuleDebugFragmentVisitor::visitCrossScopeExports(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::CrossScopeImports, Data);
+}
+Error ModuleDebugFragmentVisitor::visitILLines(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::ILLines, Data);
+}
+Error ModuleDebugFragmentVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::FuncMDTokenMap, Data);
+}
+Error ModuleDebugFragmentVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::TypeMDTokenMap, Data);
+}
+Error ModuleDebugFragmentVisitor::visitMergedAssemblyInput(
+    BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::MergedAssemblyInput, Data);
+}
+Error ModuleDebugFragmentVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) {
+  return visitUnknown(ModuleDebugFragmentKind::CoffSymbolRVA, Data);
+}
+
+Error llvm::codeview::visitModuleDebugFragment(const ModuleDebugFragment &R,
+                                               ModuleDebugFragmentVisitor &V) {
+  switch (R.kind()) {
+  case ModuleDebugFragmentKind::Symbols:
+    return V.visitSymbols(R.getRecordData());
+  case ModuleDebugFragmentKind::Lines: {
+    BinaryStreamReader Reader(R.getRecordData());
+    const LineFragmentHeader *Header;
+    if (auto EC = Reader.readObject(Header))
+      return EC;
+    VarStreamArrayExtractor<LineColumnEntry> E(Header);
+    LineInfoArray LineInfos(E);
+    if (auto EC = Reader.readArray(LineInfos, Reader.bytesRemaining()))
+      return EC;
+    return V.visitLines(R.getRecordData(), Header, LineInfos);
+  }
+  case ModuleDebugFragmentKind::StringTable:
+    return V.visitStringTable(R.getRecordData());
+  case ModuleDebugFragmentKind::FileChecksums: {
+    BinaryStreamReader Reader(R.getRecordData());
+    FileChecksumArray Checksums;
+    if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
+      return EC;
+    return V.visitFileChecksums(R.getRecordData(), Checksums);
+  }
+  case ModuleDebugFragmentKind::FrameData:
+    return V.visitFrameData(R.getRecordData());
+  case ModuleDebugFragmentKind::InlineeLines:
+    return V.visitInlineeLines(R.getRecordData());
+  case ModuleDebugFragmentKind::CrossScopeImports:
+    return V.visitCrossScopeImports(R.getRecordData());
+  case ModuleDebugFragmentKind::CrossScopeExports:
+    return V.visitCrossScopeExports(R.getRecordData());
+  case ModuleDebugFragmentKind::ILLines:
+    return V.visitILLines(R.getRecordData());
+  case ModuleDebugFragmentKind::FuncMDTokenMap:
+    return V.visitFuncMDTokenMap(R.getRecordData());
+  case ModuleDebugFragmentKind::TypeMDTokenMap:
+    return V.visitTypeMDTokenMap(R.getRecordData());
+  case ModuleDebugFragmentKind::MergedAssemblyInput:
+    return V.visitMergedAssemblyInput(R.getRecordData());
+  case ModuleDebugFragmentKind::CoffSymbolRVA:
+    return V.visitCoffSymbolRVA(R.getRecordData());
+  default:
+    return V.visitUnknown(R.kind(), R.getRecordData());
+  }
+}
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
deleted file mode 100644
index 69a7c59..0000000
--- a/llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//===- ModuleSubstream.cpp --------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
-
-#include "llvm/Support/BinaryStreamReader.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {}
-
-ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, BinaryStreamRef Data)
-    : Kind(Kind), Data(Data) {}
-
-Error ModuleSubstream::initialize(BinaryStreamRef Stream,
-                                  ModuleSubstream &Info) {
-  const ModuleSubsectionHeader *Header;
-  BinaryStreamReader Reader(Stream);
-  if (auto EC = Reader.readObject(Header))
-    return EC;
-
-  ModuleSubstreamKind Kind =
-      static_cast<ModuleSubstreamKind>(uint32_t(Header->Kind));
-  if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
-    return EC;
-  Info.Kind = Kind;
-  return Error::success();
-}
-
-uint32_t ModuleSubstream::getRecordLength() const {
-  return sizeof(ModuleSubsectionHeader) + Data.getLength();
-}
-
-ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; }
-
-BinaryStreamRef ModuleSubstream::getRecordData() const { return Data; }
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp b/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
deleted file mode 100644
index e490a78..0000000
--- a/llvm/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-//===- ModuleSubstreamVisitor.cpp -------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h"
-#include "llvm/Support/BinaryStreamReader.h"
-#include "llvm/Support/BinaryStreamRef.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-Error IModuleSubstreamVisitor::visitSymbols(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::Symbols, Data);
-}
-Error IModuleSubstreamVisitor::visitLines(BinaryStreamRef Data,
-                                          const LineSubstreamHeader *Header,
-                                          const LineInfoArray &Lines) {
-  return visitUnknown(ModuleSubstreamKind::Lines, Data);
-}
-Error IModuleSubstreamVisitor::visitStringTable(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::StringTable, Data);
-}
-Error IModuleSubstreamVisitor::visitFileChecksums(
-    BinaryStreamRef Data, const FileChecksumArray &Checksums) {
-  return visitUnknown(ModuleSubstreamKind::FileChecksums, Data);
-}
-Error IModuleSubstreamVisitor::visitFrameData(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::FrameData, Data);
-}
-Error IModuleSubstreamVisitor::visitInlineeLines(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::InlineeLines, Data);
-}
-Error IModuleSubstreamVisitor::visitCrossScopeImports(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::CrossScopeExports, Data);
-}
-Error IModuleSubstreamVisitor::visitCrossScopeExports(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::CrossScopeImports, Data);
-}
-Error IModuleSubstreamVisitor::visitILLines(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::ILLines, Data);
-}
-Error IModuleSubstreamVisitor::visitFuncMDTokenMap(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::FuncMDTokenMap, Data);
-}
-Error IModuleSubstreamVisitor::visitTypeMDTokenMap(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::TypeMDTokenMap, Data);
-}
-Error IModuleSubstreamVisitor::visitMergedAssemblyInput(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::MergedAssemblyInput, Data);
-}
-Error IModuleSubstreamVisitor::visitCoffSymbolRVA(BinaryStreamRef Data) {
-  return visitUnknown(ModuleSubstreamKind::CoffSymbolRVA, Data);
-}
-
-Error llvm::codeview::visitModuleSubstream(const ModuleSubstream &R,
-                                           IModuleSubstreamVisitor &V) {
-  switch (R.getSubstreamKind()) {
-  case ModuleSubstreamKind::Symbols:
-    return V.visitSymbols(R.getRecordData());
-  case ModuleSubstreamKind::Lines: {
-    BinaryStreamReader Reader(R.getRecordData());
-    const LineSubstreamHeader *Header;
-    if (auto EC = Reader.readObject(Header))
-      return EC;
-    VarStreamArrayExtractor<LineColumnEntry> E(Header);
-    LineInfoArray LineInfos(E);
-    if (auto EC = Reader.readArray(LineInfos, Reader.bytesRemaining()))
-      return EC;
-    return V.visitLines(R.getRecordData(), Header, LineInfos);
-  }
-  case ModuleSubstreamKind::StringTable:
-    return V.visitStringTable(R.getRecordData());
-  case ModuleSubstreamKind::FileChecksums: {
-    BinaryStreamReader Reader(R.getRecordData());
-    FileChecksumArray Checksums;
-    if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
-      return EC;
-    return V.visitFileChecksums(R.getRecordData(), Checksums);
-  }
-  case ModuleSubstreamKind::FrameData:
-    return V.visitFrameData(R.getRecordData());
-  case ModuleSubstreamKind::InlineeLines:
-    return V.visitInlineeLines(R.getRecordData());
-  case ModuleSubstreamKind::CrossScopeImports:
-    return V.visitCrossScopeImports(R.getRecordData());
-  case ModuleSubstreamKind::CrossScopeExports:
-    return V.visitCrossScopeExports(R.getRecordData());
-  case ModuleSubstreamKind::ILLines:
-    return V.visitILLines(R.getRecordData());
-  case ModuleSubstreamKind::FuncMDTokenMap:
-    return V.visitFuncMDTokenMap(R.getRecordData());
-  case ModuleSubstreamKind::TypeMDTokenMap:
-    return V.visitTypeMDTokenMap(R.getRecordData());
-  case ModuleSubstreamKind::MergedAssemblyInput:
-    return V.visitMergedAssemblyInput(R.getRecordData());
-  case ModuleSubstreamKind::CoffSymbolRVA:
-    return V.visitCoffSymbolRVA(R.getRecordData());
-  default:
-    return V.visitUnknown(R.getSubstreamKind(), R.getRecordData());
-  }
-}
diff --git a/llvm/lib/DebugInfo/PDB/CMakeLists.txt b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
index f87a0b0..bd35efb 100644
--- a/llvm/lib/DebugInfo/PDB/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
@@ -28,6 +28,8 @@
 endif()
 
 add_pdb_impl_folder(Native
+  Native/DbiModuleDescriptor.cpp
+  Native/DbiModuleDescriptorBuilder.cpp
   Native/DbiStream.cpp
   Native/DbiStreamBuilder.cpp
   Native/EnumTables.cpp
@@ -37,9 +39,7 @@
   Native/HashTable.cpp
   Native/InfoStream.cpp
   Native/InfoStreamBuilder.cpp
-  Native/ModInfo.cpp
-  Native/ModInfoBuilder.cpp
-  Native/ModStream.cpp
+  Native/ModuleDebugStream.cpp
   Native/NativeCompilandSymbol.cpp
   Native/NativeEnumModules.cpp
   Native/NativeExeSymbol.cpp
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptor.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptor.cpp
new file mode 100644
index 0000000..e04388b
--- /dev/null
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptor.cpp
@@ -0,0 +1,90 @@
+//===- DbiModuleDescriptor.cpp - PDB module information -------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include "llvm/Support/BinaryStreamReader.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/MathExtras.h"
+#include <cstdint>
+
+using namespace llvm;
+using namespace llvm::pdb;
+using namespace llvm::support;
+
+DbiModuleDescriptor::DbiModuleDescriptor() = default;
+
+DbiModuleDescriptor::DbiModuleDescriptor(const DbiModuleDescriptor &Info) =
+    default;
+
+DbiModuleDescriptor::~DbiModuleDescriptor() = default;
+
+Error DbiModuleDescriptor::initialize(BinaryStreamRef Stream,
+                                      DbiModuleDescriptor &Info) {
+  BinaryStreamReader Reader(Stream);
+  if (auto EC = Reader.readObject(Info.Layout))
+    return EC;
+
+  if (auto EC = Reader.readCString(Info.ModuleName))
+    return EC;
+
+  if (auto EC = Reader.readCString(Info.ObjFileName))
+    return EC;
+  return Error::success();
+}
+
+bool DbiModuleDescriptor::hasECInfo() const {
+  return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
+}
+
+uint16_t DbiModuleDescriptor::getTypeServerIndex() const {
+  return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
+         ModInfoFlags::TypeServerIndexShift;
+}
+
+uint16_t DbiModuleDescriptor::getModuleStreamIndex() const {
+  return Layout->ModDiStream;
+}
+
+uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const {
+  return Layout->SymBytes;
+}
+
+uint32_t DbiModuleDescriptor::getLineInfoByteSize() const {
+  return Layout->LineBytes;
+}
+
+uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const {
+  return Layout->C13Bytes;
+}
+
+uint32_t DbiModuleDescriptor::getNumberOfFiles() const {
+  return Layout->NumFiles;
+}
+
+uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const {
+  return Layout->SrcFileNameNI;
+}
+
+uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const {
+  return Layout->PdbFilePathNI;
+}
+
+StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; }
+
+StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; }
+
+uint32_t DbiModuleDescriptor::getRecordLength() const {
+  uint32_t M = ModuleName.str().size() + 1;
+  uint32_t O = ObjFileName.str().size() + 1;
+  uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
+  Size = alignTo(Size, 4);
+  return Size;
+}
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModInfoBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
similarity index 77%
rename from llvm/lib/DebugInfo/PDB/Native/ModInfoBuilder.cpp
rename to llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
index 73c45a9..91b0711 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModInfoBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
@@ -1,4 +1,4 @@
-//===- ModInfoBuilder.cpp - PDB Module Info Stream Creation -----*- C++ -*-===//
+//===- DbiModuleDescriptorBuilder.cpp - PDB Mod Info Creation ---*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,13 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Native/ModInfoBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/DebugInfo/MSF/MSFBuilder.h"
 #include "llvm/DebugInfo/MSF/MSFCommon.h"
 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
-#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
 #include "llvm/Support/BinaryItemStream.h"
@@ -45,33 +45,38 @@
   return Size;
 }
 
-ModInfoBuilder::ModInfoBuilder(StringRef ModuleName, uint32_t ModIndex,
-                               msf::MSFBuilder &Msf)
+DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName,
+                                                       uint32_t ModIndex,
+                                                       msf::MSFBuilder &Msf)
     : MSF(Msf), ModuleName(ModuleName) {
   Layout.Mod = ModIndex;
 }
 
-uint16_t ModInfoBuilder::getStreamIndex() const { return Layout.ModDiStream; }
+uint16_t DbiModuleDescriptorBuilder::getStreamIndex() const {
+  return Layout.ModDiStream;
+}
 
-void ModInfoBuilder::setObjFileName(StringRef Name) { ObjFileName = Name; }
+void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) {
+  ObjFileName = Name;
+}
 
-void ModInfoBuilder::addSymbol(CVSymbol Symbol) {
+void DbiModuleDescriptorBuilder::addSymbol(CVSymbol Symbol) {
   Symbols.push_back(Symbol);
   SymbolByteSize += Symbol.data().size();
 }
 
-void ModInfoBuilder::addSourceFile(StringRef Path) {
+void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) {
   SourceFiles.push_back(Path);
 }
 
-uint32_t ModInfoBuilder::calculateSerializedLength() const {
+uint32_t DbiModuleDescriptorBuilder::calculateSerializedLength() const {
   uint32_t L = sizeof(Layout);
   uint32_t M = ModuleName.size() + 1;
   uint32_t O = ObjFileName.size() + 1;
   return alignTo(L + M + O, sizeof(uint32_t));
 }
 
-void ModInfoBuilder::finalize() {
+void DbiModuleDescriptorBuilder::finalize() {
   Layout.C13Bytes = 0;
   Layout.FileNameOffs = 0; // TODO: Fix this
   Layout.Flags = 0;        // TODO: Fix this
@@ -87,7 +92,7 @@
   Layout.SymBytes = SymbolByteSize + sizeof(uint32_t);
 }
 
-Error ModInfoBuilder::finalizeMsfLayout() {
+Error DbiModuleDescriptorBuilder::finalizeMsfLayout() {
   this->Layout.ModDiStream = kInvalidStreamIndex;
   auto ExpectedSN = MSF.addStream(calculateDiSymbolStreamSize(SymbolByteSize));
   if (!ExpectedSN)
@@ -96,9 +101,9 @@
   return Error::success();
 }
 
-Error ModInfoBuilder::commit(BinaryStreamWriter &ModiWriter,
-                             const msf::MSFLayout &MsfLayout,
-                             WritableBinaryStreamRef MsfBuffer) {
+Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter,
+                                         const msf::MSFLayout &MsfLayout,
+                                         WritableBinaryStreamRef MsfBuffer) {
   // We write the Modi record to the `ModiWriter`, but we additionally write its
   // symbol stream to a brand new stream.
   if (auto EC = ModiWriter.writeObject(Layout))
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
index b9f5357..4802cc6 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStream.cpp
@@ -10,9 +10,9 @@
 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
 #include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h"
 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
-#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
@@ -252,11 +252,12 @@
   if (ModInfoSubstream.getLength() == 0)
     return Error::success();
 
-  // Since each ModInfo in the stream is a variable length, we have to iterate
+  // Since each DbiModuleDescriptor in the stream is a variable length, we have
+  // to iterate
   // them to know how many there actually are.
   BinaryStreamReader Reader(ModInfoSubstream);
 
-  VarStreamArray<ModInfo> ModInfoArray;
+  VarStreamArray<DbiModuleDescriptor> ModInfoArray;
   if (auto EC = Reader.readArray(ModInfoArray, ModInfoSubstream.getLength()))
     return EC;
   for (auto &Info : ModInfoArray) {
@@ -371,10 +372,12 @@
     NumSourceFiles += Count;
 
   // This is the array that in the reference implementation corresponds to
-  // `ModInfo::FileLayout::FileNameOffs`, which is commented there as being a
+  // `DbiModuleDescriptor::FileLayout::FileNameOffs`, which is commented there
+  // as being a
   // pointer. Due to the mentioned problems of pointers causing difficulty
   // when reading from the file on 64-bit systems, we continue to ignore that
-  // field in `ModInfo`, and instead build a vector of StringRefs and stores
+  // field in `DbiModuleDescriptor`, and instead build a vector of StringRefs
+  // and stores
   // them in `ModuleInfoEx`.  The value written to and read from the file is
   // not used anyway, it is only there as a way to store the offsets for the
   // purposes of later accessing the names at runtime.
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
index a203aea..62bda65 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -12,8 +12,8 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/DebugInfo/MSF/MSFBuilder.h"
 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"
 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
-#include "llvm/DebugInfo/PDB/Native/ModInfoBuilder.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Support/BinaryStreamWriter.h"
@@ -74,10 +74,11 @@
          calculateSectionMapStreamSize() + calculateDbgStreamsSize();
 }
 
-Expected<ModInfoBuilder &>
+Expected<DbiModuleDescriptorBuilder &>
 DbiStreamBuilder::addModuleInfo(StringRef ModuleName) {
   uint32_t Index = ModiList.size();
-  auto MIB = llvm::make_unique<ModInfoBuilder>(ModuleName, Index, Msf);
+  auto MIB =
+      llvm::make_unique<DbiModuleDescriptorBuilder>(ModuleName, Index, Msf);
   auto M = MIB.get();
   auto Result = ModiMap.insert(std::make_pair(ModuleName, std::move(MIB)));
 
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp
deleted file mode 100644
index 1405286..0000000
--- a/llvm/lib/DebugInfo/PDB/Native/ModInfo.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//===- ModInfo.cpp - PDB module information -------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
-#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/Support/BinaryStreamReader.h"
-#include "llvm/Support/Endian.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/MathExtras.h"
-#include <cstdint>
-
-using namespace llvm;
-using namespace llvm::pdb;
-using namespace llvm::support;
-
-ModInfo::ModInfo() = default;
-
-ModInfo::ModInfo(const ModInfo &Info) = default;
-
-ModInfo::~ModInfo() = default;
-
-Error ModInfo::initialize(BinaryStreamRef Stream, ModInfo &Info) {
-  BinaryStreamReader Reader(Stream);
-  if (auto EC = Reader.readObject(Info.Layout))
-    return EC;
-
-  if (auto EC = Reader.readCString(Info.ModuleName))
-    return EC;
-
-  if (auto EC = Reader.readCString(Info.ObjFileName))
-    return EC;
-  return Error::success();
-}
-
-bool ModInfo::hasECInfo() const {
-  return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
-}
-
-uint16_t ModInfo::getTypeServerIndex() const {
-  return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
-         ModInfoFlags::TypeServerIndexShift;
-}
-
-uint16_t ModInfo::getModuleStreamIndex() const { return Layout->ModDiStream; }
-
-uint32_t ModInfo::getSymbolDebugInfoByteSize() const {
-  return Layout->SymBytes;
-}
-
-uint32_t ModInfo::getLineInfoByteSize() const { return Layout->LineBytes; }
-
-uint32_t ModInfo::getC13LineInfoByteSize() const { return Layout->C13Bytes; }
-
-uint32_t ModInfo::getNumberOfFiles() const { return Layout->NumFiles; }
-
-uint32_t ModInfo::getSourceFileNameIndex() const {
-  return Layout->SrcFileNameNI;
-}
-
-uint32_t ModInfo::getPdbFilePathNameIndex() const {
-  return Layout->PdbFilePathNI;
-}
-
-StringRef ModInfo::getModuleName() const { return ModuleName; }
-
-StringRef ModInfo::getObjFileName() const { return ObjFileName; }
-
-uint32_t ModInfo::getRecordLength() const {
-  uint32_t M = ModuleName.str().size() + 1;
-  uint32_t O = ObjFileName.str().size() + 1;
-  uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
-  Size = alignTo(Size, 4);
-  return Size;
-}
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
similarity index 78%
rename from llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
rename to llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
index e87e2c4..8caa4b8 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
@@ -1,4 +1,4 @@
-//===- ModStream.cpp - PDB Module Info Stream Access ----------------------===//
+//===- ModuleDebugStream.cpp - PDB Module Info Stream Access --------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,10 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Native/ModStream.h"
+#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
+#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
@@ -24,13 +24,13 @@
 using namespace llvm::msf;
 using namespace llvm::pdb;
 
-ModStream::ModStream(const ModInfo &Module,
-                     std::unique_ptr<MappedBlockStream> Stream)
+ModuleDebugStream::ModuleDebugStream(const DbiModuleDescriptor &Module,
+                                     std::unique_ptr<MappedBlockStream> Stream)
     : Mod(Module), Stream(std::move(Stream)) {}
 
-ModStream::~ModStream() = default;
+ModuleDebugStream::~ModuleDebugStream() = default;
 
-Error ModStream::reload() {
+Error ModuleDebugStream::reload() {
   BinaryStreamReader Reader(*Stream);
 
   uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
@@ -70,20 +70,20 @@
 }
 
 iterator_range<codeview::CVSymbolArray::Iterator>
-ModStream::symbols(bool *HadError) const {
+ModuleDebugStream::symbols(bool *HadError) const {
   // It's OK if the stream is empty.
   if (SymbolsSubstream.getUnderlyingStream().getLength() == 0)
     return make_range(SymbolsSubstream.end(), SymbolsSubstream.end());
   return make_range(SymbolsSubstream.begin(HadError), SymbolsSubstream.end());
 }
 
-iterator_range<codeview::ModuleSubstreamArray::Iterator>
-ModStream::lines(bool *HadError) const {
+iterator_range<codeview::ModuleDebugFragmentArray::Iterator>
+ModuleDebugStream::lines(bool *HadError) const {
   return make_range(LineInfo.begin(HadError), LineInfo.end());
 }
 
-bool ModStream::hasLineInfo() const {
+bool ModuleDebugStream::hasLineInfo() const {
   return C13LinesSubstream.getLength() > 0 || LinesSubstream.getLength() > 0;
 }
 
-Error ModStream::commit() { return Error::success(); }
+Error ModuleDebugStream::commit() { return Error::success(); }
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 1abb368..9de3ddc 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -461,8 +461,9 @@
                                 size_t *length, int *status);
 #endif
 
-std::string LLVMSymbolizer::DemangleName(const std::string &Name,
-                                         const SymbolizableModule *ModInfo) {
+std::string
+LLVMSymbolizer::DemangleName(const std::string &Name,
+                             const SymbolizableModule *DbiModuleDescriptor) {
 #if !defined(_MSC_VER)
   // We can spoil names of symbols with C linkage, so use an heuristic
   // approach to check if the name should be demangled.
@@ -490,7 +491,7 @@
     return (result == 0) ? Name : std::string(DemangledName);
   }
 #endif
-  if (ModInfo && ModInfo->isWin32Module())
+  if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module())
     return std::string(demanglePE32ExternCFunc(Name));
   return Name;
 }