forked from OSchip/llvm-project
Make IPDBSession::getGlobalScope a non-const method
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. llvm-svn: 306041
This commit is contained in:
parent
41a34e4111
commit
6a4b080a5f
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
uint64_t getLoadAddress() const override;
|
uint64_t getLoadAddress() const override;
|
||||||
void setLoadAddress(uint64_t Address) 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> getSymbolById(uint32_t SymbolId) const override;
|
||||||
|
|
||||||
std::unique_ptr<PDBSymbol>
|
std::unique_ptr<PDBSymbol>
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
virtual uint64_t getLoadAddress() const = 0;
|
virtual uint64_t getLoadAddress() const = 0;
|
||||||
virtual void setLoadAddress(uint64_t Address) = 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;
|
virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
|
|
||||||
uint64_t getLoadAddress() const override;
|
uint64_t getLoadAddress() const override;
|
||||||
void setLoadAddress(uint64_t Address) 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> getSymbolById(uint32_t SymbolId) const override;
|
||||||
|
|
||||||
std::unique_ptr<PDBSymbol>
|
std::unique_ptr<PDBSymbol>
|
||||||
|
|
|
@ -151,7 +151,7 @@ void DIASession::setLoadAddress(uint64_t Address) {
|
||||||
Session->put_loadAddress(Address);
|
Session->put_loadAddress(Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() const {
|
std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() {
|
||||||
CComPtr<IDiaSymbol> GlobalScope;
|
CComPtr<IDiaSymbol> GlobalScope;
|
||||||
if (S_OK != Session->get_globalScope(&GlobalScope))
|
if (S_OK != Session->get_globalScope(&GlobalScope))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -70,12 +70,11 @@ uint64_t NativeSession::getLoadAddress() const { return 0; }
|
||||||
|
|
||||||
void NativeSession::setLoadAddress(uint64_t Address) {}
|
void NativeSession::setLoadAddress(uint64_t Address) {}
|
||||||
|
|
||||||
std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() const {
|
std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() {
|
||||||
auto RawSymbol =
|
auto RawSymbol = llvm::make_unique<NativeExeSymbol>(*this);
|
||||||
llvm::make_unique<NativeExeSymbol>(const_cast<NativeSession &>(*this));
|
|
||||||
auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
|
auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
|
||||||
std::unique_ptr<PDBSymbolExe> ExeSymbol(
|
std::unique_ptr<PDBSymbolExe> ExeSymbol(
|
||||||
static_cast<PDBSymbolExe *>(PdbSymbol.release()));
|
static_cast<PDBSymbolExe *>(PdbSymbol.release()));
|
||||||
return ExeSymbol;
|
return ExeSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,7 @@ namespace {
|
||||||
class MockSession : public IPDBSession {
|
class MockSession : public IPDBSession {
|
||||||
uint64_t getLoadAddress() const override { return 0; }
|
uint64_t getLoadAddress() const override { return 0; }
|
||||||
void setLoadAddress(uint64_t Address) override {}
|
void setLoadAddress(uint64_t Address) override {}
|
||||||
std::unique_ptr<PDBSymbolExe> getGlobalScope() const override {
|
std::unique_ptr<PDBSymbolExe> getGlobalScope() override { return nullptr; }
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override {
|
std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue