DebugInfoPDB: Make the symbol base case hold an IPDBSession ref.

Dumping a symbol often requires access to data that isn't inside
the symbol hierarchy, but which is only accessible through the
top-level session.  This patch is a pure interface change to give
symbols a reference to the session.

llvm-svn: 228542
diff --git a/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp b/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp
index 5a86d4c..4f838a0 100644
--- a/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp
@@ -12,6 +12,9 @@
 
 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
+
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h"
@@ -66,6 +69,21 @@
     return ReturnType();                                                       \
   }
 
+class MockSession : public IPDBSession {
+  uint64_t getLoadAddress() const override { return 0; }
+  void setLoadAddress(uint64_t Address) override {}
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override {
+    return nullptr;
+  }
+  std::unique_ptr<PDBSymbol> getSymbolById() const override { return nullptr; }
+  std::unique_ptr<IPDBSourceFile> getSourceFileById() const override {
+    return nullptr;
+  }
+  std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override {
+    return nullptr;
+  }
+};
+
 class MockRawSymbol : public IPDBRawSymbol {
 public:
   MockRawSymbol(PDB_SymType SymType) : Type(SymType) {}
@@ -257,6 +275,8 @@
   std::unordered_map<PDB_SymType, std::unique_ptr<PDBSymbol>> SymbolMap;
 
   void SetUp() override {
+    Session.reset(new MockSession());
+
     InsertItemWithTag(PDB_SymType::None);
     InsertItemWithTag(PDB_SymType::Exe);
     InsertItemWithTag(PDB_SymType::Compiland);
@@ -291,14 +311,6 @@
     InsertItemWithTag(PDB_SymType::Max);
   }
 
-private:
-  void InsertItemWithTag(PDB_SymType Tag) {
-    auto RawSymbol = std::unique_ptr<IPDBRawSymbol>(new MockRawSymbol(Tag));
-    auto Symbol = PDBSymbol::create(std::move(RawSymbol));
-    SymbolMap.insert(std::make_pair(Tag, std::move(Symbol)));
-  }
-
-public:
   template <class ExpectedType> void VerifyDyncast(PDB_SymType Tag) {
     for (auto item = SymbolMap.begin(); item != SymbolMap.end(); ++item) {
       EXPECT_EQ(item->first == Tag, llvm::isa<ExpectedType>(*item->second));
@@ -314,6 +326,15 @@
       EXPECT_EQ(should_match, llvm::isa<PDBSymbolUnknown>(*item->second));
     }
   }
+
+private:
+  std::unique_ptr<IPDBSession> Session;
+
+  void InsertItemWithTag(PDB_SymType Tag) {
+    auto RawSymbol = std::unique_ptr<IPDBRawSymbol>(new MockRawSymbol(Tag));
+    auto Symbol = PDBSymbol::create(*Session, std::move(RawSymbol));
+    SymbolMap.insert(std::make_pair(Tag, std::move(Symbol)));
+  }
 };
 
 TEST_F(PDBApiTest, Dyncast) {