xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1 //==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
10 
11 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
12 #include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
15 
16 namespace llvm {
17 namespace pdb {
18 
NativeEnumModules(NativeSession & PDBSession,uint32_t Index)19 NativeEnumModules::NativeEnumModules(NativeSession &PDBSession, uint32_t Index)
20     : Session(PDBSession), Index(Index) {}
21 
getChildCount() const22 uint32_t NativeEnumModules::getChildCount() const {
23   return Session.getSymbolCache().getNumCompilands();
24 }
25 
26 std::unique_ptr<PDBSymbol>
getChildAtIndex(uint32_t N) const27 NativeEnumModules::getChildAtIndex(uint32_t N) const {
28   return Session.getSymbolCache().getOrCreateCompiland(N);
29 }
30 
getNext()31 std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
32   if (Index >= getChildCount())
33     return nullptr;
34   return getChildAtIndex(Index++);
35 }
36 
reset()37 void NativeEnumModules::reset() { Index = 0; }
38 
39 }
40 }
41