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) {}
82 struct CXXRecordLayoutInfo {
102 bool HasOwnVFPtr : 1;
107 bool HasExtendableVFPtr : 1;
112 bool EndsWithZeroSizedObject : 1;
116 bool LeadsWithZeroSizedBase : 1;
119 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
125 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
128 BaseOffsetsMapTy BaseOffsets;
136 CXXRecordLayoutInfo *CXXInfo =
nullptr;
142 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
155 bool IsPrimaryBaseVirtual,
157 bool EndsWithZeroSizedObject,
158 bool LeadsWithZeroSizedBase,
159 const BaseOffsetsMapTy& BaseOffsets,
182 return FieldOffsets[FieldNo];
194 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
196 return CXXInfo->NonVirtualSize;
202 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
204 return CXXInfo->NonVirtualAlignment;
209 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
211 return CXXInfo->PrimaryBase.getPointer();
217 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
219 return CXXInfo->PrimaryBase.getInt();
224 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
225 assert(CXXInfo->BaseOffsets.count(Base) &&
"Did not find base!");
227 return CXXInfo->BaseOffsets[Base];
232 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
233 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
235 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
239 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
240 return CXXInfo->SizeOfLargestEmptySubobject;
251 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
252 return CXXInfo->HasOwnVFPtr;
259 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
260 return CXXInfo->HasExtendableVFPtr;
271 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
272 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
277 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
278 return !CXXInfo->VBPtrOffset.isNegative();
282 return RequiredAlignment;
286 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
290 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
291 return CXXInfo->LeadsWithZeroSizedBase;
297 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
298 return CXXInfo->VBPtrOffset;
302 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
303 return CXXInfo->BaseSharingVBPtr;
307 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
308 return CXXInfo->VBaseOffsets;
314 #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 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