blob: a65782e2d4fc645826c012b909b28adbff663505 [file] [log] [blame]
Adrian McCarthy65d26882017-03-15 20:17:58 +00001//==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
11
12#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turner1eb9a022017-05-04 23:53:29 +000013#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
Adrian McCarthy65d26882017-03-15 20:17:58 +000014#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
15#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
16#include "llvm/DebugInfo/PDB/PDBSymbol.h"
17#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
18
19namespace llvm {
20namespace pdb {
21
22NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
Zachary Turner1eb9a022017-05-04 23:53:29 +000023 const DbiModuleList &Modules,
Adrian McCarthy65d26882017-03-15 20:17:58 +000024 uint32_t Index)
25 : Session(PDBSession), Modules(Modules), Index(Index) {}
26
27uint32_t NativeEnumModules::getChildCount() const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000028 return static_cast<uint32_t>(Modules.getModuleCount());
Adrian McCarthy65d26882017-03-15 20:17:58 +000029}
30
31std::unique_ptr<PDBSymbol>
32NativeEnumModules::getChildAtIndex(uint32_t Index) const {
Zachary Turner1eb9a022017-05-04 23:53:29 +000033 if (Index >= Modules.getModuleCount())
Adrian McCarthy65d26882017-03-15 20:17:58 +000034 return nullptr;
Adrian McCarthybf0afc32017-06-28 22:47:40 +000035 return Session.createCompilandSymbol(Modules.getModuleDescriptor(Index));
Adrian McCarthy65d26882017-03-15 20:17:58 +000036}
37
38std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
Zachary Turner1eb9a022017-05-04 23:53:29 +000039 if (Index >= Modules.getModuleCount())
Adrian McCarthy65d26882017-03-15 20:17:58 +000040 return nullptr;
41 return getChildAtIndex(Index++);
42}
43
44void NativeEnumModules::reset() { Index = 0; }
45
46NativeEnumModules *NativeEnumModules::clone() const {
47 return new NativeEnumModules(Session, Modules, Index);
48}
49
50}
51}