LLVM 22.0.0git
NativeEnumGlobals.cpp
Go to the documentation of this file.
1//==- NativeEnumGlobals.cpp - Native Global Enumerator impl ------*- C++ -*-==//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
10
19
20using namespace llvm;
21using namespace llvm::codeview;
22using namespace llvm::pdb;
23
25 std::vector<codeview::SymbolKind> Kinds)
26 : Index(0), Session(PDBSession) {
27 GlobalsStream &GS = cantFail(Session.getPDBFile().getPDBGlobalsStream());
28 SymbolStream &SS = cantFail(Session.getPDBFile().getPDBSymbolStream());
29 for (uint32_t Off : GS.getGlobalsTable()) {
30 CVSymbol S = SS.readRecord(Off);
31 if (!llvm::is_contained(Kinds, S.kind()))
32 continue;
33 MatchOffsets.push_back(Off);
34 }
35}
36
38 return static_cast<uint32_t>(MatchOffsets.size());
39}
40
41std::unique_ptr<PDBSymbol>
43 if (N >= MatchOffsets.size())
44 return nullptr;
45
46 SymIndexId Id =
47 Session.getSymbolCache().getOrCreateGlobalSymbolByOffset(MatchOffsets[N]);
48 return Session.getSymbolCache().getSymbolById(Id);
49}
50
51std::unique_ptr<PDBSymbol> NativeEnumGlobals::getNext() {
52 return getChildAtIndex(Index++);
53}
54
55void NativeEnumGlobals::reset() { Index = 0; }
uint32_t getChildCount() const override
NativeEnumGlobals(NativeSession &Session, std::vector< codeview::SymbolKind > Kinds)
std::unique_ptr< PDBSymbol > getChildAtIndex(uint32_t Index) const override
std::unique_ptr< PDBSymbol > getNext() override
CVRecord< SymbolKind > CVSymbol
Definition CVRecord.h:65
uint32_t SymIndexId
Definition PDBTypes.h:26
This is an optimization pass for GlobalISel generic memory operations.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1877
#define N