Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 1 | //==- DIAEnumDebugStreams.cpp - DIA Debug Stream 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 | |
Chandler Carruth | 71f308a | 2015-02-13 09:09:03 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame^] | 11 | #include "llvm/DebugInfo/PDB/DIA/DIADataStream.h" |
| 12 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 13 | |
| 14 | using namespace llvm; |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 15 | using namespace llvm::pdb; |
Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 16 | |
| 17 | DIAEnumDebugStreams::DIAEnumDebugStreams( |
| 18 | CComPtr<IDiaEnumDebugStreams> DiaEnumerator) |
| 19 | : Enumerator(DiaEnumerator) {} |
| 20 | |
| 21 | uint32_t DIAEnumDebugStreams::getChildCount() const { |
| 22 | LONG Count = 0; |
| 23 | return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; |
| 24 | } |
| 25 | |
| 26 | std::unique_ptr<IPDBDataStream> |
| 27 | DIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const { |
| 28 | CComPtr<IDiaEnumDebugStreamData> Item; |
| 29 | VARIANT VarIndex; |
| 30 | VarIndex.vt = VT_I4; |
| 31 | VarIndex.lVal = Index; |
| 32 | if (S_OK != Enumerator->Item(VarIndex, &Item)) |
| 33 | return nullptr; |
| 34 | |
| 35 | return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); |
| 36 | } |
| 37 | |
| 38 | std::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() { |
| 39 | CComPtr<IDiaEnumDebugStreamData> Item; |
| 40 | ULONG NumFetched = 0; |
| 41 | if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) |
| 42 | return nullptr; |
| 43 | |
| 44 | return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); |
| 45 | } |
| 46 | |
| 47 | void DIAEnumDebugStreams::reset() { Enumerator->Reset(); } |
| 48 | |
| 49 | DIAEnumDebugStreams *DIAEnumDebugStreams::clone() const { |
| 50 | CComPtr<IDiaEnumDebugStreams> EnumeratorClone; |
| 51 | if (S_OK != Enumerator->Clone(&EnumeratorClone)) |
| 52 | return nullptr; |
| 53 | return new DIAEnumDebugStreams(EnumeratorClone); |
| 54 | } |