blob: 873f4a0a8db9c537ab87a024fe0ee98f2414dc0d [file] [log] [blame]
Zachary Turner679aead2018-03-13 17:46:06 +00001//==- DIAEnumSourceFiles.cpp - DIA Source File 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/DIAEnumInjectedSources.h"
11#include "llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h"
12#include "llvm/DebugInfo/PDB/PDBSymbol.h"
13
14using namespace llvm;
15using namespace llvm::pdb;
16
17DIAEnumInjectedSources::DIAEnumInjectedSources(
18 const DIASession &PDBSession,
19 CComPtr<IDiaEnumInjectedSources> DiaEnumerator)
20 : Session(PDBSession), Enumerator(DiaEnumerator) {}
21
22uint32_t DIAEnumInjectedSources::getChildCount() const {
23 LONG Count = 0;
24 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
25}
26
27std::unique_ptr<IPDBInjectedSource>
28DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const {
29 CComPtr<IDiaInjectedSource> Item;
30 if (S_OK != Enumerator->Item(Index, &Item))
31 return nullptr;
32
33 return std::unique_ptr<IPDBInjectedSource>(
34 new DIAInjectedSource(Session, Item));
35}
36
37std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() {
38 CComPtr<IDiaInjectedSource> Item;
39 ULONG NumFetched = 0;
40 if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
41 return nullptr;
42
43 return std::unique_ptr<IPDBInjectedSource>(
44 new DIAInjectedSource(Session, Item));
45}
46
47void DIAEnumInjectedSources::reset() { Enumerator->Reset(); }
48
49DIAEnumInjectedSources *DIAEnumInjectedSources::clone() const {
50 CComPtr<IDiaEnumInjectedSources> EnumeratorClone;
51 if (S_OK != Enumerator->Clone(&EnumeratorClone))
52 return nullptr;
53 return new DIAEnumInjectedSources(Session, EnumeratorClone);
54}