]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
MFV r328225: 8603 rename zilog's "zl_writer_lock" to "zl_issuer_lock"
[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 Session.createCompilandSymbol(Modules.getModuleDescriptor(Index));
36 }
37
38 std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
39   if (Index >= Modules.getModuleCount())
40     return nullptr;
41   return getChildAtIndex(Index++);
42 }
43
44 void NativeEnumModules::reset() { Index = 0; }
45
46 NativeEnumModules *NativeEnumModules::clone() const {
47   return new NativeEnumModules(Session, Modules, Index);
48 }
49
50 }
51 }