blob: f62c4991fe33de3ade543f46c4fd86edf7edc888 [file] [log] [blame]
Zachary Turnercffff262015-02-10 21:17:52 +00001//==- 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 Carruth71f308a2015-02-13 09:09:03 +000010#include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000011#include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
12#include "llvm/DebugInfo/PDB/PDBSymbol.h"
Zachary Turnercffff262015-02-10 21:17:52 +000013
14using namespace llvm;
Zachary Turnerec28fc32016-05-04 20:32:13 +000015using namespace llvm::pdb;
Zachary Turnercffff262015-02-10 21:17:52 +000016
17DIAEnumDebugStreams::DIAEnumDebugStreams(
18 CComPtr<IDiaEnumDebugStreams> DiaEnumerator)
19 : Enumerator(DiaEnumerator) {}
20
21uint32_t DIAEnumDebugStreams::getChildCount() const {
22 LONG Count = 0;
23 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
24}
25
26std::unique_ptr<IPDBDataStream>
27DIAEnumDebugStreams::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
38std::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
47void DIAEnumDebugStreams::reset() { Enumerator->Reset(); }
48
49DIAEnumDebugStreams *DIAEnumDebugStreams::clone() const {
50 CComPtr<IDiaEnumDebugStreams> EnumeratorClone;
51 if (S_OK != Enumerator->Clone(&EnumeratorClone))
52 return nullptr;
53 return new DIAEnumDebugStreams(EnumeratorClone);
54}