13#ifndef LLVM_CLANG_AST_RECORDLAYOUT_H
14#define LLVM_CLANG_AST_RECORDLAYOUT_H
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/PointerIntPair.h"
38class ASTRecordLayout {
49 bool HasVtorDisp =
false;
95 struct CXXRecordLayoutInfo {
126 bool HasOwnVFPtr : 1;
131 bool HasExtendableVFPtr : 1;
136 bool EndsWithZeroSizedObject : 1;
140 bool LeadsWithZeroSizedBase : 1;
143 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
149 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
152 BaseOffsetsMapTy BaseOffsets;
160 CXXRecordLayoutInfo *CXXInfo =
nullptr;
168 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
183 bool EndsWithZeroSizedObject,
bool LeadsWithZeroSizedBase,
184 const BaseOffsetsMapTy &BaseOffsets,
193 ASTRecordLayout &
operator=(
const ASTRecordLayout &) =
delete;
215 return FieldOffsets[FieldNo];
225 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
227 return CXXInfo->NonVirtualSize;
233 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
235 return CXXInfo->NonVirtualAlignment;
242 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
244 return CXXInfo->NonRequiredNVAlignment;
251 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
253 return CXXInfo->PreferredNVAlignment;
258 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
260 return CXXInfo->PrimaryBase.getPointer();
266 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
268 return CXXInfo->PrimaryBase.getInt();
273 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
276 assert(CXXInfo->BaseOffsets.count(
Base) &&
"Did not find base!");
278 return CXXInfo->BaseOffsets[
Base];
283 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
286 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
288 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
292 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
293 return CXXInfo->SizeOfLargestEmptySubobject;
304 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
305 return CXXInfo->HasOwnVFPtr;
312 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
313 return CXXInfo->HasExtendableVFPtr;
324 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
325 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
330 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
331 return !CXXInfo->VBPtrOffset.isNegative();
338 return PragmaPackResistantAlignment;
342 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
346 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
347 return CXXInfo->LeadsWithZeroSizedBase;
353 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
354 return CXXInfo->VBPtrOffset;
358 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
359 return CXXInfo->BaseSharingVBPtr;
363 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
364 return CXXInfo->VBaseOffsets;
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool endsWithZeroSizedObject() const
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
CharUnits getPreferredAlignment() const
getPreferredFieldAlignment - Get the record preferred alignment in characters.
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
llvm::DenseMap< const CXXRecordDecl *, VBaseInfo > VBaseOffsetsMapTy
ASTRecordLayout & operator=(const ASTRecordLayout &)=delete
CharUnits getNonRequiredNVAlignment() const
getNonRequiredNVAlignment - Get the non-virtual alignment (in chars) of an object ignoring over-align...
CharUnits getSize() const
getSize - Get the record size in characters.
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
bool hasVBPtr() const
hasVBPtr - Does this class have a virtual function table pointer.
bool leadsWithZeroSizedBase() const
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getNonVirtualAlignment() const
getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an object, which is the alignmen...
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
ASTRecordLayout(const ASTRecordLayout &)=delete
CharUnits getRequiredAlignment() const
CharUnits getSizeOfLargestEmptySubobject() const
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getPreferredNVAlignment() const
getPreferredNVAlignment - Get the preferred non-virtual alignment (in chars) of an object,...
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
const VBaseOffsetsMapTy & getVBaseOffsetsMap() const
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
bool hasExtendableVFPtr() const
hasVFPtr - Does this class have a virtual function table pointer that can be extended by a derived cl...
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not.
CharUnits getPragmaPackResistantAlignment() const
Get the natural alignment of pragma-pack-resistant fields.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a C++ struct/union/class.
CXXRecordDecl * getDefinition() const
This is an opaque type for sizes expressed in character units.
Top level wrappers for InstallAPI frontend operations.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits VBaseOffset
The offset to this virtual base in the complete-object layout of this class.