1 //===- PDBSymbolTypeFunctionSig.cpp - --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
12 #include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBSession.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
17 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
24 class FunctionArgEnumerator : public IPDBEnumSymbols {
26 typedef ConcreteSymbolEnumerator<PDBSymbolTypeFunctionArg> ArgEnumeratorType;
28 FunctionArgEnumerator(const IPDBSession &PDBSession,
29 const PDBSymbolTypeFunctionSig &Sig)
30 : Session(PDBSession),
31 Enumerator(Sig.findAllChildren<PDBSymbolTypeFunctionArg>()) {}
33 FunctionArgEnumerator(const IPDBSession &PDBSession,
34 std::unique_ptr<ArgEnumeratorType> ArgEnumerator)
35 : Session(PDBSession), Enumerator(std::move(ArgEnumerator)) {}
37 uint32_t getChildCount() const override {
38 return Enumerator->getChildCount();
41 std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override {
42 auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
43 if (!FunctionArgSymbol)
45 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
48 std::unique_ptr<PDBSymbol> getNext() override {
49 auto FunctionArgSymbol = Enumerator->getNext();
50 if (!FunctionArgSymbol)
52 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
55 void reset() override { Enumerator->reset(); }
57 MyType *clone() const override {
58 std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
59 return new FunctionArgEnumerator(Session, std::move(Clone));
63 const IPDBSession &Session;
64 std::unique_ptr<ArgEnumeratorType> Enumerator;
68 PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
69 const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
70 : PDBSymbol(PDBSession, std::move(Symbol)) {}
72 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getReturnType() const {
73 return Session.getSymbolById(getTypeId());
76 std::unique_ptr<IPDBEnumSymbols>
77 PDBSymbolTypeFunctionSig::getArguments() const {
78 return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
81 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
82 uint32_t ClassId = getClassParentId();
85 return Session.getSymbolById(ClassId);
88 void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {