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 using namespace llvm::pdb; 16 DIAEnumLineNumbers(CComPtr<IDiaEnumLineNumbers> DiaEnumerator)17DIAEnumLineNumbers::DIAEnumLineNumbers( 18 CComPtr<IDiaEnumLineNumbers> DiaEnumerator) 19 : Enumerator(DiaEnumerator) {} 20 getChildCount() const21uint32_t DIAEnumLineNumbers::getChildCount() const { 22 LONG Count = 0; 23 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 24 } 25 26 std::unique_ptr<IPDBLineNumber> getChildAtIndex(uint32_t Index) const27DIAEnumLineNumbers::getChildAtIndex(uint32_t Index) const { 28 CComPtr<IDiaLineNumber> Item; 29 if (S_OK != Enumerator->Item(Index, &Item)) 30 return nullptr; 31 32 return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item)); 33 } 34 getNext()35std::unique_ptr<IPDBLineNumber> DIAEnumLineNumbers::getNext() { 36 CComPtr<IDiaLineNumber> Item; 37 ULONG NumFetched = 0; 38 if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) 39 return nullptr; 40 41 return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item)); 42 } 43 reset()44void DIAEnumLineNumbers::reset() { Enumerator->Reset(); } 45 clone() const46DIAEnumLineNumbers *DIAEnumLineNumbers::clone() const { 47 CComPtr<IDiaEnumLineNumbers> EnumeratorClone; 48 if (S_OK != Enumerator->Clone(&EnumeratorClone)) 49 return nullptr; 50 return new DIAEnumLineNumbers(EnumeratorClone); 51 } 52