[ARM] Split large truncating MVE stores
[llvm-complete.git] / lib / DebugInfo / PDB / PDBSymbolFunc.cpp
blobcb0329bc0ed72cd3b22012b92c596e15ff828665
1 //===- PDBSymbolFunc.cpp - --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
11 #include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13 #include "llvm/DebugInfo/PDB/IPDBSession.h"
14 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
17 #include "llvm/DebugInfo/PDB/PDBTypes.h"
19 #include <unordered_set>
20 #include <utility>
21 #include <vector>
23 using namespace llvm;
24 using namespace llvm::pdb;
26 namespace {
27 class FunctionArgEnumerator : public IPDBEnumChildren<PDBSymbolData> {
28 public:
29 typedef ConcreteSymbolEnumerator<PDBSymbolData> ArgEnumeratorType;
31 FunctionArgEnumerator(const IPDBSession &PDBSession,
32 const PDBSymbolFunc &PDBFunc)
33 : Session(PDBSession), Func(PDBFunc) {
34 // Arguments can appear multiple times if they have live range
35 // information, so we only take the first occurrence.
36 std::unordered_set<std::string> SeenNames;
37 auto DataChildren = Func.findAllChildren<PDBSymbolData>();
38 while (auto Child = DataChildren->getNext()) {
39 if (Child->getDataKind() == PDB_DataKind::Param) {
40 std::string Name = Child->getName();
41 if (SeenNames.find(Name) != SeenNames.end())
42 continue;
43 Args.push_back(std::move(Child));
44 SeenNames.insert(Name);
47 reset();
50 uint32_t getChildCount() const override { return Args.size(); }
52 std::unique_ptr<PDBSymbolData>
53 getChildAtIndex(uint32_t Index) const override {
54 if (Index >= Args.size())
55 return nullptr;
57 return Session.getConcreteSymbolById<PDBSymbolData>(
58 Args[Index]->getSymIndexId());
61 std::unique_ptr<PDBSymbolData> getNext() override {
62 if (CurIter == Args.end())
63 return nullptr;
64 const auto &Result = **CurIter;
65 ++CurIter;
66 return Session.getConcreteSymbolById<PDBSymbolData>(Result.getSymIndexId());
69 void reset() override { CurIter = Args.empty() ? Args.end() : Args.begin(); }
71 private:
72 typedef std::vector<std::unique_ptr<PDBSymbolData>> ArgListType;
73 const IPDBSession &Session;
74 const PDBSymbolFunc &Func;
75 ArgListType Args;
76 ArgListType::const_iterator CurIter;
80 std::unique_ptr<IPDBEnumChildren<PDBSymbolData>>
81 PDBSymbolFunc::getArguments() const {
82 return std::make_unique<FunctionArgEnumerator>(Session, *this);
85 void PDBSymbolFunc::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); }
87 bool PDBSymbolFunc::isDestructor() const {
88 std::string Name = getName();
89 if (Name.empty())
90 return false;
91 if (Name[0] == '~')
92 return true;
93 if (Name == "__vecDelDtor")
94 return true;
95 return false;
98 std::unique_ptr<IPDBEnumLineNumbers> PDBSymbolFunc::getLineNumbers() const {
99 auto Len = RawSymbol->getLength();
100 return Session.findLineNumbersByAddress(RawSymbol->getVirtualAddress(),
101 Len ? Len : 1);
104 uint32_t PDBSymbolFunc::getCompilandId() const {
105 if (auto Lines = getLineNumbers()) {
106 if (auto FirstLine = Lines->getNext()) {
107 return FirstLine->getCompilandId();
110 return 0;