xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeEnumSymbols.cpp (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1 //==- NativeEnumSymbols.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/NativeEnumSymbols.h"
10 
11 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
12 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
16 
17 using namespace llvm;
18 using namespace llvm::codeview;
19 using namespace llvm::pdb;
20 
21 NativeEnumSymbols::NativeEnumSymbols(NativeSession &PDBSession,
22                                      std::vector<SymIndexId> Symbols)
23     : Symbols(std::move(Symbols)), Index(0), Session(PDBSession) {}
24 
25 uint32_t NativeEnumSymbols::getChildCount() const {
26   return static_cast<uint32_t>(Symbols.size());
27 }
28 
29 std::unique_ptr<PDBSymbol>
30 NativeEnumSymbols::getChildAtIndex(uint32_t N) const {
31   if (N < Symbols.size()) {
32     return Session.getSymbolCache().getSymbolById(Symbols[N]);
33   }
34   return nullptr;
35 }
36 
37 std::unique_ptr<PDBSymbol> NativeEnumSymbols::getNext() {
38   return getChildAtIndex(Index++);
39 }
40 
41 void NativeEnumSymbols::reset() { Index = 0; }
42