Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 1 | //==- DIAEnumSectionContribs.cpp ---------------------------------*- 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/DIAEnumSectionContribs.h" |
| 11 | #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h" |
| 12 | #include "llvm/DebugInfo/PDB/DIA/DIASession.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | using namespace llvm::pdb; |
| 16 | |
| 17 | DIAEnumSectionContribs::DIAEnumSectionContribs( |
| 18 | const DIASession &PDBSession, |
| 19 | CComPtr<IDiaEnumSectionContribs> DiaEnumerator) |
| 20 | : Session(PDBSession), Enumerator(DiaEnumerator) {} |
| 21 | |
| 22 | uint32_t DIAEnumSectionContribs::getChildCount() const { |
| 23 | LONG Count = 0; |
| 24 | return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; |
| 25 | } |
| 26 | |
| 27 | std::unique_ptr<IPDBSectionContrib> |
| 28 | DIAEnumSectionContribs::getChildAtIndex(uint32_t Index) const { |
| 29 | CComPtr<IDiaSectionContrib> Item; |
| 30 | if (S_OK != Enumerator->Item(Index, &Item)) |
| 31 | return nullptr; |
| 32 | |
| 33 | return std::unique_ptr<IPDBSectionContrib>( |
| 34 | new DIASectionContrib(Session, Item)); |
| 35 | } |
| 36 | |
| 37 | std::unique_ptr<IPDBSectionContrib> DIAEnumSectionContribs::getNext() { |
| 38 | CComPtr<IDiaSectionContrib> Item; |
| 39 | ULONG NumFetched = 0; |
| 40 | if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) |
| 41 | return nullptr; |
| 42 | |
| 43 | return std::unique_ptr<IPDBSectionContrib>( |
| 44 | new DIASectionContrib(Session, Item)); |
| 45 | } |
| 46 | |
| 47 | void DIAEnumSectionContribs::reset() { Enumerator->Reset(); } |