xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric //==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
12*81ad6265SDimitry Andric #include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
130b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbol.h"
140b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric namespace llvm {
170b57cec5SDimitry Andric namespace pdb {
180b57cec5SDimitry Andric 
NativeEnumModules(NativeSession & PDBSession,uint32_t Index)190b57cec5SDimitry Andric NativeEnumModules::NativeEnumModules(NativeSession &PDBSession, uint32_t Index)
200b57cec5SDimitry Andric     : Session(PDBSession), Index(Index) {}
210b57cec5SDimitry Andric 
getChildCount() const220b57cec5SDimitry Andric uint32_t NativeEnumModules::getChildCount() const {
230b57cec5SDimitry Andric   return Session.getSymbolCache().getNumCompilands();
240b57cec5SDimitry Andric }
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric std::unique_ptr<PDBSymbol>
getChildAtIndex(uint32_t N) const270b57cec5SDimitry Andric NativeEnumModules::getChildAtIndex(uint32_t N) const {
280b57cec5SDimitry Andric   return Session.getSymbolCache().getOrCreateCompiland(N);
290b57cec5SDimitry Andric }
300b57cec5SDimitry Andric 
getNext()310b57cec5SDimitry Andric std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
320b57cec5SDimitry Andric   if (Index >= getChildCount())
330b57cec5SDimitry Andric     return nullptr;
340b57cec5SDimitry Andric   return getChildAtIndex(Index++);
350b57cec5SDimitry Andric }
360b57cec5SDimitry Andric 
reset()370b57cec5SDimitry Andric void NativeEnumModules::reset() { Index = 0; }
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric }
400b57cec5SDimitry Andric }
41