1 //==- DIAEnumLineNumbers.cpp - DIA Line Number Enumerator impl ---*- C++ -*-==// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "llvm/DebugInfo/PDB/PDBSymbol.h" 11 #include "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h" 12 #include "llvm/DebugInfo/PDB/DIA/DIALineNumber.h" 13 14 using namespace llvm; 15 DIAEnumLineNumbers(CComPtr<IDiaEnumLineNumbers> DiaEnumerator)16DIAEnumLineNumbers::DIAEnumLineNumbers( 17 CComPtr<IDiaEnumLineNumbers> DiaEnumerator) 18 : Enumerator(DiaEnumerator) {} 19 getChildCount() const20uint32_t DIAEnumLineNumbers::getChildCount() const { 21 LONG Count = 0; 22 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 23 } 24 25 std::unique_ptr<IPDBLineNumber> getChildAtIndex(uint32_t Index) const26DIAEnumLineNumbers::getChildAtIndex(uint32_t Index) const { 27 CComPtr<IDiaLineNumber> Item; 28 if (S_OK != Enumerator->Item(Index, &Item)) 29 return nullptr; 30 31 return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item)); 32 } 33 getNext()34std::unique_ptr<IPDBLineNumber> DIAEnumLineNumbers::getNext() { 35 CComPtr<IDiaLineNumber> Item; 36 ULONG NumFetched = 0; 37 if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) 38 return nullptr; 39 40 return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item)); 41 } 42 reset()43void DIAEnumLineNumbers::reset() { Enumerator->Reset(); } 44 clone() const45DIAEnumLineNumbers *DIAEnumLineNumbers::clone() const { 46 CComPtr<IDiaEnumLineNumbers> EnumeratorClone; 47 if (S_OK != Enumerator->Clone(&EnumeratorClone)) 48 return nullptr; 49 return new DIAEnumLineNumbers(EnumeratorClone); 50 } 51