xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIAEnumFrameData.cpp (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1 //==- DIAEnumFrameData.cpp ---------------------------------------*- 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/DIA/DIAEnumFrameData.h"
10 #include "llvm/DebugInfo/PDB/DIA/DIAFrameData.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
12 
13 using namespace llvm::pdb;
14 
15 DIAEnumFrameData::DIAEnumFrameData(CComPtr<IDiaEnumFrameData> DiaEnumerator)
16     : Enumerator(DiaEnumerator) {}
17 
18 uint32_t DIAEnumFrameData::getChildCount() const {
19   LONG Count = 0;
20   return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
21 }
22 
23 std::unique_ptr<IPDBFrameData>
24 DIAEnumFrameData::getChildAtIndex(uint32_t Index) const {
25   CComPtr<IDiaFrameData> Item;
26   if (S_OK != Enumerator->Item(Index, &Item))
27     return nullptr;
28 
29   return std::unique_ptr<IPDBFrameData>(new DIAFrameData(Item));
30 }
31 
32 std::unique_ptr<IPDBFrameData> DIAEnumFrameData::getNext() {
33   CComPtr<IDiaFrameData> Item;
34   ULONG NumFetched = 0;
35   if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
36     return nullptr;
37 
38   return std::unique_ptr<IPDBFrameData>(new DIAFrameData(Item));
39 }
40 
41 void DIAEnumFrameData::reset() { Enumerator->Reset(); }
42