LLVM 20.0.0git
UDTLayout.h
Go to the documentation of this file.
1//===- UDTLayout.h - UDT layout info ----------------------------*- 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//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_PDB_UDTLAYOUT_H
10#define LLVM_DEBUGINFO_PDB_UDTLAYOUT_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/BitVector.h"
14#include "llvm/ADT/StringRef.h"
21#include <cstdint>
22#include <memory>
23#include <string>
24#include <vector>
25
26namespace llvm {
27namespace pdb {
28
29class BaseClassLayout;
30class ClassLayout;
31class UDTLayoutBase;
32
34public:
36 const std::string &Name, uint32_t OffsetInParent,
37 uint32_t Size, bool IsElided);
38 virtual ~LayoutItemBase() = default;
39
41 virtual uint32_t immediatePadding() const { return 0; }
42 virtual uint32_t tailPadding() const;
43
44 const UDTLayoutBase *getParent() const { return Parent; }
45 StringRef getName() const { return Name; }
47 uint32_t getSize() const { return SizeOf; }
48 uint32_t getLayoutSize() const { return LayoutSize; }
49 const PDBSymbol *getSymbol() const { return Symbol; }
50 const BitVector &usedBytes() const { return UsedBytes; }
51 bool isElided() const { return IsElided; }
52 virtual bool isVBPtr() const { return false; }
53
56 uint32_t End = Begin + getSize();
57 return (Off >= Begin && Off < End);
58 }
59
60protected:
61 const PDBSymbol *Symbol = nullptr;
62 const UDTLayoutBase *Parent = nullptr;
64 std::string Name;
68 bool IsElided = false;
69};
70
72public:
74 std::unique_ptr<PDBSymbolTypeBuiltin> Sym, uint32_t Offset,
76
77 bool isVBPtr() const override { return true; }
78
79private:
80 std::unique_ptr<PDBSymbolTypeBuiltin> Type;
81};
82
84public:
86 std::unique_ptr<PDBSymbolData> DataMember);
87
89 bool hasUDTLayout() const;
90 const ClassLayout &getUDTLayout() const;
91
92private:
93 std::unique_ptr<PDBSymbolData> DataMember;
94 std::unique_ptr<ClassLayout> UdtLayout;
95};
96
98public:
100 std::unique_ptr<PDBSymbolTypeVTable> VTable);
101
102 uint32_t getElementSize() const { return ElementSize; }
103
104private:
105 uint32_t ElementSize = 0;
106 std::unique_ptr<PDBSymbolTypeVTable> VTable;
107};
108
110 template <typename T> using UniquePtrVector = std::vector<std::unique_ptr<T>>;
111
112public:
114 const std::string &Name, uint32_t OffsetInParent, uint32_t Size,
115 bool IsElided);
116
117 uint32_t tailPadding() const override;
125
126protected:
127 bool hasVBPtrAtOffset(uint32_t Off) const;
128 void initializeChildren(const PDBSymbol &Sym);
129
130 void addChildToLayout(std::unique_ptr<LayoutItemBase> Child);
131
133
134 UniquePtrVector<PDBSymbol> Other;
135 UniquePtrVector<PDBSymbolFunc> Funcs;
136 UniquePtrVector<LayoutItemBase> ChildStorage;
137 std::vector<LayoutItemBase *> LayoutItems;
138
139 std::vector<BaseClassLayout *> AllBases;
142
145};
146
148public:
150 bool Elide, std::unique_ptr<PDBSymbolTypeBaseClass> Base);
151
152 const PDBSymbolTypeBaseClass &getBase() const { return *Base; }
153 bool isVirtualBase() const { return IsVirtualBase; }
154 bool isEmptyBase() { return SizeOf == 1 && LayoutSize == 0; }
155
156private:
157 std::unique_ptr<PDBSymbolTypeBaseClass> Base;
158 bool IsVirtualBase;
159};
160
162public:
163 explicit ClassLayout(const PDBSymbolTypeUDT &UDT);
164 explicit ClassLayout(std::unique_ptr<PDBSymbolTypeUDT> UDT);
165
167
168 const PDBSymbolTypeUDT &getClass() const { return UDT; }
169 uint32_t immediatePadding() const override;
170
171private:
172 BitVector ImmediateUsedBytes;
173 std::unique_ptr<PDBSymbolTypeUDT> OwnedStorage;
174 const PDBSymbolTypeUDT &UDT;
175};
176
177} // end namespace pdb
178} // end namespace llvm
179
180#endif // LLVM_DEBUGINFO_PDB_UDTLAYOUT_H
This file implements the BitVector class.
uint64_t Size
bool End
Definition: ELF_riscv.cpp:480
Symbol * Sym
Definition: ELF_riscv.cpp:479
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
bool isVirtualBase() const
Definition: UDTLayout.h:153
const PDBSymbolTypeBaseClass & getBase() const
Definition: UDTLayout.h:152
uint32_t immediatePadding() const override
Definition: UDTLayout.cpp:150
const PDBSymbolTypeUDT & getClass() const
Definition: UDTLayout.h:168
ClassLayout(ClassLayout &&Other)=default
const PDBSymbolData & getDataMember()
Definition: UDTLayout.cpp:89
const ClassLayout & getUDTLayout() const
Definition: UDTLayout.cpp:95
const PDBSymbol * getSymbol() const
Definition: UDTLayout.h:49
virtual ~LayoutItemBase()=default
StringRef getName() const
Definition: UDTLayout.h:45
uint32_t getSize() const
Definition: UDTLayout.h:47
virtual uint32_t tailPadding() const
Definition: UDTLayout.cpp:64
uint32_t deepPaddingSize() const
Definition: UDTLayout.cpp:60
const BitVector & usedBytes() const
Definition: UDTLayout.h:50
virtual bool isVBPtr() const
Definition: UDTLayout.h:52
uint32_t getOffsetInParent() const
Definition: UDTLayout.h:46
uint32_t containsOffset(uint32_t Off) const
Definition: UDTLayout.h:54
uint32_t getLayoutSize() const
Definition: UDTLayout.h:48
virtual uint32_t immediatePadding() const
Definition: UDTLayout.h:41
const UDTLayoutBase * getParent() const
Definition: UDTLayout.h:44
bool isElided() const
Definition: UDTLayout.h:51
const UDTLayoutBase * Parent
Definition: UDTLayout.h:62
const PDBSymbol * Symbol
Definition: UDTLayout.h:61
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e....
Definition: PDBSymbol.h:71
ArrayRef< BaseClassLayout * > VirtualBases
Definition: UDTLayout.h:141
ArrayRef< BaseClassLayout * > virtual_bases() const
Definition: UDTLayout.h:121
ArrayRef< BaseClassLayout * > bases() const
Definition: UDTLayout.h:119
bool hasVBPtrAtOffset(uint32_t Off) const
Definition: UDTLayout.cpp:270
ArrayRef< BaseClassLayout * > regular_bases() const
Definition: UDTLayout.h:120
ArrayRef< std::unique_ptr< PDBSymbol > > other_items() const
Definition: UDTLayout.h:124
std::vector< LayoutItemBase * > LayoutItems
Definition: UDTLayout.h:137
ArrayRef< LayoutItemBase * > layout_items() const
Definition: UDTLayout.h:118
UniquePtrVector< PDBSymbol > Other
Definition: UDTLayout.h:134
uint32_t tailPadding() const override
Definition: UDTLayout.cpp:120
ArrayRef< std::unique_ptr< PDBSymbolFunc > > funcs() const
Definition: UDTLayout.h:123
void addChildToLayout(std::unique_ptr< LayoutItemBase > Child)
Definition: UDTLayout.cpp:280
std::vector< BaseClassLayout * > AllBases
Definition: UDTLayout.h:139
UniquePtrVector< PDBSymbolFunc > Funcs
Definition: UDTLayout.h:135
VTableLayoutItem * VTable
Definition: UDTLayout.h:143
void initializeChildren(const PDBSymbol &Sym)
Definition: UDTLayout.cpp:168
uint32_t directVirtualBaseCount() const
Definition: UDTLayout.h:122
UniquePtrVector< LayoutItemBase > ChildStorage
Definition: UDTLayout.h:136
ArrayRef< BaseClassLayout * > NonVirtualBases
Definition: UDTLayout.h:140
VBPtrLayoutItem * VBPtr
Definition: UDTLayout.h:144
bool isVBPtr() const override
Definition: UDTLayout.h:77
uint32_t getElementSize() const
Definition: UDTLayout.h:102
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18