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;
91 struct CXXRecordLayoutInfo {
122 bool HasOwnVFPtr : 1;
127 bool HasExtendableVFPtr : 1;
132 bool EndsWithZeroSizedObject : 1;
136 bool LeadsWithZeroSizedBase : 1;
139 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
145 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
148 BaseOffsetsMapTy BaseOffsets;
156 CXXRecordLayoutInfo *CXXInfo =
nullptr;
163 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
177 bool EndsWithZeroSizedObject,
bool LeadsWithZeroSizedBase,
178 const BaseOffsetsMapTy &BaseOffsets,
187 ASTRecordLayout &
operator=(
const ASTRecordLayout &) =
delete;
209 return FieldOffsets[FieldNo];
219 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
221 return CXXInfo->NonVirtualSize;
227 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
229 return CXXInfo->NonVirtualAlignment;
236 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
238 return CXXInfo->NonRequiredNVAlignment;
245 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
247 return CXXInfo->PreferredNVAlignment;
252 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
254 return CXXInfo->PrimaryBase.getPointer();
260 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
262 return CXXInfo->PrimaryBase.getInt();
267 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
270 assert(CXXInfo->BaseOffsets.count(
Base) &&
"Did not find base!");
272 return CXXInfo->BaseOffsets[
Base];
277 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
280 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
282 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
286 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
287 return CXXInfo->SizeOfLargestEmptySubobject;
298 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
299 return CXXInfo->HasOwnVFPtr;
306 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
307 return CXXInfo->HasExtendableVFPtr;
318 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
319 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
324 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
325 return !CXXInfo->VBPtrOffset.isNegative();
331 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
335 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
336 return CXXInfo->LeadsWithZeroSizedBase;
342 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
343 return CXXInfo->VBPtrOffset;
347 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
348 return CXXInfo->BaseSharingVBPtr;
352 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
353 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 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
CharUnits - This is an opaque type for sizes expressed in character units.
Top level wrappers for InstallAPI frontend operations.
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits VBaseOffset
The offset to this virtual base in the complete-object layout of this class.