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/PDBSymDumper.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.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)) {
72 assert(RawSymbol->getSymTag() == PDB_SymType::FunctionSig);
75 std::unique_ptr<IPDBEnumSymbols>
76 PDBSymbolTypeFunctionSig::getArguments() const {
77 return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
80 void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {
84 void PDBSymbolTypeFunctionSig::dumpRight(PDBSymDumper &Dumper) const {
85 Dumper.dumpRight(*this);