LLVM  15.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 
21 using namespace llvm;
22 using namespace llvm::codeview;
23 using namespace llvm::pdb;
24 
25 NativeEnumGlobals::NativeEnumGlobals(NativeSession &PDBSession,
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 
42 std::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 
52 std::unique_ptr<PDBSymbol> NativeEnumGlobals::getNext() {
53  return getChildAtIndex(Index++);
54 }
55 
56 void NativeEnumGlobals::reset() { Index = 0; }
llvm::X86AS::GS
@ GS
Definition: X86.h:187
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::X86AS::SS
@ SS
Definition: X86.h:189
llvm::pdb::SymbolStream
Definition: SymbolStream.h:22
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:109
llvm::pdb::PDBFile::getPDBSymbolStream
Expected< SymbolStream & > getPDBSymbolStream()
Definition: PDBFile.cpp:348
llvm::pdb::NativeEnumGlobals::getNext
std::unique_ptr< PDBSymbol > getNext() override
Definition: NativeEnumGlobals.cpp:52
llvm::pdb::NativeEnumGlobals::reset
void reset() override
Definition: NativeEnumGlobals.cpp:56
GlobalsStream.h
llvm::pdb::NativeEnumGlobals::getChildCount
uint32_t getChildCount() const override
Definition: NativeEnumGlobals.cpp:38
NativeEnumGlobals.h
PDBSymbol.h
PDBTypes.h
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::SymbolCache::getSymbolById
std::unique_ptr< PDBSymbol > getSymbolById(SymIndexId SymbolId) const
Definition: SymbolCache.cpp:247
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1672
llvm::pdb::NativeSession::getSymbolCache
SymbolCache & getSymbolCache()
Definition: NativeSession.h:113
IPDBEnumChildren.h
llvm::codeview::CVRecord
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:29
llvm::pdb::GlobalsStream
Definition: GlobalsStream.h:70
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:745
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::pdb::NativeEnumGlobals::getChildAtIndex
std::unique_ptr< PDBSymbol > getChildAtIndex(uint32_t Index) const override
Definition: NativeEnumGlobals.cpp:43
CVRecord.h
llvm::pdb::NativeSession
Definition: NativeSession.h:32
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
PDBFile.h
N
#define N
SymbolCache.h
llvm::pdb::SymbolCache::getOrCreateGlobalSymbolByOffset
SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset)
Definition: SymbolCache.cpp:274
SymbolStream.h
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:235
llvm::pdb::PDBFile::getPDBGlobalsStream
Expected< GlobalsStream & > getPDBGlobalsStream()
Definition: PDBFile.cpp:257
NativeSession.h