• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
10 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
12 #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
13 
14 using namespace llvm;
15 using namespace llvm::pdb;
16 
DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator)17 DIAEnumDebugStreams::DIAEnumDebugStreams(
18     CComPtr<IDiaEnumDebugStreams> DiaEnumerator)
19     : Enumerator(DiaEnumerator) {}
20 
getChildCount() const21 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>
getChildAtIndex(uint32_t Index) const27 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 
getNext()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 
reset()47 void DIAEnumDebugStreams::reset() { Enumerator->Reset(); }
48 
clone() const49 DIAEnumDebugStreams *DIAEnumDebugStreams::clone() const {
50   CComPtr<IDiaEnumDebugStreams> EnumeratorClone;
51   if (S_OK != Enumerator->Clone(&EnumeratorClone))
52     return nullptr;
53   return new DIAEnumDebugStreams(EnumeratorClone);
54 }
55