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" 49 bool HasVtorDisp =
false;
54 : VBaseOffset(VBaseOffset), HasVtorDisp(hasVtorDisp) {}
85 struct CXXRecordLayoutInfo {
105 bool HasOwnVFPtr : 1;
110 bool HasExtendableVFPtr : 1;
115 bool EndsWithZeroSizedObject : 1;
119 bool LeadsWithZeroSizedBase : 1;
122 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
128 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
131 BaseOffsetsMapTy BaseOffsets;
139 CXXRecordLayoutInfo *CXXInfo =
nullptr;
146 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
160 bool IsPrimaryBaseVirtual,
162 bool EndsWithZeroSizedObject,
163 bool LeadsWithZeroSizedBase,
164 const BaseOffsetsMapTy& BaseOffsets,
191 return FieldOffsets[FieldNo];
203 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
205 return CXXInfo->NonVirtualSize;
211 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
213 return CXXInfo->NonVirtualAlignment;
218 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
220 return CXXInfo->PrimaryBase.getPointer();
226 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
228 return CXXInfo->PrimaryBase.getInt();
233 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
234 assert(CXXInfo->BaseOffsets.count(Base) &&
"Did not find base!");
236 return CXXInfo->BaseOffsets[Base];
241 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
242 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
244 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
248 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
249 return CXXInfo->SizeOfLargestEmptySubobject;
260 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
261 return CXXInfo->HasOwnVFPtr;
268 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
269 return CXXInfo->HasExtendableVFPtr;
280 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
281 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
286 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
287 return !CXXInfo->VBPtrOffset.isNegative();
291 return RequiredAlignment;
295 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
299 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
300 return CXXInfo->LeadsWithZeroSizedBase;
306 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
307 return CXXInfo->VBPtrOffset;
311 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
312 return CXXInfo->BaseSharingVBPtr;
316 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
317 return CXXInfo->VBaseOffsets;
323 #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