blob: 5153596d52ae00dae31fa4b65356f8b3651bf033 [file] [log] [blame]
Zachary Turnercffff262015-02-10 21:17:52 +00001//==- DIAEnumSymbols.cpp - DIA Symbol Enumerator impl ------------*- C++ -*-==//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Zachary Turnercffff262015-02-10 21:17:52 +00006//
7//===----------------------------------------------------------------------===//
8
Zachary Turnercffff262015-02-10 21:17:52 +00009#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
10#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
11#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000012#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
17DIAEnumSymbols::DIAEnumSymbols(const DIASession &PDBSession,
18 CComPtr<IDiaEnumSymbols> DiaEnumerator)
19 : Session(PDBSession), Enumerator(DiaEnumerator) {}
20
21uint32_t DIAEnumSymbols::getChildCount() const {
22 LONG Count = 0;
23 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
24}
25
26std::unique_ptr<PDBSymbol>
27DIAEnumSymbols::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
36std::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
47void DIAEnumSymbols::reset() { Enumerator->Reset(); }