Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 1 | //==- DIAEnumSourceFiles.cpp - DIA Source File Enumerator impl ---*- C++ -*-==// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame^] | 3 | // 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 Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 9 | #include "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h" |
| 10 | #include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 12 | |
| 13 | using namespace llvm; |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 14 | using namespace llvm::pdb; |
Zachary Turner | cffff26 | 2015-02-10 21:17:52 +0000 | [diff] [blame] | 15 | |
| 16 | DIAEnumSourceFiles::DIAEnumSourceFiles( |
| 17 | const DIASession &PDBSession, CComPtr<IDiaEnumSourceFiles> DiaEnumerator) |
| 18 | : Session(PDBSession), Enumerator(DiaEnumerator) {} |
| 19 | |
| 20 | uint32_t DIAEnumSourceFiles::getChildCount() const { |
| 21 | LONG Count = 0; |
| 22 | return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; |
| 23 | } |
| 24 | |
| 25 | std::unique_ptr<IPDBSourceFile> |
| 26 | DIAEnumSourceFiles::getChildAtIndex(uint32_t Index) const { |
| 27 | CComPtr<IDiaSourceFile> Item; |
| 28 | if (S_OK != Enumerator->Item(Index, &Item)) |
| 29 | return nullptr; |
| 30 | |
| 31 | return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item)); |
| 32 | } |
| 33 | |
| 34 | std::unique_ptr<IPDBSourceFile> DIAEnumSourceFiles::getNext() { |
| 35 | CComPtr<IDiaSourceFile> Item; |
| 36 | ULONG NumFetched = 0; |
| 37 | if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) |
| 38 | return nullptr; |
| 39 | |
| 40 | return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item)); |
| 41 | } |
| 42 | |
| 43 | void DIAEnumSourceFiles::reset() { Enumerator->Reset(); } |