]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
Merge ^/head r318380 through r318559.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / PDB / Native / NativeEnumModules.cpp
1 //==- NativeEnumModules.cpp - Native Symbol 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/Native/NativeEnumModules.h"
11
12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13 #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
15 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
18
19 namespace llvm {
20 namespace pdb {
21
22 NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
23                                      const DbiModuleList &Modules,
24                                      uint32_t Index)
25     : Session(PDBSession), Modules(Modules), Index(Index) {}
26
27 uint32_t NativeEnumModules::getChildCount() const {
28   return static_cast<uint32_t>(Modules.getModuleCount());
29 }
30
31 std::unique_ptr<PDBSymbol>
32 NativeEnumModules::getChildAtIndex(uint32_t Index) const {
33   if (Index >= Modules.getModuleCount())
34     return nullptr;
35   return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(
36       Session, std::unique_ptr<IPDBRawSymbol>(new NativeCompilandSymbol(
37                    Session, Modules.getModuleDescriptor(Index)))));
38 }
39
40 std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
41   if (Index >= Modules.getModuleCount())
42     return nullptr;
43   return getChildAtIndex(Index++);
44 }
45
46 void NativeEnumModules::reset() { Index = 0; }
47
48 NativeEnumModules *NativeEnumModules::clone() const {
49   return new NativeEnumModules(Session, Modules, Index);
50 }
51
52 }
53 }