189bca9e5SAaron Smith //===- DIAEnumTables.cpp - DIA Table Enumerator Impl ------------*- C++ -*-===// 289bca9e5SAaron Smith // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 689bca9e5SAaron Smith // 789bca9e5SAaron Smith //===----------------------------------------------------------------------===// 889bca9e5SAaron Smith 989bca9e5SAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIAEnumTables.h" 1089bca9e5SAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIATable.h" 1189bca9e5SAaron Smith 1289bca9e5SAaron Smith using namespace llvm; 1389bca9e5SAaron Smith using namespace llvm::pdb; 1489bca9e5SAaron Smith DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator)15757274f9SAaron SmithDIAEnumTables::DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator) 1689bca9e5SAaron Smith : Enumerator(DiaEnumerator) {} 1789bca9e5SAaron Smith getChildCount() const1889bca9e5SAaron Smithuint32_t DIAEnumTables::getChildCount() const { 1989bca9e5SAaron Smith LONG Count = 0; 2089bca9e5SAaron Smith return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 2189bca9e5SAaron Smith } 2289bca9e5SAaron Smith 2389bca9e5SAaron Smith std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const2489bca9e5SAaron SmithDIAEnumTables::getChildAtIndex(uint32_t Index) const { 2589bca9e5SAaron Smith CComPtr<IDiaTable> Item; 2689bca9e5SAaron Smith VARIANT Var; 2789bca9e5SAaron Smith Var.vt = VT_UINT; 2889bca9e5SAaron Smith Var.uintVal = Index; 2989bca9e5SAaron Smith if (S_OK != Enumerator->Item(Var, &Item)) 3089bca9e5SAaron Smith return nullptr; 3189bca9e5SAaron Smith 3289bca9e5SAaron Smith return std::unique_ptr<IPDBTable>(new DIATable(Item)); 3389bca9e5SAaron Smith } 3489bca9e5SAaron Smith getNext()3589bca9e5SAaron Smithstd::unique_ptr<IPDBTable> DIAEnumTables::getNext() { 3689bca9e5SAaron Smith CComPtr<IDiaTable> Item; 3789bca9e5SAaron Smith ULONG CeltFetched = 0; 3889bca9e5SAaron Smith if (S_OK != Enumerator->Next(1, &Item, &CeltFetched)) 3989bca9e5SAaron Smith return nullptr; 4089bca9e5SAaron Smith 4189bca9e5SAaron Smith return std::unique_ptr<IPDBTable>(new DIATable(Item)); 4289bca9e5SAaron Smith } 4389bca9e5SAaron Smith reset()4489bca9e5SAaron Smithvoid DIAEnumTables::reset() { Enumerator->Reset(); } 45