NativeEnumSymbols.cpp 1.4 KB

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