]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/Native/NativeEnumTypes.cpp
MFV r329715: 8997 ztest assertion failure in zil_lwb_write_issue
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / PDB / Native / NativeEnumTypes.cpp
1 //==- NativeEnumTypes.cpp - Native Type 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/NativeEnumTypes.h"
11
12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
17
18 namespace llvm {
19 namespace pdb {
20
21 NativeEnumTypes::NativeEnumTypes(NativeSession &PDBSession,
22                                  codeview::LazyRandomTypeCollection &Types,
23                                  codeview::TypeLeafKind Kind)
24     : Matches(), Index(0), Session(PDBSession), Kind(Kind) {
25   for (auto Index = Types.getFirst(); Index;
26        Index = Types.getNext(Index.getValue())) {
27     if (Types.getType(Index.getValue()).kind() == Kind)
28       Matches.push_back(Index.getValue());
29   }
30 }
31
32 NativeEnumTypes::NativeEnumTypes(
33     NativeSession &PDBSession, const std::vector<codeview::TypeIndex> &Matches,
34     codeview::TypeLeafKind Kind)
35     : Matches(Matches), Index(0), Session(PDBSession), Kind(Kind) {}
36
37 uint32_t NativeEnumTypes::getChildCount() const {
38   return static_cast<uint32_t>(Matches.size());
39 }
40
41 std::unique_ptr<PDBSymbol>
42 NativeEnumTypes::getChildAtIndex(uint32_t Index) const {
43   if (Index < Matches.size())
44     return Session.createEnumSymbol(Matches[Index]);
45   return nullptr;
46 }
47
48 std::unique_ptr<PDBSymbol> NativeEnumTypes::getNext() {
49   return getChildAtIndex(Index++);
50 }
51
52 void NativeEnumTypes::reset() { Index = 0; }
53
54 NativeEnumTypes *NativeEnumTypes::clone() const {
55   return new NativeEnumTypes(Session, Matches, Kind);
56 }
57
58 } // namespace pdb
59 } // namespace llvm