]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp
Merge ^/head r327150 through r327164.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / PDB / PDBSymbolTypeFunctionSig.cpp
1 //===- PDBSymbolTypeFunctionSig.cpp - --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
11
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"
18
19 #include <utility>
20
21 using namespace llvm;
22 using namespace llvm::pdb;
23
24 namespace {
25 class FunctionArgEnumerator : public IPDBEnumSymbols {
26 public:
27   typedef ConcreteSymbolEnumerator<PDBSymbolTypeFunctionArg> ArgEnumeratorType;
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
58   MyType *clone() const override {
59     std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
60     return new FunctionArgEnumerator(Session, std::move(Clone));
61   }
62
63 private:
64   const IPDBSession &Session;
65   std::unique_ptr<ArgEnumeratorType> Enumerator;
66 };
67 }
68
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);
73 }
74
75 std::unique_ptr<IPDBEnumSymbols>
76 PDBSymbolTypeFunctionSig::getArguments() const {
77   return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
78 }
79
80 void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const {
81   Dumper.dump(*this);
82 }
83
84 void PDBSymbolTypeFunctionSig::dumpRight(PDBSymDumper &Dumper) const {
85   Dumper.dumpRight(*this);
86 }