llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
Adrian McCarthy a39a2bd7c1 Introduce symbol cache to PDB NativeSession
Instead of creating symbols directly in the findChildren methods of the native
symbol implementations, they will rely on the NativeSession to act as a factory
for these types.  This lets NativeSession cache the NativeRawSymbols in its
new symbol cache and makes that cache the source of unique IDs for the symbols.

Right now, this affects only NativeCompilandSymbols.  There's no external
change yet, so I think the existing tests are still sufficient.  Coming soon
are patches to extend this to built-in types and enums.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306610 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-28 22:47:40 +00:00

52 lines
1.6 KiB
C++

//==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- 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/PDB/Native/NativeEnumModules.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
namespace llvm {
namespace pdb {
NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
const DbiModuleList &Modules,
uint32_t Index)
: Session(PDBSession), Modules(Modules), Index(Index) {}
uint32_t NativeEnumModules::getChildCount() const {
return static_cast<uint32_t>(Modules.getModuleCount());
}
std::unique_ptr<PDBSymbol>
NativeEnumModules::getChildAtIndex(uint32_t Index) const {
if (Index >= Modules.getModuleCount())
return nullptr;
return Session.createCompilandSymbol(Modules.getModuleDescriptor(Index));
}
std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
if (Index >= Modules.getModuleCount())
return nullptr;
return getChildAtIndex(Index++);
}
void NativeEnumModules::reset() { Index = 0; }
NativeEnumModules *NativeEnumModules::clone() const {
return new NativeEnumModules(Session, Modules, Index);
}
}
}