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>
74 uint64_t *FieldOffsets;
80 struct CXXRecordLayoutInfo {
100 bool HasOwnVFPtr : 1;
105 bool HasExtendableVFPtr : 1;
110 bool HasZeroSizedSubObject : 1;
114 bool LeadsWithZeroSizedBase : 1;
117 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
123 typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> BaseOffsetsMapTy;
126 BaseOffsetsMapTy BaseOffsets;
134 CXXRecordLayoutInfo *CXXInfo;
140 CharUnits datasize,
const uint64_t *fieldoffsets,
141 unsigned fieldcount);
144 typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
151 const uint64_t *fieldoffsets,
unsigned fieldcount,
155 bool IsPrimaryBaseVirtual,
157 bool HasZeroSizedSubObject,
158 bool LeadsWithZeroSizedBase,
159 const BaseOffsetsMapTy& BaseOffsets,
182 assert (FieldNo < FieldCount &&
"Invalid Field No");
183 return FieldOffsets[FieldNo];
195 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
197 return CXXInfo->NonVirtualSize;
203 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
205 return CXXInfo->NonVirtualAlignment;
210 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
212 return CXXInfo->PrimaryBase.getPointer();
218 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
220 return CXXInfo->PrimaryBase.getInt();
225 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
226 assert(CXXInfo->BaseOffsets.count(Base) &&
"Did not find base!");
228 return CXXInfo->BaseOffsets[Base];
233 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
234 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
236 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
240 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
241 return CXXInfo->SizeOfLargestEmptySubobject;
252 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
253 return CXXInfo->HasOwnVFPtr;
260 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
261 return CXXInfo->HasExtendableVFPtr;
272 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
273 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
278 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
279 return !CXXInfo->VBPtrOffset.isNegative();
283 return RequiredAlignment;
287 return CXXInfo && CXXInfo->HasZeroSizedSubObject;
291 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
292 return CXXInfo->LeadsWithZeroSizedBase;
298 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
299 return CXXInfo->VBPtrOffset;
303 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
304 return CXXInfo->BaseSharingVBPtr;
308 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
309 return CXXInfo->VBaseOffsets;
llvm::DenseMap< const CXXRecordDecl *, VBaseInfo > VBaseOffsetsMapTy
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
bool hasZeroSizedSubObject() const
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
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getRequiredAlignment() const
bool hasVBPtr() const
hasVBPtr - Does this class have a virtual function table pointer.
uint64_t getFieldOffset(unsigned FieldNo) const
bool leadsWithZeroSizedBase() const
CharUnits getNonVirtualAlignment() const
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
const CXXRecordDecl * getBaseSharingVBPtr() const
CharUnits getVBPtrOffset() const
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
const VBaseOffsetsMapTy & getVBaseOffsetsMap() const
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits getNonVirtualSize() 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 getDataSize() const