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