blob: 97319fd77d117522ca94017b4d82bc39faf6d263 [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;
Zachary Turner1eb9a022017-05-04 23:53:29 +000035 return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(
36 Session, std::unique_ptr<IPDBRawSymbol>(new NativeCompilandSymbol(
37 Session, Modules.getModuleDescriptor(Index)))));
Adrian McCarthy65d26882017-03-15 20:17:58 +000038}
39
40std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
Zachary Turner1eb9a022017-05-04 23:53:29 +000041 if (Index >= Modules.getModuleCount())
Adrian McCarthy65d26882017-03-15 20:17:58 +000042 return nullptr;
43 return getChildAtIndex(Index++);
44}
45
46void NativeEnumModules::reset() { Index = 0; }
47
48NativeEnumModules *NativeEnumModules::clone() const {
49 return new NativeEnumModules(Session, Modules, Index);
50}
51
52}
53}