LLVM  4.0.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 using namespace llvm::pdb;
23 
24 namespace {
25 class FunctionArgEnumerator : public IPDBEnumSymbols {
26 public:
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 
70  const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol)
71  : PDBSymbol(PDBSession, std::move(Symbol)) {}
72 
73 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getReturnType() const {
74  return Session.getSymbolById(getTypeId());
75 }
76 
77 std::unique_ptr<IPDBEnumSymbols>
79  return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
80 }
81 
82 std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
83  uint32_t ClassId = getClassParentId();
84  if (ClassId == 0)
85  return nullptr;
86  return Session.getSymbolById(ClassId);
87 }
88 
90  Dumper.dump(*this);
91 }
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:25
PDBSymbolTypeFunctionSig(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > Symbol)
std::unique_ptr< PDBSymbol > getClassParent() const
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.
std::unique_ptr< IPDBEnumSymbols > getArguments() const
virtual std::unique_ptr< PDBSymbol > getSymbolById(uint32_t SymbolId) const =0
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e...
Definition: PDBSymbol.h:43
std::unique_ptr< PDBSymbol > getReturnType() const
virtual void dump(const PDBSymbolAnnotation &Symbol)
const IPDBSession & Session
Definition: PDBSymbol.h:94