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"
22 using namespace llvm::pdb;
25 class FunctionArgEnumerator : public IPDBEnumSymbols {
27 typedef ConcreteSymbolEnumerator<PDBSymbolTypeFunctionArg> ArgEnumeratorType;
29 FunctionArgEnumerator(const IPDBSession &PDBSession,
30 const PDBSymbolTypeFunctionSig &Sig)
31 : Session(PDBSession),
32 Enumerator(Sig.findAllChildren<PDBSymbolTypeFunctionArg>()) {}
34 FunctionArgEnumerator(const IPDBSession &PDBSession,
35 std::unique_ptr<ArgEnumeratorType> ArgEnumerator)
36 : Session(PDBSession), Enumerator(std::move(ArgEnumerator)) {}
38 uint32_t getChildCount() const override {
39 return Enumerator->getChildCount();
42 std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override {
43 auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
44 if (!FunctionArgSymbol)
46 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
49 std::unique_ptr<PDBSymbol> getNext() override {
50 auto FunctionArgSymbol = Enumerator->getNext();
51 if (!FunctionArgSymbol)
53 return Session.getSymbolById(FunctionArgSymbol->getTypeId());
56 void reset() override { Enumerator->reset(); }
58 MyType *clone() const override {
59 std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
60 return new FunctionArgEnumerator(Session, std::move(Clone));
64 const IPDBSession &Session;
65 std::unique_ptr<ArgEnumeratorType> Enumerator;
69 PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
70 const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
71 : PDBSymbol(PDBSession, std::move(Symbol)) {}
73 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getReturnType() const {
74 return Session.getSymbolById(getTypeId());
77 std::unique_ptr<IPDBEnumSymbols>
78 PDBSymbolTypeFunctionSig::getArguments() const {
79 return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
82 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
83 uint32_t ClassId = getClassParentId();
86 return Session.getSymbolById(ClassId);
89 void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {