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