Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame^] | 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/NativeCompilandSymbol.h" |
| 14 | #include "llvm/DebugInfo/PDB/Native/NativeSession.h" |
| 15 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 16 | #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" |
| 17 | |
| 18 | namespace llvm { |
| 19 | namespace pdb { |
| 20 | |
| 21 | NativeEnumModules::NativeEnumModules(NativeSession &PDBSession, |
| 22 | ArrayRef<ModuleInfoEx> Modules, |
| 23 | uint32_t Index) |
| 24 | : Session(PDBSession), Modules(Modules), Index(Index) {} |
| 25 | |
| 26 | uint32_t NativeEnumModules::getChildCount() const { |
| 27 | return static_cast<uint32_t>(Modules.size()); |
| 28 | } |
| 29 | |
| 30 | std::unique_ptr<PDBSymbol> |
| 31 | NativeEnumModules::getChildAtIndex(uint32_t Index) const { |
| 32 | if (Index >= Modules.size()) |
| 33 | return nullptr; |
| 34 | return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(Session, |
| 35 | std::unique_ptr<IPDBRawSymbol>( |
| 36 | new NativeCompilandSymbol(Session, Modules[Index])))); |
| 37 | } |
| 38 | |
| 39 | std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() { |
| 40 | if (Index >= Modules.size()) |
| 41 | return nullptr; |
| 42 | return getChildAtIndex(Index++); |
| 43 | } |
| 44 | |
| 45 | void NativeEnumModules::reset() { Index = 0; } |
| 46 | |
| 47 | NativeEnumModules *NativeEnumModules::clone() const { |
| 48 | return new NativeEnumModules(Session, Modules, Index); |
| 49 | } |
| 50 | |
| 51 | } |
| 52 | } |