LLVM 20.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
20
21using namespace llvm;
22using namespace llvm::codeview;
23using namespace llvm::pdb;
24
26 std::vector<codeview::SymbolKind> Kinds)
27 : Index(0), Session(PDBSession) {
30 for (uint32_t Off : GS.getGlobalsTable()) {
31 CVSymbol S = SS.readRecord(Off);
32 if (!llvm::is_contained(Kinds, S.kind()))
33 continue;
34 MatchOffsets.push_back(Off);
35 }
36}
37
39 return static_cast<uint32_t>(MatchOffsets.size());
40}
41
42std::unique_ptr<PDBSymbol>
44 if (N >= MatchOffsets.size())
45 return nullptr;
46
47 SymIndexId Id =
48 Session.getSymbolCache().getOrCreateGlobalSymbolByOffset(MatchOffsets[N]);
49 return Session.getSymbolCache().getSymbolById(Id);
50}
51
52std::unique_ptr<PDBSymbol> NativeEnumGlobals::getNext() {
53 return getChildAtIndex(Index++);
54}
55
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:29
Kind kind() const
Definition: CVRecord.h:42
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
SymbolCache & getSymbolCache()
Expected< GlobalsStream & > getPDBGlobalsStream()
Definition: PDBFile.cpp:256
Expected< SymbolStream & > getPDBSymbolStream()
Definition: PDBFile.cpp:347
std::unique_ptr< PDBSymbol > getSymbolById(SymIndexId SymbolId) const
SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:756
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1879
#define N