14 #ifndef LLVM_CLANG_AST_RECORDLAYOUT_H 15 #define LLVM_CLANG_AST_RECORDLAYOUT_H 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/PointerIntPair.h" 50 bool HasVtorDisp =
false;
55 : VBaseOffset(VBaseOffset), HasVtorDisp(hasVtorDisp) {}
86 struct CXXRecordLayoutInfo {
106 bool HasOwnVFPtr : 1;
111 bool HasExtendableVFPtr : 1;
116 bool EndsWithZeroSizedObject : 1;
120 bool LeadsWithZeroSizedBase : 1;
123 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
129 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
132 BaseOffsetsMapTy BaseOffsets;
140 CXXRecordLayoutInfo *CXXInfo =
nullptr;
147 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
161 bool IsPrimaryBaseVirtual,
163 bool EndsWithZeroSizedObject,
164 bool LeadsWithZeroSizedBase,
165 const BaseOffsetsMapTy& BaseOffsets,
192 return FieldOffsets[FieldNo];
204 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
206 return CXXInfo->NonVirtualSize;
212 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
214 return CXXInfo->NonVirtualAlignment;
219 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
221 return CXXInfo->PrimaryBase.getPointer();
227 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
229 return CXXInfo->PrimaryBase.getInt();
234 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
235 assert(CXXInfo->BaseOffsets.count(Base) &&
"Did not find base!");
237 return CXXInfo->BaseOffsets[Base];
242 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
243 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
245 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
249 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
250 return CXXInfo->SizeOfLargestEmptySubobject;
261 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
262 return CXXInfo->HasOwnVFPtr;
269 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
270 return CXXInfo->HasExtendableVFPtr;
281 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
282 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
287 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
288 return !CXXInfo->VBPtrOffset.isNegative();
292 return RequiredAlignment;
296 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
300 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
301 return CXXInfo->LeadsWithZeroSizedBase;
307 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
308 return CXXInfo->VBPtrOffset;
312 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
313 return CXXInfo->BaseSharingVBPtr;
317 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
318 return CXXInfo->VBaseOffsets;
324 #endif // LLVM_CLANG_AST_RECORDLAYOUT_H bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
bool hasVBPtr() const
hasVBPtr - Does this class have a virtual function table pointer.
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits - This is an opaque type for sizes expressed in character units.
bool endsWithZeroSizedObject() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const VBaseOffsetsMapTy & getVBaseOffsetsMap() const
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getSizeOfLargestEmptySubobject() const
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
bool hasExtendableVFPtr() const
hasVFPtr - Does this class have a virtual function table pointer that can be extended by a derived cl...
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getRequiredAlignment() const
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding, in characters.
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustement...
CharUnits getNonVirtualAlignment() const
getNonVirtualSize - Get the non-virtual alignment (in chars) of an object, which is the alignment of ...
Dataflow Directional Tag Classes.
CharUnits getSize() const
getSize - Get the record size in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
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 getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
llvm::DenseMap< const CXXRecordDecl *, VBaseInfo > VBaseOffsetsMapTy
CharUnits VBaseOffset
The offset to this virtual base in the complete-object layout of this class.
ASTRecordLayout & operator=(const ASTRecordLayout &)=delete
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
bool leadsWithZeroSizedBase() const