blob: 7226ab2ba0a043050bb8d344f7c5b6ff5aded48c [file] [log] [blame]
Zachary Turner679aead2018-03-13 17:46:06 +00001//==- DIAEnumSourceFiles.cpp - DIA Source File 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 Turner679aead2018-03-13 17:46:06 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h"
10#include "llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h"
11#include "llvm/DebugInfo/PDB/PDBSymbol.h"
12
13using namespace llvm;
14using namespace llvm::pdb;
15
16DIAEnumInjectedSources::DIAEnumInjectedSources(
Zachary Turner679aead2018-03-13 17:46:06 +000017 CComPtr<IDiaEnumInjectedSources> DiaEnumerator)
Reid Klecknerba732f22018-09-14 20:16:31 +000018 : Enumerator(DiaEnumerator) {}
Zachary Turner679aead2018-03-13 17:46:06 +000019
20uint32_t DIAEnumInjectedSources::getChildCount() const {
21 LONG Count = 0;
22 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
23}
24
25std::unique_ptr<IPDBInjectedSource>
26DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const {
27 CComPtr<IDiaInjectedSource> Item;
28 if (S_OK != Enumerator->Item(Index, &Item))
29 return nullptr;
30
Reid Kleckner8562c1a2018-03-21 21:47:26 +000031 return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item));
Zachary Turner679aead2018-03-13 17:46:06 +000032}
33
34std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() {
35 CComPtr<IDiaInjectedSource> Item;
36 ULONG NumFetched = 0;
37 if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
38 return nullptr;
39
Reid Kleckner8562c1a2018-03-21 21:47:26 +000040 return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item));
Zachary Turner679aead2018-03-13 17:46:06 +000041}
42
43void DIAEnumInjectedSources::reset() { Enumerator->Reset(); }