LLVM  5.0.0
PDBSymbolFunc.cpp
Go to the documentation of this file.
1 //===- PDBSymbolFunc.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 
20 
21 #include <unordered_set>
22 #include <utility>
23 #include <vector>
24 
25 using namespace llvm;
26 using namespace llvm::pdb;
27 
28 namespace {
29 class FunctionArgEnumerator : public IPDBEnumChildren<PDBSymbolData> {
30 public:
31  typedef ConcreteSymbolEnumerator<PDBSymbolData> ArgEnumeratorType;
32 
33  FunctionArgEnumerator(const IPDBSession &PDBSession,
34  const PDBSymbolFunc &PDBFunc)
35  : Session(PDBSession), Func(PDBFunc) {
36  // Arguments can appear multiple times if they have live range
37  // information, so we only take the first occurrence.
38  std::unordered_set<std::string> SeenNames;
39  auto DataChildren = Func.findAllChildren<PDBSymbolData>();
40  while (auto Child = DataChildren->getNext()) {
41  if (Child->getDataKind() == PDB_DataKind::Param) {
42  std::string Name = Child->getName();
43  if (SeenNames.find(Name) != SeenNames.end())
44  continue;
45  Args.push_back(std::move(Child));
46  SeenNames.insert(Name);
47  }
48  }
49  reset();
50  }
51 
52  uint32_t getChildCount() const override { return Args.size(); }
53 
54  std::unique_ptr<PDBSymbolData>
55  getChildAtIndex(uint32_t Index) const override {
56  if (Index >= Args.size())
57  return nullptr;
58 
59  return Session.getConcreteSymbolById<PDBSymbolData>(
60  Args[Index]->getSymIndexId());
61  }
62 
63  std::unique_ptr<PDBSymbolData> getNext() override {
64  if (CurIter == Args.end())
65  return nullptr;
66  const auto &Result = **CurIter;
67  ++CurIter;
68  return Session.getConcreteSymbolById<PDBSymbolData>(Result.getSymIndexId());
69  }
70 
71  void reset() override { CurIter = Args.empty() ? Args.end() : Args.begin(); }
72 
73  FunctionArgEnumerator *clone() const override {
74  return new FunctionArgEnumerator(Session, Func);
75  }
76 
77 private:
78  typedef std::vector<std::unique_ptr<PDBSymbolData>> ArgListType;
79  const IPDBSession &Session;
80  const PDBSymbolFunc &Func;
81  ArgListType Args;
82  ArgListType::const_iterator CurIter;
83 };
84 }
85 
87  std::unique_ptr<IPDBRawSymbol> Symbol)
88  : PDBSymbol(PDBSession, std::move(Symbol)) {
89  assert(RawSymbol->getSymTag() == PDB_SymType::Function);
90 }
91 
92 std::unique_ptr<IPDBEnumChildren<PDBSymbolData>>
94  return llvm::make_unique<FunctionArgEnumerator>(Session, *this);
95 }
96 
97 void PDBSymbolFunc::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
98 
100  std::string Name = getName();
101  if (Name.empty())
102  return false;
103  if (Name[0] == '~')
104  return true;
105  if (Name == "__vecDelDtor")
106  return true;
107  return false;
108 }
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition: IPDBSession.h:26
PDBSymbolFunc(const IPDBSession &PDBSession, std::unique_ptr< IPDBRawSymbol > FuncSymbol)
std::unique_ptr< IPDBRawSymbol > RawSymbol
Definition: PDBSymbol.h:134
static StringRef getName(Value *V)
const char * Name
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e...
Definition: PDBSymbol.h:61
std::unique_ptr< IPDBEnumChildren< PDBSymbolData > > getArguments() const
virtual void dump(const PDBSymbolAnnotation &Symbol)
const IPDBSession & Session
Definition: PDBSymbol.h:133
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void dump(PDBSymDumper &Dumper) const override
Dumps the contents of a symbol a raw_ostream.