LLVM  3.7.0
PDBSymbolTypeFunctionSig.cpp
Go to the documentation of this file.
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 
11 
18 
19 #include <utility>
20 
21 using namespace llvm;
22 
23 namespace {
24 class FunctionArgEnumerator : public IPDBEnumSymbols {
25 public:
27 
28  FunctionArgEnumerator(const IPDBSession &PDBSession,
29  const PDBSymbolTypeFunctionSig &Sig)
30  : Session(PDBSession),
31  Enumerator(Sig.findAllChildren<PDBSymbolTypeFunctionArg>()) {}
32 
33  FunctionArgEnumerator(const IPDBSession &PDBSession,
34  std::unique_ptr<ArgEnumeratorType> ArgEnumerator)
35  : Session(PDBSession), Enumerator(std::move(ArgEnumerator)) {}
36 
37  uint32_t getChildCount() const override {
38  return Enumerator->getChildCount();
39  }
40 
41  std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override {
42  auto FunctionArgSymbol = Enumerator->getChildAtIndex(Index);
43  if (!FunctionArgSymbol)
44  return nullptr;
45  return Session.getSymbolById(FunctionArgSymbol->getTypeId());
46  }
47 
48  std::unique_ptr<PDBSymbol> getNext() override {
49  auto FunctionArgSymbol = Enumerator->getNext();
50  if (!FunctionArgSymbol)
51  return nullptr;
52  return Session.getSymbolById(FunctionArgSymbol->getTypeId());
53  }
54 
55  void reset() override { Enumerator->reset(); }
56 
57  MyType *clone() const override {
58  std::unique_ptr<ArgEnumeratorType> Clone(Enumerator->clone());
59  return new FunctionArgEnumerator(Session, std::move(Clone));
60  }
61 
62 private:
63  const IPDBSession &Session;
64  std::unique_ptr<ArgEnumeratorType> Enumerator;
65 };
66 }
67 
69  const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
70  : PDBSymbol(PDBSession, std::move(Symbol)) {}
71 
72 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getReturnType() const {
73  return Session.getSymbolById(getTypeId());
74 }
75 
76 std::unique_ptr<IPDBEnumSymbols>
78  return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
79 }
80 
81 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
82  uint32_t ClassId = getClassParentId();
83  if (ClassId == 0)
84  return nullptr;
85  return Session.getSymbolById(ClassId);
86 }
87 
89  Dumper.dump(*this);
90 }
virtual std::unique_ptr< PDBSymbol > getSymbolById(uint32_t SymbolId) const =0
PDBSymbolTypeFunctionSig(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
virtual void dump(const PDBSymbolAnnotation &Symbol)
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e...
Definition: PDBSymbol.h:42
std::unique_ptr< PDBSymbol > getClassParent() const
std::unique_ptr< IPDBEnumSymbols > getArguments() const
const IPDBSession & Session
Definition: PDBSymbol.h:91
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:24
std::unique_ptr< PDBSymbol > getReturnType() const
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.