• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //==- 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/PDBSymbol.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h"
12 #include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
13 
14 using namespace llvm;
15 using namespace llvm::pdb;
16 
DIAEnumSourceFiles(const DIASession & PDBSession,CComPtr<IDiaEnumSourceFiles> DiaEnumerator)17 DIAEnumSourceFiles::DIAEnumSourceFiles(
18     const DIASession &PDBSession, CComPtr<IDiaEnumSourceFiles> DiaEnumerator)
19     : Session(PDBSession), Enumerator(DiaEnumerator) {}
20 
getChildCount() const21 uint32_t DIAEnumSourceFiles::getChildCount() const {
22   LONG Count = 0;
23   return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
24 }
25 
26 std::unique_ptr<IPDBSourceFile>
getChildAtIndex(uint32_t Index) const27 DIAEnumSourceFiles::getChildAtIndex(uint32_t Index) const {
28   CComPtr<IDiaSourceFile> Item;
29   if (S_OK != Enumerator->Item(Index, &Item))
30     return nullptr;
31 
32   return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item));
33 }
34 
getNext()35 std::unique_ptr<IPDBSourceFile> DIAEnumSourceFiles::getNext() {
36   CComPtr<IDiaSourceFile> Item;
37   ULONG NumFetched = 0;
38   if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
39     return nullptr;
40 
41   return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item));
42 }
43 
reset()44 void DIAEnumSourceFiles::reset() { Enumerator->Reset(); }
45 
clone() const46 DIAEnumSourceFiles *DIAEnumSourceFiles::clone() const {
47   CComPtr<IDiaEnumSourceFiles> EnumeratorClone;
48   if (S_OK != Enumerator->Clone(&EnumeratorClone))
49     return nullptr;
50   return new DIAEnumSourceFiles(Session, EnumeratorClone);
51 }
52