NativeEnumLineNumbers.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //==- NativeEnumLineNumbers.cpp - Native Type 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/NativeEnumLineNumbers.h"
  9. #include "llvm/DebugInfo/CodeView/CodeView.h"
  10. #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
  11. #include "llvm/DebugInfo/PDB/Native/NativeLineNumber.h"
  12. #include <vector>
  13. using namespace llvm;
  14. using namespace llvm::codeview;
  15. using namespace llvm::pdb;
  16. NativeEnumLineNumbers::NativeEnumLineNumbers(
  17. std::vector<NativeLineNumber> LineNums)
  18. : Lines(std::move(LineNums)), Index(0) {}
  19. uint32_t NativeEnumLineNumbers::getChildCount() const {
  20. return static_cast<uint32_t>(Lines.size());
  21. }
  22. std::unique_ptr<IPDBLineNumber>
  23. NativeEnumLineNumbers::getChildAtIndex(uint32_t N) const {
  24. if (N >= getChildCount())
  25. return nullptr;
  26. return std::make_unique<NativeLineNumber>(Lines[N]);
  27. }
  28. std::unique_ptr<IPDBLineNumber> NativeEnumLineNumbers::getNext() {
  29. return getChildAtIndex(Index++);
  30. }
  31. void NativeEnumLineNumbers::reset() { Index = 0; }