]> granicus.if.org Git - llvm/commitdiff
Make IPDBSession::getGlobalScope a non-const method
authorAdrian McCarthy <amccarth@google.com>
Thu, 22 Jun 2017 18:42:23 +0000 (18:42 +0000)
committerAdrian McCarthy <amccarth@google.com>
Thu, 22 Jun 2017 18:42:23 +0000 (18:42 +0000)
There doesn't seem to be a compelling reason why this method should be const
other than it was possible with the DIA implementation.  The native session
is going to act as a symbol factory and cache.  This could be acheived with
mutable (and the existing const_cast), but it seems cleaner to accept that
this method affects the state of the session.

This change eliminates an existing const_cast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306041 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/PDB/DIA/DIASession.h
include/llvm/DebugInfo/PDB/IPDBSession.h
include/llvm/DebugInfo/PDB/Native/NativeSession.h
lib/DebugInfo/PDB/DIA/DIASession.cpp
lib/DebugInfo/PDB/Native/NativeSession.cpp
unittests/DebugInfo/PDB/PDBApiTest.cpp

index 3f5818631e7bc1c9c1c56a868ab18fdf9da3b7a6..350442556bef88b176fbd45ee3b738bee6ae89f6 100644 (file)
@@ -31,7 +31,7 @@ public:
 
   uint64_t getLoadAddress() const override;
   void setLoadAddress(uint64_t Address) override;
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
 
   std::unique_ptr<PDBSymbol>
index 85d9fe1248599cb92a8bf2650923e18902601d1b..cf195095c8d221c01ed95cf276df6557651ce135 100644 (file)
@@ -29,7 +29,7 @@ public:
 
   virtual uint64_t getLoadAddress() const = 0;
   virtual void setLoadAddress(uint64_t Address) = 0;
-  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
+  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;
   virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
 
   template <typename T>
index e6da266f796d545a7c96f8b64f4b6ffa5c88e314..bbe207738e02115ce599ebef63051ecdf9faebac 100644 (file)
@@ -32,7 +32,7 @@ public:
 
   uint64_t getLoadAddress() const override;
   void setLoadAddress(uint64_t Address) override;
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
 
   std::unique_ptr<PDBSymbol>
index ef47b92b4f2f31bfca62cf5e4690fdedc6e69541..ef9390cda312700c5693683b99f1ab6cee171c26 100644 (file)
@@ -151,7 +151,7 @@ void DIASession::setLoadAddress(uint64_t Address) {
   Session->put_loadAddress(Address);
 }
 
-std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() const {
+std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() {
   CComPtr<IDiaSymbol> GlobalScope;
   if (S_OK != Session->get_globalScope(&GlobalScope))
     return nullptr;
index 7e6843bceb7db330d0d3770951ef944b1c92e142..c59cf866d1cd4b2f9d20a80d40ed334e0977dbad 100644 (file)
@@ -70,12 +70,11 @@ uint64_t NativeSession::getLoadAddress() const { return 0; }
 
 void NativeSession::setLoadAddress(uint64_t Address) {}
 
-std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() const {
-  auto RawSymbol =
-      llvm::make_unique<NativeExeSymbol>(const_cast<NativeSession &>(*this));
+std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() {
+  auto RawSymbol = llvm::make_unique<NativeExeSymbol>(*this);
   auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
   std::unique_ptr<PDBSymbolExe> ExeSymbol(
-    static_cast<PDBSymbolExe *>(PdbSymbol.release()));
+      static_cast<PDBSymbolExe *>(PdbSymbol.release()));
   return ExeSymbol;
 }
 
index 6afe83cd90dd51339decda4634f3034455b0ca4e..257a8879e439cace77a1bfb9410b7d71f7467f73 100644 (file)
@@ -63,9 +63,7 @@ namespace {
 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<PDBSymbolExe> getGlobalScope() override { return nullptr; }
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override {
     return nullptr;
   }