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" |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h" |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 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 | |
| 22 | NativeEnumModules::NativeEnumModules(NativeSession &PDBSession, |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 23 | const DbiModuleList &Modules, |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 24 | uint32_t Index) |
| 25 | : Session(PDBSession), Modules(Modules), Index(Index) {} |
| 26 | |
| 27 | uint32_t NativeEnumModules::getChildCount() const { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 28 | return static_cast<uint32_t>(Modules.getModuleCount()); |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | std::unique_ptr<PDBSymbol> |
| 32 | NativeEnumModules::getChildAtIndex(uint32_t Index) const { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 33 | if (Index >= Modules.getModuleCount()) |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 34 | return nullptr; |
Adrian McCarthy | bf0afc3 | 2017-06-28 22:47:40 +0000 | [diff] [blame] | 35 | return Session.createCompilandSymbol(Modules.getModuleDescriptor(Index)); |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 39 | if (Index >= Modules.getModuleCount()) |
Adrian McCarthy | 65d2688 | 2017-03-15 20:17:58 +0000 | [diff] [blame] | 40 | return nullptr; |
| 41 | return getChildAtIndex(Index++); |
| 42 | } |
| 43 | |
| 44 | void NativeEnumModules::reset() { Index = 0; } |
| 45 | |
| 46 | NativeEnumModules *NativeEnumModules::clone() const { |
| 47 | return new NativeEnumModules(Session, Modules, Index); |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | } |