1 //==- DIAEnumSymbols.cpp - DIA Symbol 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/DIAEnumSymbols.h"
12 #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
13 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
14
15 using namespace llvm;
16
DIAEnumSymbols(const DIASession & PDBSession,CComPtr<IDiaEnumSymbols> DiaEnumerator)17 DIAEnumSymbols::DIAEnumSymbols(const DIASession &PDBSession,
18 CComPtr<IDiaEnumSymbols> DiaEnumerator)
19 : Session(PDBSession), Enumerator(DiaEnumerator) {}
20
getChildCount() const21 uint32_t DIAEnumSymbols::getChildCount() const {
22 LONG Count = 0;
23 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
24 }
25
26 std::unique_ptr<PDBSymbol>
getChildAtIndex(uint32_t Index) const27 DIAEnumSymbols::getChildAtIndex(uint32_t Index) const {
28 CComPtr<IDiaSymbol> Item;
29 if (S_OK != Enumerator->Item(Index, &Item))
30 return nullptr;
31
32 std::unique_ptr<DIARawSymbol> RawSymbol(new DIARawSymbol(Session, Item));
33 return std::unique_ptr<PDBSymbol>(PDBSymbol::create(Session, std::move(RawSymbol)));
34 }
35
getNext()36 std::unique_ptr<PDBSymbol> DIAEnumSymbols::getNext() {
37 CComPtr<IDiaSymbol> Item;
38 ULONG NumFetched = 0;
39 if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
40 return nullptr;
41
42 std::unique_ptr<DIARawSymbol> RawSymbol(new DIARawSymbol(Session, Item));
43 return std::unique_ptr<PDBSymbol>(
44 PDBSymbol::create(Session, std::move(RawSymbol)));
45 }
46
reset()47 void DIAEnumSymbols::reset() { Enumerator->Reset(); }
48
clone() const49 DIAEnumSymbols *DIAEnumSymbols::clone() const {
50 CComPtr<IDiaEnumSymbols> EnumeratorClone;
51 if (S_OK != Enumerator->Clone(&EnumeratorClone))
52 return nullptr;
53 return new DIAEnumSymbols(Session, EnumeratorClone);
54 }
55