LLVM 20.0.0git
PDBSymbolTypeFunctionSig.cpp
Go to the documentation of this file.
1//===- PDBSymbolTypeFunctionSig.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
18
19#include <utility>
20
21using namespace llvm;
22using namespace llvm::pdb;
23
24namespace {
25class FunctionArgEnumerator : public IPDBEnumSymbols {
26public:
28
29 FunctionArgEnumerator(const IPDBSession &PDBSession,
30 const PDBSymbolTypeFunctionSig &Sig)
31 : Session(PDBSession),
32 Enumerator(Sig.findAllChildren<PDBSymbolTypeFunctionArg>()) {}
33
34 FunctionArgEnumerator(const IPDBSession &PDBSession,
35 std::unique_ptr<ArgEnumeratorType> ArgEnumerator)
36 : Session(PDBSession), Enumerator(std::move(ArgEnumerator)) {}
37
38 uint32_t getChildCount() const override {
39 return Enumerator->getChildCount();
40 }
41
42 std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override {
43 auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
44 if (!FunctionArgSymbol)
45 return nullptr;
46 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
47 }
48
49 std::unique_ptr<PDBSymbol> getNext() override {
50 auto FunctionArgSymbol = Enumerator->getNext();
51 if (!FunctionArgSymbol)
52 return nullptr;
53 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
54 }
55
56 void reset() override { Enumerator->reset(); }
57
58private:
59 const IPDBSession &Session;
60 std::unique_ptr<ArgEnumeratorType> Enumerator;
61};
62}
63
64std::unique_ptr<IPDBEnumSymbols>
66 return std::make_unique<FunctionArgEnumerator>(Session, *this);
67}
68
70 Dumper.dump(*this);
71}
72
74 Dumper.dumpRight(*this);
75}
76
78 auto SigArguments = getArguments();
79 if (!SigArguments)
80 return false;
81 uint32_t NumArgs = SigArguments->getChildCount();
82 if (NumArgs == 0)
83 return false;
84 auto Last = SigArguments->getChildAtIndex(NumArgs - 1);
85 if (auto Builtin = llvm::dyn_cast_or_null<PDBSymbolTypeBuiltin>(Last.get())) {
86 if (Builtin->getBuiltinType() == PDB_BuiltinType::None)
87 return true;
88 }
89
90 // Note that for a variadic template signature, this method always returns
91 // false since the parameters of the template are specialized.
92 return false;
93}
virtual uint32_t getChildCount() const=0
virtual ChildTypePtr getChildAtIndex(uint32_t Index) const=0
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:25
virtual void dump(const PDBSymbolAnnotation &Symbol)
virtual void dumpRight(const PDBSymbolTypeArray &Symbol)
Definition: PDBSymDumper.h:56
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.
std::unique_ptr< IPDBEnumSymbols > getArguments() const
void dumpRight(PDBSymDumper &Dumper) const override
For certain PDBSymbolTypes, dumps additional information for the type that normally goes on the right...
const IPDBSession & Session
Definition: PDBSymbol.h:168
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858