LLVM 20.0.0git
PDBSymbolFunc.cpp
Go to the documentation of this file.
1//===- PDBSymbolFunc.cpp - --------------------------------------*- 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
20#include <unordered_set>
21#include <utility>
22#include <vector>
23
24using namespace llvm;
25using namespace llvm::pdb;
26
27namespace {
28class FunctionArgEnumerator : public IPDBEnumChildren<PDBSymbolData> {
29public:
30 typedef ConcreteSymbolEnumerator<PDBSymbolData> ArgEnumeratorType;
31
32 FunctionArgEnumerator(const IPDBSession &PDBSession,
33 const PDBSymbolFunc &PDBFunc)
34 : Session(PDBSession), Func(PDBFunc) {
35 // Arguments can appear multiple times if they have live range
36 // information, so we only take the first occurrence.
37 std::unordered_set<std::string> SeenNames;
38 auto DataChildren = Func.findAllChildren<PDBSymbolData>();
39 while (auto Child = DataChildren->getNext()) {
40 if (Child->getDataKind() == PDB_DataKind::Param) {
41 if (SeenNames.insert(Child->getName()).second)
42 Args.push_back(std::move(Child));
43 }
44 }
45 reset();
46 }
47
48 uint32_t getChildCount() const override { return Args.size(); }
49
50 std::unique_ptr<PDBSymbolData>
51 getChildAtIndex(uint32_t Index) const override {
52 if (Index >= Args.size())
53 return nullptr;
54
55 return Session.getConcreteSymbolById<PDBSymbolData>(
56 Args[Index]->getSymIndexId());
57 }
58
59 std::unique_ptr<PDBSymbolData> getNext() override {
60 if (CurIter == Args.end())
61 return nullptr;
62 const auto &Result = **CurIter;
63 ++CurIter;
64 return Session.getConcreteSymbolById<PDBSymbolData>(Result.getSymIndexId());
65 }
66
67 void reset() override { CurIter = Args.empty() ? Args.end() : Args.begin(); }
68
69private:
70 typedef std::vector<std::unique_ptr<PDBSymbolData>> ArgListType;
71 const IPDBSession &Session;
72 const PDBSymbolFunc &Func;
73 ArgListType Args;
74 ArgListType::const_iterator CurIter;
75};
76}
77
78std::unique_ptr<IPDBEnumChildren<PDBSymbolData>>
80 return std::make_unique<FunctionArgEnumerator>(Session, *this);
81}
82
83void PDBSymbolFunc::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
84
86 std::string Name = getName();
87 if (Name.empty())
88 return false;
89 if (Name[0] == '~')
90 return true;
91 if (Name == "__vecDelDtor")
92 return true;
93 return false;
94}
95
96std::unique_ptr<IPDBEnumLineNumbers> PDBSymbolFunc::getLineNumbers() const {
97 auto Len = RawSymbol->getLength();
99 Len ? Len : 1);
100}
101
103 if (auto Lines = getLineNumbers()) {
104 if (auto FirstLine = Lines->getNext()) {
105 return FirstLine->getCompilandId();
106 }
107 }
108 return 0;
109}
std::string Name
virtual uint32_t getChildCount() const =0
virtual ChildTypePtr getNext()=0
virtual ChildTypePtr getChildAtIndex(uint32_t Index) const =0
virtual uint64_t getLength() const =0
virtual uint64_t getVirtualAddress() const =0
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:25
virtual std::unique_ptr< IPDBEnumLineNumbers > findLineNumbersByAddress(uint64_t Address, uint32_t Length) const =0
virtual void dump(const PDBSymbolAnnotation &Symbol)
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.
std::unique_ptr< IPDBEnumChildren< PDBSymbolData > > getArguments() const
FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType, getSignature) std uint32_t getCompilandId() const
const IPDBSession & Session
Definition: PDBSymbol.h:168
std::string getName() const
Definition: PDBSymbol.cpp:183
IPDBRawSymbol * RawSymbol
Definition: PDBSymbol.h:170
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
NodeAddr< FuncNode * > Func
Definition: RDFGraph.h:393
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18