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 { return Enumerator->getChildCount(); }
39 std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const {
40 auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
41 if (!FunctionArgSymbol)
43 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
46 std::unique_ptr<PDBSymbol> getNext() {
47 auto FunctionArgSymbol = Enumerator->getNext();
48 if (!FunctionArgSymbol)
50 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
53 void reset() { Enumerator->reset(); }
55 MyType *clone() const {
56 std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
57 return new FunctionArgEnumerator(Session, std::move(Clone));
61 const IPDBSession &Session;
62 std::unique_ptr<ArgEnumeratorType> Enumerator;
66 PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
67 const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
68 : PDBSymbol(PDBSession, std::move(Symbol)) {}
70 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getReturnType() const {
71 return Session.getSymbolById(getTypeId());
74 std::unique_ptr<IPDBEnumSymbols>
75 PDBSymbolTypeFunctionSig::getArguments() const {
76 return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
79 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
80 uint32_t ClassId = getClassParentId();
83 return Session.getSymbolById(ClassId);
86 void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {