clang 22.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 <memory>
24#include <utility>
25
26namespace clang {
27 class CXXRecordDecl;
28
29/// Represents a single component in a vtable.
31public:
32 enum Kind {
38
39 /// A pointer to the complete destructor.
41
42 /// A pointer to the deleting destructor.
44
45 /// An entry that is never used.
46 ///
47 /// In some cases, a vtable function pointer will end up never being
48 /// called. Such vtable function pointers are represented as a
49 /// CK_UnusedFunctionPointer.
51 };
52
53 VTableComponent() = default;
54
56 return VTableComponent(CK_VCallOffset, Offset);
57 }
58
60 return VTableComponent(CK_VBaseOffset, Offset);
61 }
62
64 return VTableComponent(CK_OffsetToTop, Offset);
65 }
66
68 return VTableComponent(CK_RTTI, reinterpret_cast<uintptr_t>(RD));
69 }
70
72 assert(!isa<CXXDestructorDecl>(MD) &&
73 "Don't use MakeFunction with destructors!");
74
76 reinterpret_cast<uintptr_t>(MD));
77 }
78
81 reinterpret_cast<uintptr_t>(DD));
82 }
83
86 reinterpret_cast<uintptr_t>(DD));
87 }
88
90 assert(!isa<CXXDestructorDecl>(MD) &&
91 "Don't use MakeUnusedFunction with destructors!");
93 reinterpret_cast<uintptr_t>(MD));
94 }
95
96 /// Get the kind of this vtable component.
97 Kind getKind() const {
98 return (Kind)(Value & 0x7);
99 }
100
102 assert(getKind() == CK_VCallOffset && "Invalid component kind!");
103
104 return getOffset();
105 }
106
108 assert(getKind() == CK_VBaseOffset && "Invalid component kind!");
109
110 return getOffset();
111 }
112
114 assert(getKind() == CK_OffsetToTop && "Invalid component kind!");
115
116 return getOffset();
117 }
118
119 const CXXRecordDecl *getRTTIDecl() const {
120 assert(isRTTIKind() && "Invalid component kind!");
121 return reinterpret_cast<CXXRecordDecl *>(getPointer());
122 }
123
125 assert(isFunctionPointerKind() && "Invalid component kind!");
126 if (isDestructorKind())
127 return getDestructorDecl();
128 return reinterpret_cast<CXXMethodDecl *>(getPointer());
129 }
130
132 assert(isDestructorKind() && "Invalid component kind!");
133 return reinterpret_cast<CXXDestructorDecl *>(getPointer());
134 }
135
137 assert(getKind() == CK_UnusedFunctionPointer && "Invalid component kind!");
138 return reinterpret_cast<CXXMethodDecl *>(getPointer());
139 }
140
141 bool isDestructorKind() const { return isDestructorKind(getKind()); }
142
146
149 }
150
151 bool isRTTIKind() const { return isRTTIKind(getKind()); }
152
153 GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
154 assert(isUsedFunctionPointerKind() &&
155 "GlobalDecl can be created only from virtual function");
156
157 auto *DtorDecl = dyn_cast<CXXDestructorDecl>(getFunctionDecl());
158 switch (getKind()) {
160 return GlobalDecl(getFunctionDecl());
162 return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
164 return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
167 case CK_VCallOffset:
168 case CK_VBaseOffset:
169 case CK_OffsetToTop:
170 case CK_RTTI:
172 llvm_unreachable("Only function pointers kinds");
173 }
174 llvm_unreachable("Should already return");
175 }
176
177private:
178 static bool isFunctionPointerKind(Kind ComponentKind) {
179 return isUsedFunctionPointerKind(ComponentKind) ||
180 ComponentKind == CK_UnusedFunctionPointer;
181 }
182 static bool isUsedFunctionPointerKind(Kind ComponentKind) {
183 return ComponentKind == CK_FunctionPointer ||
184 isDestructorKind(ComponentKind);
185 }
186 static bool isDestructorKind(Kind ComponentKind) {
187 return ComponentKind == CK_CompleteDtorPointer ||
188 ComponentKind == CK_DeletingDtorPointer;
189 }
190 static bool isRTTIKind(Kind ComponentKind) {
191 return ComponentKind == CK_RTTI;
192 }
193
194 VTableComponent(Kind ComponentKind, CharUnits Offset) {
195 assert((ComponentKind == CK_VCallOffset ||
196 ComponentKind == CK_VBaseOffset ||
197 ComponentKind == CK_OffsetToTop) && "Invalid component kind!");
198 assert(Offset.getQuantity() < (1LL << 56) && "Offset is too big!");
199 assert(Offset.getQuantity() >= -(1LL << 56) && "Offset is too small!");
200
201 Value = (uint64_t(Offset.getQuantity()) << 3) | ComponentKind;
202 }
203
204 VTableComponent(Kind ComponentKind, uintptr_t Ptr) {
205 assert((isRTTIKind(ComponentKind) || isFunctionPointerKind(ComponentKind)) &&
206 "Invalid component kind!");
207
208 assert((Ptr & 7) == 0 && "Pointer not sufficiently aligned!");
209
210 Value = Ptr | ComponentKind;
211 }
212
213 CharUnits getOffset() const {
214 assert((getKind() == CK_VCallOffset || getKind() == CK_VBaseOffset ||
215 getKind() == CK_OffsetToTop) && "Invalid component kind!");
216
217 return CharUnits::fromQuantity(Value >> 3);
218 }
219
220 uintptr_t getPointer() const {
221 assert((getKind() == CK_RTTI || isFunctionPointerKind()) &&
222 "Invalid component kind!");
223
224 return static_cast<uintptr_t>(Value & ~7ULL);
225 }
226
227 /// The kind is stored in the lower 3 bits of the value. For offsets, we
228 /// make use of the facts that classes can't be larger than 2^55 bytes,
229 /// so we store the offset in the lower part of the 61 bits that remain.
230 /// (The reason that we're not simply using a PointerIntPair here is that we
231 /// need the offsets to be 64-bit, even when on a 32-bit machine).
232 int64_t Value;
233};
234
236public:
237 typedef std::pair<uint64_t, ThunkInfo> VTableThunkTy;
241 typedef llvm::DenseMap<BaseSubobject, AddressPointLocation>
243
244 // Mapping between the VTable index and address point index. This is useful
245 // when you don't care about the base subobjects and only want the address
246 // point for a given vtable index.
248
250
251private:
252 // Stores the component indices of the first component of each virtual table
253 // in the virtual table group.
254 VTableIndicesTy VTableIndices;
255
256 OwningArrayRef<VTableComponent> VTableComponents;
257
258 /// Contains thunks needed by vtables, sorted by indices.
260
261 /// Address points for all vtables.
262 AddressPointsMapTy AddressPoints;
263
264 /// Address points for all vtable indices.
265 AddressPointsIndexMapTy AddressPointIndices;
266
267public:
268 // Requires `VTableIndices.front() == 0`
269 VTableLayout(VTableIndicesTy VTableIndices,
270 ArrayRef<VTableComponent> VTableComponents,
271 ArrayRef<VTableThunkTy> VTableThunks,
272 const AddressPointsMapTy &AddressPoints);
274
276 return VTableComponents;
277 }
278
280 return VTableThunks;
281 }
282
284 assert(AddressPoints.count(Base) && "Did not find address point!");
285 return AddressPoints.lookup(Base);
286 }
287
289 return AddressPoints;
290 }
291
293 return AddressPointIndices;
294 }
295
296 size_t getNumVTables() const { return VTableIndices.size(); }
297
298 size_t getVTableOffset(size_t i) const { return VTableIndices[i]; }
299
300 size_t getVTableSize(size_t i) const {
301 size_t thisIndex = VTableIndices[i];
302 size_t nextIndex = (i + 1 == VTableIndices.size())
303 ? vtable_components().size()
304 : VTableIndices[i + 1];
305 return nextIndex - thisIndex;
306 }
307};
308
310public:
312
313 bool isMicrosoft() const { return IsMicrosoftABI; }
314
316
317protected:
318 typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy;
319
320 /// Contains all thunks that a given method decl will need.
322
323 /// Compute and store all vtable related information (vtable layout, vbase
324 /// offset offsets, thunks etc) for the given record decl.
326
328
329public:
333
334 // This assumes that all the destructors present in the vtable
335 // use exactly the same set of thunks.
336 ThunksMapTy::const_iterator I = Thunks.find(MD);
337 if (I == Thunks.end()) {
338 // We did not find a thunk for this method.
339 return nullptr;
340 }
341
342 return &I->second;
343 }
344
346
347 /// Determine whether this function should be assigned a vtable slot.
348 static bool hasVtableSlot(const CXXMethodDecl *MD);
349};
350
352public:
353 typedef llvm::DenseMap<const CXXMethodDecl *, const CXXMethodDecl *>
355
356private:
357
358 /// Contains the index (relative to the vtable address point)
359 /// where the function pointer for a virtual function is stored.
360 typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVTableIndicesTy;
361 MethodVTableIndicesTy MethodVTableIndices;
362
363 typedef llvm::DenseMap<const CXXRecordDecl *,
364 std::unique_ptr<const VTableLayout>>
365 VTableLayoutMapTy;
366 VTableLayoutMapTy VTableLayouts;
367
368 typedef std::pair<const CXXRecordDecl *,
369 const CXXRecordDecl *> ClassPairTy;
370
371 /// vtable offsets for offsets of virtual bases of a class.
372 ///
373 /// Contains the vtable offset (relative to the address point) in chars
374 /// where the offsets for virtual bases of a class are stored.
375 typedef llvm::DenseMap<ClassPairTy, CharUnits>
376 VirtualBaseClassOffsetOffsetsMapTy;
377 VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets;
378
379 /// Map from a virtual method to the nearest method in the primary base class
380 /// chain that it overrides.
381 OriginalMethodMapTy OriginalMethodMap;
382
383 void computeVTableRelatedInformation(const CXXRecordDecl *RD) override;
384
385public:
387 /// Components in the vtable are pointers to other structs/functions.
389
390 /// Components in the vtable are relative offsets between the vtable and the
391 /// other structs/functions.
393 };
394
396 VTableComponentLayout ComponentLayout = Pointer);
397 ~ItaniumVTableContext() override;
398
400 computeVTableRelatedInformation(RD);
401 assert(VTableLayouts.count(RD) && "No layout for this record decl!");
402
403 return *VTableLayouts[RD];
404 }
405
406 std::unique_ptr<VTableLayout> createConstructionVTableLayout(
407 const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
408 bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass);
409
410 /// Locate a virtual function in the vtable.
411 ///
412 /// Return the index (relative to the vtable address point) where the
413 /// function pointer for the given virtual function is stored.
414 uint64_t getMethodVTableIndex(GlobalDecl GD);
415
416 /// Return the offset in chars (relative to the vtable address point) where
417 /// the offset of the virtual base that contains the given base is stored,
418 /// otherwise, if no virtual base contains the given class, return 0.
419 ///
420 /// Base must be a virtual base class or an unambiguous base.
422 const CXXRecordDecl *VBase);
423
424 /// Return the method that added the v-table slot that will be used to call
425 /// the given method.
426 ///
427 /// In the Itanium ABI, where overrides always cause methods to be added to
428 /// the primary v-table if they're not already there, this will be the first
429 /// declaration in the primary base class chain for which the return type
430 /// adjustment is trivial.
432
434
435 void setOriginalMethod(const CXXMethodDecl *Key, const CXXMethodDecl *Val) {
436 OriginalMethodMap[Key] = Val;
437 }
438
439 /// This method is reserved for the implementation and shouldn't be used
440 /// directly.
442 return OriginalMethodMap;
443 }
444
445 static bool classof(const VTableContextBase *VT) {
446 return !VT->isMicrosoft();
447 }
448
450 return ComponentLayout;
451 }
452
453 bool isPointerLayout() const { return ComponentLayout == Pointer; }
454 bool isRelativeLayout() const { return ComponentLayout == Relative; }
455
456private:
457 VTableComponentLayout ComponentLayout;
458};
459
460/// Holds information about the inheritance path to a virtual base or function
461/// table pointer. A record may contain as many vfptrs or vbptrs as there are
462/// base subobjects.
463struct VPtrInfo {
465
468
469 /// This is the most derived class that has this vptr at offset zero. When
470 /// single inheritance is used, this is always the most derived class. If
471 /// multiple inheritance is used, it may be any direct or indirect base.
473
474 /// This is the class that introduced the vptr by declaring new virtual
475 /// methods or virtual bases.
477
478 /// IntroducingObject is at this offset from its containing complete object or
479 /// virtual base.
481
482 /// The bases from the inheritance path that got used to mangle the vbtable
483 /// name. This is not really a full path like a CXXBasePath. It holds the
484 /// subset of records that need to be mangled into the vbtable symbol name in
485 /// order to get a unique name.
487
488 /// The next base to push onto the mangled path if this path is ambiguous in a
489 /// derived class. If it's null, then it's already been pushed onto the path.
491
492 /// The set of possibly indirect vbases that contain this vbtable. When a
493 /// derived class indirectly inherits from the same vbase twice, we only keep
494 /// vtables and their paths from the first instance.
496
497 /// This holds the base classes path from the complete type to the first base
498 /// with the given vfptr offset, in the base-to-derived order. Only used for
499 /// vftables.
501
502 /// Static offset from the top of the most derived class to this vfptr,
503 /// including any virtual base offset. Only used for vftables.
505
506 /// The vptr is stored inside the non-virtual component of this virtual base.
508 return ContainingVBases.empty() ? nullptr : ContainingVBases.front();
509 }
510};
511
513
514/// All virtual base related information about a given record decl. Includes
515/// information on all virtual base tables and the path components that are used
516/// to mangle them.
518 /// A map from virtual base to vbtable index for doing a conversion from the
519 /// the derived class to the a base.
520 llvm::DenseMap<const CXXRecordDecl *, unsigned> VBTableIndices;
521
522 /// Information on all virtual base tables used when this record is the most
523 /// derived class.
525};
526
528 /// If nonzero, holds the vbtable index of the virtual base with the vfptr.
529 uint64_t VBTableIndex;
530
531 /// If nonnull, holds the last vbase which contains the vfptr that the
532 /// method definition is adjusted to.
534
535 /// This is the offset of the vfptr from the start of the last vbase, or the
536 /// complete type if there are no virtual bases.
538
539 /// Method's index in the vftable.
540 uint64_t Index;
541
545
550
551 bool operator<(const MethodVFTableLocation &other) const {
552 if (VBTableIndex != other.VBTableIndex) {
553 assert(VBase != other.VBase);
554 return VBTableIndex < other.VBTableIndex;
555 }
556 return std::tie(VFPtrOffset, Index) <
557 std::tie(other.VFPtrOffset, other.Index);
558 }
559};
560
562public:
563
564private:
565 ASTContext &Context;
566
567 typedef llvm::DenseMap<GlobalDecl, MethodVFTableLocation>
568 MethodVFTableLocationsTy;
569 MethodVFTableLocationsTy MethodVFTableLocations;
570
571 typedef llvm::DenseMap<const CXXRecordDecl *, std::unique_ptr<VPtrInfoVector>>
572 VFPtrLocationsMapTy;
573 VFPtrLocationsMapTy VFPtrLocations;
574
575 typedef std::pair<const CXXRecordDecl *, CharUnits> VFTableIdTy;
576 typedef llvm::DenseMap<VFTableIdTy, std::unique_ptr<const VTableLayout>>
577 VFTableLayoutMapTy;
578 VFTableLayoutMapTy VFTableLayouts;
579
580 llvm::DenseMap<const CXXRecordDecl *, std::unique_ptr<VirtualBaseInfo>>
581 VBaseInfo;
582
583 void computeVTableRelatedInformation(const CXXRecordDecl *RD) override;
584
585 void dumpMethodLocations(const CXXRecordDecl *RD,
586 const MethodVFTableLocationsTy &NewMethods,
587 raw_ostream &);
588
589 const VirtualBaseInfo &
590 computeVBTableRelatedInformation(const CXXRecordDecl *RD);
591
592 void computeVTablePaths(bool ForVBTables, const CXXRecordDecl *RD,
593 VPtrInfoVector &Paths);
594
595public:
597 : VTableContextBase(/*MS=*/true), Context(Context) {}
598
599 ~MicrosoftVTableContext() override;
600
602
604 CharUnits VFPtrOffset);
605
607
609 // Complete destructors don't have a slot in a vftable, so no thunks needed.
612 return nullptr;
614 }
615
616 /// Returns the index of VBase in the vbtable of Derived.
617 /// VBase must be a morally virtual base of Derived.
618 /// The vbtable is an array of i32 offsets. The first entry is a self entry,
619 /// and the rest are offsets from the vbptr to virtual bases.
620 unsigned getVBTableIndex(const CXXRecordDecl *Derived,
621 const CXXRecordDecl *VBase);
622
624
625 static bool classof(const VTableContextBase *VT) { return VT->isMicrosoft(); }
626};
627
628} // namespace clang
629
630#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:220
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition DeclCXX.h:2255
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:978
GlobalDecl - represents a global declaration.
Definition GlobalDecl.h:57
CXXDtorType getDtorType() const
Definition GlobalDecl.h:113
const Decl * getDecl() const
Definition GlobalDecl.h:106
@ Relative
Components in the vtable are relative offsets between the vtable and the other structs/functions.
@ Pointer
Components in the vtable are pointers to other structs/functions.
const CXXMethodDecl * findOriginalMethodInMap(const CXXMethodDecl *MD) const
const OriginalMethodMapTy & getOriginalMethodMap()
This method is reserved for the implementation and shouldn't be used directly.
VTableComponentLayout getVTableComponentLayout() const
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...
ItaniumVTableContext(ASTContext &Context, VTableComponentLayout ComponentLayout=Pointer)
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)
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...