Put PDB parsing code into a pdb namespace.

llvm-svn: 268072
diff --git a/llvm/lib/DebugInfo/PDB/CMakeLists.txt b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
index 93960c8..d6a3d2b 100644
--- a/llvm/lib/DebugInfo/PDB/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
@@ -31,9 +31,9 @@
   Raw/MappedBlockStream.cpp
   Raw/ModInfo.cpp
   Raw/PDBFile.cpp
-  Raw/PDBDbiStream.cpp
-  Raw/PDBInfoStream.cpp
-  Raw/PDBNameMap.cpp
+  Raw/DbiStream.cpp
+  Raw/InfoStream.cpp
+  Raw/NameMap.cpp
   Raw/RawSession.cpp
   Raw/StreamReader.cpp)
 
diff --git a/llvm/lib/DebugInfo/PDB/PDB.cpp b/llvm/lib/DebugInfo/PDB/PDB.cpp
index c4dd982..39b4b94 100644
--- a/llvm/lib/DebugInfo/PDB/PDB.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDB.cpp
@@ -25,7 +25,7 @@
                                    std::unique_ptr<IPDBSession> &Session) {
   // Create the correct concrete instance type based on the value of Type.
   if (Type == PDB_ReaderType::Raw)
-    return RawSession::createFromPdb(Path, Session);
+    return pdb::RawSession::createFromPdb(Path, Session);
 
 #if HAVE_DIA_SDK
   return DIASession::createFromPdb(Path, Session);
@@ -38,7 +38,7 @@
                                    std::unique_ptr<IPDBSession> &Session) {
   // Create the correct concrete instance type based on the value of Type.
   if (Type == PDB_ReaderType::Raw)
-    return RawSession::createFromExe(Path, Session);
+    return pdb::RawSession::createFromExe(Path, Session);
 
 #if HAVE_DIA_SDK
   return DIASession::createFromExe(Path, Session);
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp
index 20abe4c..d8b78ec 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ByteStream.cpp
@@ -11,6 +11,7 @@
 #include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
 ByteStream::ByteStream() : Owned(false) {}
 
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBDbiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
similarity index 85%
rename from llvm/lib/DebugInfo/PDB/Raw/PDBDbiStream.cpp
rename to llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
index 6c15385..7762fa3 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBDbiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStream.cpp
@@ -1,4 +1,4 @@
-//===- PDBDbiStream.cpp - PDB Dbi Stream (Stream 3) Access ----------------===//
+//===- DbiStream.cpp - PDB Dbi Stream (Stream 3) Access -------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,14 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Raw/PDBDbiStream.h"
+#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
+#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
 #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
-#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
-#include "llvm/DebugInfo/PDB/Raw/PDBRawConstants.h"
+#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 using namespace llvm::support;
 
 namespace {
@@ -45,10 +46,10 @@
 const uint16_t BuildMajorShift = 8;
 }
 
-struct PDBDbiStream::HeaderInfo {
+struct DbiStream::HeaderInfo {
   little32_t VersionSignature;
   ulittle32_t VersionHeader;
-  ulittle32_t Age; // Should match PDBInfoStream.
+  ulittle32_t Age;                  // Should match InfoStream.
   ulittle16_t GSSyms;               // Number of global symbols
   ulittle16_t BuildNumber;          // See DbiBuildNo structure.
   ulittle16_t PSSyms;               // Number of public symbols
@@ -59,23 +60,23 @@
   little32_t SecContrSubstreamSize; // Size of sec. contribution stream
   little32_t SectionMapSize;        // Size of sec. map substream
   little32_t FileInfoSize;          // Size of file info substream
-  little32_t TypeServerSize;        // Size of type server map
-  ulittle32_t MFCTypeServerIndex;   // Index of MFC Type Server
-  little32_t OptionalDbgHdrSize;    // Size of DbgHeader info
-  little32_t ECSubstreamSize;       // Size of EC stream (what is EC?)
-  ulittle16_t Flags;                // See DbiFlags enum.
-  ulittle16_t MachineType;          // See PDB_MachineType enum.
+  little32_t TypeServerSize;      // Size of type server map
+  ulittle32_t MFCTypeServerIndex; // Index of MFC Type Server
+  little32_t OptionalDbgHdrSize;  // Size of DbgHeader info
+  little32_t ECSubstreamSize;     // Size of EC stream (what is EC?)
+  ulittle16_t Flags;              // See DbiFlags enum.
+  ulittle16_t MachineType;        // See PDB_MachineType enum.
 
   ulittle32_t Reserved; // Pad to 64 bytes
 };
 
-PDBDbiStream::PDBDbiStream(PDBFile &File) : Pdb(File), Stream(3, File) {
+DbiStream::DbiStream(PDBFile &File) : Pdb(File), Stream(3, File) {
   static_assert(sizeof(HeaderInfo) == 64, "Invalid HeaderInfo size!");
 }
 
-PDBDbiStream::~PDBDbiStream() {}
+DbiStream::~DbiStream() {}
 
-std::error_code PDBDbiStream::reload() {
+std::error_code DbiStream::reload() {
   StreamReader Reader(Stream);
 
   Header.reset(new HeaderInfo());
@@ -127,7 +128,8 @@
   for (auto Info : Range)
     ModuleInfos.push_back(ModuleInfoEx(Info));
 
-  if ((EC = SecContrSubstream.initialize(Reader, Header->SecContrSubstreamSize)))
+  if ((EC =
+           SecContrSubstream.initialize(Reader, Header->SecContrSubstreamSize)))
     return EC;
   if ((EC = SecMapSubstream.initialize(Reader, Header->SectionMapSize)))
     return EC;
@@ -149,47 +151,45 @@
   return std::error_code();
 }
 
-PdbRaw_DbiVer PDBDbiStream::getDbiVersion() const {
+PdbRaw_DbiVer DbiStream::getDbiVersion() const {
   uint32_t Value = Header->VersionHeader;
   return static_cast<PdbRaw_DbiVer>(Value);
 }
 
-uint32_t PDBDbiStream::getAge() const { return Header->Age; }
+uint32_t DbiStream::getAge() const { return Header->Age; }
 
-bool PDBDbiStream::isIncrementallyLinked() const {
+bool DbiStream::isIncrementallyLinked() const {
   return (Header->Flags & FlagIncrementalMask) != 0;
 }
 
-bool PDBDbiStream::hasCTypes() const {
+bool DbiStream::hasCTypes() const {
   return (Header->Flags & FlagHasCTypesMask) != 0;
 }
 
-bool PDBDbiStream::isStripped() const {
+bool DbiStream::isStripped() const {
   return (Header->Flags & FlagStrippedMask) != 0;
 }
 
-uint16_t PDBDbiStream::getBuildMajorVersion() const {
+uint16_t DbiStream::getBuildMajorVersion() const {
   return (Header->BuildNumber & BuildMajorMask) >> BuildMajorShift;
 }
 
-uint16_t PDBDbiStream::getBuildMinorVersion() const {
+uint16_t DbiStream::getBuildMinorVersion() const {
   return (Header->BuildNumber & BuildMinorMask) >> BuildMinorShift;
 }
 
-uint32_t PDBDbiStream::getPdbDllVersion() const {
-  return Header->PdbDllVersion;
-}
+uint32_t DbiStream::getPdbDllVersion() const { return Header->PdbDllVersion; }
 
-uint32_t PDBDbiStream::getNumberOfSymbols() const { return Header->SymRecords; }
+uint32_t DbiStream::getNumberOfSymbols() const { return Header->SymRecords; }
 
-PDB_Machine PDBDbiStream::getMachineType() const {
+PDB_Machine DbiStream::getMachineType() const {
   uint16_t Machine = Header->MachineType;
   return static_cast<PDB_Machine>(Machine);
 }
 
-ArrayRef<ModuleInfoEx> PDBDbiStream::modules() const { return ModuleInfos; }
+ArrayRef<ModuleInfoEx> DbiStream::modules() const { return ModuleInfos; }
 
-std::error_code PDBDbiStream::initializeFileInfo() {
+std::error_code DbiStream::initializeFileInfo() {
   struct FileInfoSubstreamHeader {
     ulittle16_t NumModules;     // Total # of modules, should match number of
                                 // records in the ModuleInfo substream.
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBInfoStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
similarity index 64%
rename from llvm/lib/DebugInfo/PDB/Raw/PDBInfoStream.cpp
rename to llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
index 90397db..c1b4737 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBInfoStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
@@ -1,4 +1,4 @@
-//===- PDBInfoStream.cpp - PDB Info Stream (Stream 1) Access ----*- C++ -*-===//
+//===- InfoStream.cpp - PDB Info Stream (Stream 1) Access -------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,16 +7,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
+#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
-PDBInfoStream::PDBInfoStream(PDBFile &File) : Pdb(File), Stream(1, File) {}
+InfoStream::InfoStream(PDBFile &File) : Pdb(File), Stream(1, File) {}
 
-std::error_code PDBInfoStream::reload() {
+std::error_code InfoStream::reload() {
   StreamReader Reader(Stream);
 
   support::ulittle32_t Value;
@@ -38,19 +39,19 @@
   return std::error_code();
 }
 
-uint32_t PDBInfoStream::getNamedStreamIndex(llvm::StringRef Name) const {
+uint32_t InfoStream::getNamedStreamIndex(llvm::StringRef Name) const {
   uint32_t Result;
   if (!NamedStreams.tryGetValue(Name, Result))
     return 0;
   return Result;
 }
 
-PdbRaw_ImplVer PDBInfoStream::getVersion() const {
+PdbRaw_ImplVer InfoStream::getVersion() const {
   return static_cast<PdbRaw_ImplVer>(Version);
 }
 
-uint32_t PDBInfoStream::getSignature() const { return Signature; }
+uint32_t InfoStream::getSignature() const { return Signature; }
 
-uint32_t PDBInfoStream::getAge() const { return Age; }
+uint32_t InfoStream::getAge() const { return Age; }
 
-PDB_UniqueId PDBInfoStream::getGuid() const { return Guid; }
+PDB_UniqueId InfoStream::getGuid() const { return Guid; }
diff --git a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
index ed954bb..860f763 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
@@ -11,6 +11,7 @@
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
 MappedBlockStream::MappedBlockStream(uint32_t StreamIdx, const PDBFile &File) : Pdb(File) {
   StreamLength = Pdb.getStreamByteSize(StreamIdx);
diff --git a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
index 4634cb0..362c402 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/ModInfo.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/Endian.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 using namespace llvm::support;
 
 namespace {
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
similarity index 92%
rename from llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
rename to llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
index 4dd8cf0..28dc67a 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBNameMap.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
@@ -1,4 +1,4 @@
-//===- PDBNameMap.cpp - PDB Name Map ----------------------------*- C++ -*-===//
+//===- NameMap.cpp - PDB Name Map -------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,15 +7,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/DebugInfo/PDB/Raw/PDBNameMap.h"
+#include "llvm/DebugInfo/PDB/Raw/NameMap.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
-PDBNameMap::PDBNameMap() {}
+NameMap::NameMap() {}
 
-std::error_code PDBNameMap::load(StreamReader &Stream) {
+std::error_code NameMap::load(StreamReader &Stream) {
 
   // This is some sort of weird string-set/hash table encoded in the stream.
   // It starts with the number of bytes in the table.
@@ -100,7 +101,7 @@
   return std::error_code();
 }
 
-bool PDBNameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
+bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
   auto Iter = Mapping.find(Name);
   if (Iter == Mapping.end())
     return false;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index 0adabfe..6e5f536 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -9,12 +9,13 @@
 
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/DebugInfo/PDB/Raw/PDBDbiStream.h"
-#include "llvm/DebugInfo/PDB/Raw/PDBInfoStream.h"
+#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
+#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
 namespace {
 static const char Magic[] = {'M',  'i',  'c',    'r', 'o', 's',  'o',  'f',
@@ -45,7 +46,7 @@
 };
 }
 
-struct llvm::PDBFileContext {
+struct llvm::pdb::PDBFileContext {
   std::unique_ptr<MemoryBuffer> Buffer;
   const SuperBlock *SB;
   std::vector<uint32_t> StreamSizes;
@@ -244,18 +245,18 @@
       getNumDirectoryBlocks());
 }
 
-PDBInfoStream &PDBFile::getPDBInfoStream() {
-  if (!InfoStream) {
-    InfoStream.reset(new PDBInfoStream(*this));
-    InfoStream->reload();
+InfoStream &PDBFile::getPDBInfoStream() {
+  if (!Info) {
+    Info.reset(new InfoStream(*this));
+    Info->reload();
   }
-  return *InfoStream;
+  return *Info;
 }
 
-PDBDbiStream &PDBFile::getPDBDbiStream() {
-  if (!DbiStream) {
-    DbiStream.reset(new PDBDbiStream(*this));
-    DbiStream->reload();
+DbiStream &PDBFile::getPDBDbiStream() {
+  if (!Dbi) {
+    Dbi.reset(new DbiStream(*this));
+    Dbi->reload();
   }
-  return *DbiStream;
+  return *Dbi;
 }
diff --git a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
index dcdbcb4..330e439 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
 RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile)
     : Pdb(std::move(PdbFile)) {}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp b/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp
index 707f77f..42fe452 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/StreamReader.cpp
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
 
 using namespace llvm;
+using namespace llvm::pdb;
 
 StreamReader::StreamReader(const StreamInterface &S) : Stream(S), Offset(0) {}