1 //==- 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"
13 #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
14 #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 
19 namespace llvm {
20 namespace pdb {
21 
NativeEnumModules(NativeSession & PDBSession,const DbiModuleList & Modules,uint32_t Index)22 NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
23                                      const DbiModuleList &Modules,
24                                      uint32_t Index)
25     : Session(PDBSession), Modules(Modules), Index(Index) {}
26 
getChildCount() const27 uint32_t NativeEnumModules::getChildCount() const {
28   return static_cast<uint32_t>(Modules.getModuleCount());
29 }
30 
31 std::unique_ptr<PDBSymbol>
getChildAtIndex(uint32_t Index) const32 NativeEnumModules::getChildAtIndex(uint32_t Index) const {
33   if (Index >= Modules.getModuleCount())
34     return nullptr;
35   return Session.createCompilandSymbol(Modules.getModuleDescriptor(Index));
36 }
37 
getNext()38 std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
39   if (Index >= Modules.getModuleCount())
40     return nullptr;
41   return getChildAtIndex(Index++);
42 }
43 
reset()44 void NativeEnumModules::reset() { Index = 0; }
45 
clone() const46 NativeEnumModules *NativeEnumModules::clone() const {
47   return new NativeEnumModules(Session, Modules, Index);
48 }
49 
50 }
51 }
52