14 #ifndef LLVM_CLANG_AST_RECORDLAYOUT_H
15 #define LLVM_CLANG_AST_RECORDLAYOUT_H
19 #include "llvm/ADT/DenseMap.h"
53 VBaseOffset(VBaseOffset), HasVtorDisp(hasVtorDisp) {}
56 typedef llvm::DenseMap<const CXXRecordDecl *, VBaseInfo>
77 struct CXXRecordLayoutInfo {
102 bool HasExtendableVFPtr : 1;
107 bool EndsWithZeroSizedObject : 1;
111 bool LeadsWithZeroSizedBase : 1;
114 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
120 typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> BaseOffsetsMapTy;
123 BaseOffsetsMapTy BaseOffsets;
131 CXXRecordLayoutInfo *CXXInfo;
140 typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
151 bool IsPrimaryBaseVirtual,
153 bool EndsWithZeroSizedObject,
154 bool LeadsWithZeroSizedBase,
155 const BaseOffsetsMapTy& BaseOffsets,
178 return FieldOffsets[FieldNo];
190 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
192 return CXXInfo->NonVirtualSize;
198 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
200 return CXXInfo->NonVirtualAlignment;
205 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
207 return CXXInfo->PrimaryBase.getPointer();
213 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
215 return CXXInfo->PrimaryBase.getInt();
220 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
221 assert(CXXInfo->BaseOffsets.count(Base) &&
"Did not find base!");
223 return CXXInfo->BaseOffsets[Base];
228 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
229 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
231 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
235 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
236 return CXXInfo->SizeOfLargestEmptySubobject;
247 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
248 return CXXInfo->HasOwnVFPtr;
255 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
256 return CXXInfo->HasExtendableVFPtr;
267 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
268 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
273 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
274 return !CXXInfo->VBPtrOffset.isNegative();
278 return RequiredAlignment;
282 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
286 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
287 return CXXInfo->LeadsWithZeroSizedBase;
293 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
294 return CXXInfo->VBPtrOffset;
298 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
299 return CXXInfo->BaseSharingVBPtr;
303 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
304 return CXXInfo->VBaseOffsets;
llvm::DenseMap< const CXXRecordDecl *, VBaseInfo > VBaseOffsetsMapTy
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not...
bool endsWithZeroSizedObject() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits getRequiredAlignment() const
bool hasVBPtr() const
hasVBPtr - Does this class have a virtual function table pointer.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool leadsWithZeroSizedBase() const
CharUnits getNonVirtualAlignment() const
getNonVirtualSize - Get the non-virtual alignment (in chars) of an object, which is the alignment of ...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
const CXXRecordDecl * getBaseSharingVBPtr() const
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getSizeOfLargestEmptySubobject() const
CharUnits getSize() const
getSize - Get the record size in characters.
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...
const VBaseOffsetsMapTy & getVBaseOffsetsMap() const
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding, in characters.
CharUnits VBaseOffset
The offset to this virtual base in the complete-object layout of this class.
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...