clang 23.0.0git
VTableBuilder.h
Go to the documentation of this file.
1//===--- VTableBuilder.h - C++ vtable layout builder --------------*- 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// This contains code dealing with generation of the layout of virtual tables.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_VTABLEBUILDER_H
14#define LLVM_CLANG_AST_VTABLEBUILDER_H
15
20#include "clang/Basic/ABI.h"
21#include "clang/Basic/Thunk.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/SmallVector.h"
24#include <memory>
25#include <utility>
26
27namespace clang {
28 class CXXRecordDecl;
29
30/// Represents a single component in a vtable.
32public:
33 enum Kind {
39
40 /// A pointer to the complete destructor.
42
43 /// A pointer to the deleting destructor.
45
46 /// An entry that is never used.
47 ///
48 /// In some cases, a vtable function pointer will end up never being
49 /// called. Such vtable function pointers are represented as a
50 /// CK_UnusedFunctionPointer.
52 };
53
54 VTableComponent() = default;
55
57 return VTableComponent(CK_VCallOffset, Offset);
58 }
59
61 return VTableComponent(CK_VBaseOffset, Offset);
62 }
63
65 return VTableComponent(CK_OffsetToTop, Offset);
66 }
67
69 return VTableComponent(CK_RTTI, reinterpret_cast<uintptr_t>(RD));
70 }
71
73 assert(!isa<CXXDestructorDecl>(MD) &&
74 "Don't use MakeFunction with destructors!");
75
77 reinterpret_cast<uintptr_t>(MD));
78 }
79
82 reinterpret_cast<uintptr_t>(DD));
83 }
84
87 reinterpret_cast<uintptr_t>(DD));
88 }
89
91 assert(!isa<CXXDestructorDecl>(MD) &&
92 "Don't use MakeUnusedFunction with destructors!");
94 reinterpret_cast<uintptr_t>(MD));
95 }
96
97 /// Get the kind of this vtable component.
98 Kind getKind() const {
99 return (Kind)(Value & 0x7);
100 }
101
103 assert(getKind() == CK_VCallOffset && "Invalid component kind!");
104
105 return getOffset();
106 }
107
109 assert(getKind() == CK_VBaseOffset && "Invalid component kind!");
110
111 return getOffset();
112 }
113
115 assert(getKind() == CK_OffsetToTop && "Invalid component kind!");
116
117 return getOffset();
118 }
119
120 const CXXRecordDecl *getRTTIDecl() const {
121 assert(isRTTIKind() && "Invalid component kind!");
122 return reinterpret_cast<CXXRecordDecl *>(getPointer());
123 }
124
126 assert(isFunctionPointerKind() && "Invalid component kind!");
127 if (isDestructorKind())
128 return getDestructorDecl();
129 return reinterpret_cast<CXXMethodDecl *>(getPointer());
130 }
131
133 assert(isDestructorKind() && "Invalid component kind!");
134 return reinterpret_cast<CXXDestructorDecl *>(getPointer());
135 }
136
138 assert(getKind() == CK_UnusedFunctionPointer && "Invalid component kind!");
139 return reinterpret_cast<CXXMethodDecl *>(getPointer());
140 }
141
142 bool isDestructorKind() const { return isDestructorKind(getKind()); }
143
147
150 }
151
152 bool isRTTIKind() const { return isRTTIKind(getKind()); }
153
154 GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
155 assert(isUsedFunctionPointerKind() &&
156 "GlobalDecl can be created only from virtual function");
157
158 auto *DtorDecl = dyn_cast<CXXDestructorDecl>(getFunctionDecl());
159 switch (getKind()) {
161 return GlobalDecl(getFunctionDecl());
163 return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
165 return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
168 case CK_VCallOffset:
169 case CK_VBaseOffset:
170 case CK_OffsetToTop:
171 case CK_RTTI:
173 llvm_unreachable("Only function pointers kinds");
174 }
175 llvm_unreachable("Should already return");
176 }
177
178private:
179 static bool isFunctionPointerKind(Kind ComponentKind) {
180 return isUsedFunctionPointerKind(ComponentKind) ||
181 ComponentKind == CK_UnusedFunctionPointer;
182 }
183 static bool isUsedFunctionPointerKind(Kind ComponentKind) {
184 return ComponentKind == CK_FunctionPointer ||
185 isDestructorKind(ComponentKind);
186 }
187 static bool isDestructorKind(Kind ComponentKind) {
188 return ComponentKind == CK_CompleteDtorPointer ||
189 ComponentKind == CK_DeletingDtorPointer;
190 }
191 static bool isRTTIKind(Kind ComponentKind) {
192 return ComponentKind == CK_RTTI;
193 }
194
195 VTableComponent(Kind ComponentKind, CharUnits Offset) {
196 assert((ComponentKind == CK_VCallOffset ||
197 ComponentKind == CK_VBaseOffset ||
198 ComponentKind == CK_OffsetToTop) && "Invalid component kind!");
199 assert(Offset.getQuantity() < (1LL << 56) && "Offset is too big!");
200 assert(Offset.getQuantity() >= -(1LL << 56) && "Offset is too small!");
201
202 Value = (uint64_t(Offset.getQuantity()) << 3) | ComponentKind;
203 }
204
205 VTableComponent(Kind ComponentKind, uintptr_t Ptr) {
206 assert((isRTTIKind(ComponentKind) || isFunctionPointerKind(ComponentKind)) &&
207 "Invalid component kind!");
208
209 assert((Ptr & 7) == 0 && "Pointer not sufficiently aligned!");
210
211 Value = Ptr | ComponentKind;
212 }
213
214 CharUnits getOffset() const {
215 assert((getKind() == CK_VCallOffset || getKind() == CK_VBaseOffset ||
216 getKind() == CK_OffsetToTop) && "Invalid component kind!");
217
218 return CharUnits::fromQuantity(Value >> 3);
219 }
220
221 uintptr_t getPointer() const {
222 assert((getKind() == CK_RTTI || isFunctionPointerKind()) &&
223 "Invalid component kind!");
224
225 return static_cast<uintptr_t>(Value & ~7ULL);
226 }
227
228 /// The kind is stored in the lower 3 bits of the value. For offsets, we
229 /// make use of the facts that classes can't be larger than 2^55 bytes,
230 /// so we store the offset in the lower part of the 61 bits that remain.
231 /// (The reason that we're not simply using a PointerIntPair here is that we
232 /// need the offsets to be 64-bit, even when on a 32-bit machine).
233 int64_t Value;
234};
235
237public:
238 typedef std::pair<uint64_t, ThunkInfo> VTableThunkTy;
242 typedef llvm::DenseMap<BaseSubobject, AddressPointLocation>
244
245 // Mapping between the VTable index and address point index. This is useful
246 // when you don't care about the base subobjects and only want the address
247 // point for a given vtable index.
249
251
252private:
253 // Stores the component indices of the first component of each virtual table
254 // in the virtual table group.
255 VTableIndicesTy VTableIndices;
256
258
259 /// Contains thunks needed by vtables, sorted by indices.
261
262 /// Address points for all vtables.
263 AddressPointsMapTy AddressPoints;
264
265 /// Address points for all vtable indices.
266 AddressPointsIndexMapTy AddressPointIndices;
267
268public:
269 // Requires `VTableIndices.front() == 0`
270 VTableLayout(VTableIndicesTy VTableIndices,
271 ArrayRef<VTableComponent> VTableComponents,
272 ArrayRef<VTableThunkTy> VTableThunks,
273 const AddressPointsMapTy &AddressPoints);
275
277 return VTableComponents;
278 }
279
281 return VTableThunks;
282 }
283
285 assert(AddressPoints.count(Base) && "Did not find address point!");
286 return AddressPoints.lookup(Base);
287 }
288
290 return AddressPoints;
291 }
292
294 return AddressPointIndices;
295 }
296
297 size_t getNumVTables() const { return VTableIndices.size(); }
298
299 size_t getVTableOffset(size_t i) const { return VTableIndices[i]; }
300
301 size_t getVTableSize(size_t i) const {
302 size_t thisIndex = VTableIndices[i];
303 size_t nextIndex = (i + 1 == VTableIndices.size())
304 ? vtable_components().size()
305 : VTableIndices[i + 1];
306 return nextIndex - thisIndex;
307 }
308};
309
311public:
313
314 bool isMicrosoft() const { return IsMicrosoftABI; }
315
317
318protected:
319 typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy;
320
321 /// Contains all thunks that a given method decl will need.
323
324 /// Compute and store all vtable related information (vtable layout, vbase
325 /// offset offsets, thunks etc) for the given record decl.
327
329
330public:
334
335 // This assumes that all the destructors present in the vtable
336 // use exactly the same set of thunks.
337 ThunksMapTy::const_iterator I = Thunks.find(MD);
338 if (I == Thunks.end()) {
339 // We did not find a thunk for this method.
340 return nullptr;
341 }
342
343 return &I->second;
344 }
345
347
348 /// Determine whether this function should be assigned a vtable slot.
349 static bool hasVtableSlot(const CXXMethodDecl *MD);
350};
351
353public:
354 typedef llvm::DenseMap<const CXXMethodDecl *, const CXXMethodDecl *>
356
357private:
358
359 /// Contains the index (relative to the vtable address point)
360 /// where the function pointer for a virtual function is stored.
361 typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVTableIndicesTy;
362 MethodVTableIndicesTy MethodVTableIndices;
363
364 typedef llvm::DenseMap<const CXXRecordDecl *,
365 std::unique_ptr<const VTableLayout>>
366 VTableLayoutMapTy;
367 VTableLayoutMapTy VTableLayouts;
368
369 typedef std::pair<const CXXRecordDecl *,
370 const CXXRecordDecl *> ClassPairTy;
371
372 /// vtable offsets for offsets of virtual bases of a class.
373 ///
374 /// Contains the vtable offset (relative to the address point) in chars
375 /// where the offsets for virtual bases of a class are stored.
376 typedef llvm::DenseMap<ClassPairTy, CharUnits>
377 VirtualBaseClassOffsetOffsetsMapTy;
378 VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets;
379
380 /// Map from a virtual method to the nearest method in the primary base class
381 /// chain that it overrides.
382 OriginalMethodMapTy OriginalMethodMap;
383
384 void computeVTableRelatedInformation(const CXXRecordDecl *RD) override;
385
386public:
388 ~ItaniumVTableContext() override;
389
391 computeVTableRelatedInformation(RD);
392 assert(VTableLayouts.count(RD) && "No layout for this record decl!");
393
394 return *VTableLayouts[RD];
395 }
396
397 std::unique_ptr<VTableLayout> createConstructionVTableLayout(
398 const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
399 bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass);
400
401 /// Locate a virtual function in the vtable.
402 ///
403 /// Return the index (relative to the vtable address point) where the
404 /// function pointer for the given virtual function is stored.
405 uint64_t getMethodVTableIndex(GlobalDecl GD);
406
407 /// Return the offset in chars (relative to the vtable address point) where
408 /// the offset of the virtual base that contains the given base is stored,
409 /// otherwise, if no virtual base contains the given class, return 0.
410 ///
411 /// Base must be a virtual base class or an unambiguous base.
413 const CXXRecordDecl *VBase);
414
415 /// Return the method that added the v-table slot that will be used to call
416 /// the given method.
417 ///
418 /// In the Itanium ABI, where overrides always cause methods to be added to
419 /// the primary v-table if they're not already there, this will be the first
420 /// declaration in the primary base class chain for which the return type
421 /// adjustment is trivial.
423
425
426 void setOriginalMethod(const CXXMethodDecl *Key, const CXXMethodDecl *Val) {
427 OriginalMethodMap[Key] = Val;
428 }
429
430 /// This method is reserved for the implementation and shouldn't be used
431 /// directly.
433 return OriginalMethodMap;
434 }
435
436 static bool classof(const VTableContextBase *VT) {
437 return !VT->isMicrosoft();
438 }
439};
440
441/// Holds information about the inheritance path to a virtual base or function
442/// table pointer. A record may contain as many vfptrs or vbptrs as there are
443/// base subobjects.
444struct VPtrInfo {
446
449
450 /// This is the most derived class that has this vptr at offset zero. When
451 /// single inheritance is used, this is always the most derived class. If
452 /// multiple inheritance is used, it may be any direct or indirect base.
454
455 /// This is the class that introduced the vptr by declaring new virtual
456 /// methods or virtual bases.
458
459 /// IntroducingObject is at this offset from its containing complete object or
460 /// virtual base.
462
463 /// The bases from the inheritance path that got used to mangle the vbtable
464 /// name. This is not really a full path like a CXXBasePath. It holds the
465 /// subset of records that need to be mangled into the vbtable symbol name in
466 /// order to get a unique name.
468
469 /// The next base to push onto the mangled path if this path is ambiguous in a
470 /// derived class. If it's null, then it's already been pushed onto the path.
472
473 /// The set of possibly indirect vbases that contain this vbtable. When a
474 /// derived class indirectly inherits from the same vbase twice, we only keep
475 /// vtables and their paths from the first instance.
477
478 /// This holds the base classes path from the complete type to the first base
479 /// with the given vfptr offset, in the base-to-derived order. Only used for
480 /// vftables.
482
483 /// Static offset from the top of the most derived class to this vfptr,
484 /// including any virtual base offset. Only used for vftables.
486
487 /// The vptr is stored inside the non-virtual component of this virtual base.
489 return ContainingVBases.empty() ? nullptr : ContainingVBases.front();
490 }
491};
492
494
495/// All virtual base related information about a given record decl. Includes
496/// information on all virtual base tables and the path components that are used
497/// to mangle them.
499 /// A map from virtual base to vbtable index for doing a conversion from the
500 /// the derived class to the a base.
501 llvm::DenseMap<const CXXRecordDecl *, unsigned> VBTableIndices;
502
503 /// Information on all virtual base tables used when this record is the most
504 /// derived class.
506};
507
509 /// If nonzero, holds the vbtable index of the virtual base with the vfptr.
510 uint64_t VBTableIndex;
511
512 /// If nonnull, holds the last vbase which contains the vfptr that the
513 /// method definition is adjusted to.
515
516 /// This is the offset of the vfptr from the start of the last vbase, or the
517 /// complete type if there are no virtual bases.
519
520 /// Method's index in the vftable.
521 uint64_t Index;
522
526
531
532 bool operator<(const MethodVFTableLocation &other) const {
533 if (VBTableIndex != other.VBTableIndex) {
534 assert(VBase != other.VBase);
535 return VBTableIndex < other.VBTableIndex;
536 }
537 return std::tie(VFPtrOffset, Index) <
538 std::tie(other.VFPtrOffset, other.Index);
539 }
540};
541
543public:
544
545private:
546 ASTContext &Context;
547
548 typedef llvm::DenseMap<GlobalDecl, MethodVFTableLocation>
549 MethodVFTableLocationsTy;
550 MethodVFTableLocationsTy MethodVFTableLocations;
551
552 typedef llvm::DenseMap<const CXXRecordDecl *, std::unique_ptr<VPtrInfoVector>>
553 VFPtrLocationsMapTy;
554 VFPtrLocationsMapTy VFPtrLocations;
555
556 typedef std::pair<const CXXRecordDecl *, CharUnits> VFTableIdTy;
557 typedef llvm::DenseMap<VFTableIdTy, std::unique_ptr<const VTableLayout>>
558 VFTableLayoutMapTy;
559 VFTableLayoutMapTy VFTableLayouts;
560
561 llvm::DenseMap<const CXXRecordDecl *, std::unique_ptr<VirtualBaseInfo>>
562 VBaseInfo;
563
564 void computeVTableRelatedInformation(const CXXRecordDecl *RD) override;
565
566 void dumpMethodLocations(const CXXRecordDecl *RD,
567 const MethodVFTableLocationsTy &NewMethods,
568 raw_ostream &);
569
570 const VirtualBaseInfo &
571 computeVBTableRelatedInformation(const CXXRecordDecl *RD);
572
573 void computeVTablePaths(bool ForVBTables, const CXXRecordDecl *RD,
574 VPtrInfoVector &Paths);
575
576public:
578 : VTableContextBase(/*MS=*/true), Context(Context) {}
579
580 ~MicrosoftVTableContext() override;
581
583
585 CharUnits VFPtrOffset);
586
588
590 // Complete destructors don't have a slot in a vftable, so no thunks needed.
593 return nullptr;
595 }
596
597 /// Returns the index of VBase in the vbtable of Derived.
598 /// VBase must be a morally virtual base of Derived.
599 /// The vbtable is an array of i32 offsets. The first entry is a self entry,
600 /// and the rest are offsets from the vbptr to virtual bases.
601 unsigned getVBTableIndex(const CXXRecordDecl *Derived,
602 const CXXRecordDecl *VBase);
603
605
606 static bool classof(const VTableContextBase *VT) { return VT->isMicrosoft(); }
607};
608
609} // namespace clang
610
611#endif
Enums/classes describing ABI related information about constructors, destructors and thunks.
Enums/classes describing THUNK related information about constructors, destructors and thunks.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:226
Represents a C++ destructor within a class.
Definition DeclCXX.h:2889
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2136
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition DeclCXX.h:2275
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:63
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:991
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
CXXDtorType getDtorType() const
Definition GlobalDecl.h:113
const Decl * getDecl() const
Definition GlobalDecl.h:106
const CXXMethodDecl * findOriginalMethodInMap(const CXXMethodDecl *MD) const
const OriginalMethodMapTy & getOriginalMethodMap()
This method is reserved for the implementation and shouldn't be used directly.
uint64_t getMethodVTableIndex(GlobalDecl GD)
Locate a virtual function in the vtable.
llvm::DenseMap< const CXXMethodDecl *, const CXXMethodDecl * > OriginalMethodMapTy
std::unique_ptr< VTableLayout > createConstructionVTableLayout(const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset, bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass)
const VTableLayout & getVTableLayout(const CXXRecordDecl *RD)
CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, const CXXRecordDecl *VBase)
Return the offset in chars (relative to the vtable address point) where the offset of the virtual bas...
GlobalDecl findOriginalMethod(GlobalDecl GD)
Return the method that added the v-table slot that will be used to call the given method.
void setOriginalMethod(const CXXMethodDecl *Key, const CXXMethodDecl *Val)
ItaniumVTableContext(ASTContext &Context)
static bool classof(const VTableContextBase *VT)
static bool classof(const VTableContextBase *VT)
const ThunkInfoVectorTy * getThunkInfo(GlobalDecl GD) override
MicrosoftVTableContext(ASTContext &Context)
unsigned getVBTableIndex(const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the index of VBase in the vbtable of Derived.
const VPtrInfoVector & enumerateVBTables(const CXXRecordDecl *RD)
MethodVFTableLocation getMethodVFTableLocation(GlobalDecl GD)
const VPtrInfoVector & getVFPtrOffsets(const CXXRecordDecl *RD)
const VTableLayout & getVFTableLayout(const CXXRecordDecl *RD, CharUnits VFPtrOffset)
static VTableComponent MakeCompleteDtor(const CXXDestructorDecl *DD)
static VTableComponent MakeRTTI(const CXXRecordDecl *RD)
const CXXMethodDecl * getUnusedFunctionDecl() const
static VTableComponent MakeOffsetToTop(CharUnits Offset)
bool isUsedFunctionPointerKind() const
bool isDestructorKind() const
CharUnits getVBaseOffset() const
static VTableComponent MakeUnusedFunction(const CXXMethodDecl *MD)
Kind getKind() const
Get the kind of this vtable component.
static VTableComponent MakeFunction(const CXXMethodDecl *MD)
@ CK_DeletingDtorPointer
A pointer to the deleting destructor.
@ CK_UnusedFunctionPointer
An entry that is never used.
@ CK_CompleteDtorPointer
A pointer to the complete destructor.
static VTableComponent MakeVBaseOffset(CharUnits Offset)
const CXXRecordDecl * getRTTIDecl() const
static VTableComponent MakeDeletingDtor(const CXXDestructorDecl *DD)
bool isFunctionPointerKind() const
CharUnits getOffsetToTop() const
const CXXMethodDecl * getFunctionDecl() const
GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const
static VTableComponent MakeVCallOffset(CharUnits Offset)
CharUnits getVCallOffset() const
const CXXDestructorDecl * getDestructorDecl() const
virtual const ThunkInfoVectorTy * getThunkInfo(GlobalDecl GD)
static bool hasVtableSlot(const CXXMethodDecl *MD)
Determine whether this function should be assigned a vtable slot.
virtual void computeVTableRelatedInformation(const CXXRecordDecl *RD)=0
Compute and store all vtable related information (vtable layout, vbase offset offsets,...
SmallVector< ThunkInfo, 1 > ThunkInfoVectorTy
llvm::DenseMap< const CXXMethodDecl *, ThunkInfoVectorTy > ThunksMapTy
ThunksMapTy Thunks
Contains all thunks that a given method decl will need.
llvm::SmallVector< std::size_t > VTableIndicesTy
VTableLayout(VTableIndicesTy VTableIndices, ArrayRef< VTableComponent > VTableComponents, ArrayRef< VTableThunkTy > VTableThunks, const AddressPointsMapTy &AddressPoints)
const AddressPointsIndexMapTy & getAddressPointIndices() const
size_t getVTableOffset(size_t i) const
llvm::SmallVector< unsigned, 4 > AddressPointsIndexMapTy
llvm::DenseMap< BaseSubobject, AddressPointLocation > AddressPointsMapTy
AddressPointLocation getAddressPoint(BaseSubobject Base) const
std::pair< uint64_t, ThunkInfo > VTableThunkTy
ArrayRef< VTableComponent > vtable_components() const
size_t getNumVTables() const
ArrayRef< VTableThunkTy > vtable_thunks() const
const AddressPointsMapTy & getAddressPoints() const
size_t getVTableSize(size_t i) const
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
SmallVector< std::unique_ptr< VPtrInfo >, 2 > VPtrInfoVector
@ Dtor_VectorDeleting
Vector deleting dtor.
Definition ABI.h:40
@ Dtor_Complete
Complete object dtor.
Definition ABI.h:36
@ Dtor_Deleting
Deleting dtor.
Definition ABI.h:35
U cast(CodeGen::Address addr)
Definition Address.h:327
unsigned long uint64_t
long int64_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
#define true
Definition stdbool.h:25
bool operator<(const MethodVFTableLocation &other) const
const CXXRecordDecl * VBase
If nonnull, holds the last vbase which contains the vfptr that the method definition is adjusted to.
MethodVFTableLocation(uint64_t VBTableIndex, const CXXRecordDecl *VBase, CharUnits VFPtrOffset, uint64_t Index)
CharUnits VFPtrOffset
This is the offset of the vfptr from the start of the last vbase, or the complete type if there are n...
uint64_t VBTableIndex
If nonzero, holds the vbtable index of the virtual base with the vfptr.
uint64_t Index
Method's index in the vftable.
CharUnits NonVirtualOffset
IntroducingObject is at this offset from its containing complete object or virtual base.
CharUnits FullOffsetInMDC
Static offset from the top of the most derived class to this vfptr, including any virtual base offset...
const CXXRecordDecl * getVBaseWithVPtr() const
The vptr is stored inside the non-virtual component of this virtual base.
SmallVector< const CXXRecordDecl *, 1 > BasePath
VPtrInfo(const CXXRecordDecl *RD)
BasePath ContainingVBases
The set of possibly indirect vbases that contain this vbtable.
const CXXRecordDecl * IntroducingObject
This is the class that introduced the vptr by declaring new virtual methods or virtual bases.
BasePath MangledPath
The bases from the inheritance path that got used to mangle the vbtable name.
const CXXRecordDecl * NextBaseToMangle
The next base to push onto the mangled path if this path is ambiguous in a derived class.
BasePath PathToIntroducingObject
This holds the base classes path from the complete type to the first base with the given vfptr offset...
const CXXRecordDecl * ObjectWithVPtr
This is the most derived class that has this vptr at offset zero.
All virtual base related information about a given record decl.
VPtrInfoVector VBPtrPaths
Information on all virtual base tables used when this record is the most derived class.
llvm::DenseMap< const CXXRecordDecl *, unsigned > VBTableIndices
A map from virtual base to vbtable index for doing a conversion from the the derived class to the a b...