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;
91 struct CXXRecordLayoutInfo {
116 bool HasOwnVFPtr : 1;
121 bool HasExtendableVFPtr : 1;
126 bool EndsWithZeroSizedObject : 1;
130 bool LeadsWithZeroSizedBase : 1;
133 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
139 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
142 BaseOffsetsMapTy BaseOffsets;
150 CXXRecordLayoutInfo *CXXInfo =
nullptr;
157 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
170 bool EndsWithZeroSizedObject,
bool LeadsWithZeroSizedBase,
171 const BaseOffsetsMapTy &BaseOffsets,
202 return FieldOffsets[FieldNo];
212 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
214 return CXXInfo->NonVirtualSize;
220 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
222 return CXXInfo->NonVirtualAlignment;
229 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
231 return CXXInfo->PreferredNVAlignment;
236 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
238 return CXXInfo->PrimaryBase.getPointer();
244 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
246 return CXXInfo->PrimaryBase.getInt();
251 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
254 assert(CXXInfo->BaseOffsets.count(
Base) &&
"Did not find base!");
256 return CXXInfo->BaseOffsets[
Base];
261 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
264 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
266 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
270 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
271 return CXXInfo->SizeOfLargestEmptySubobject;
282 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
283 return CXXInfo->HasOwnVFPtr;
290 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
291 return CXXInfo->HasExtendableVFPtr;
302 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
303 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
308 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
309 return !CXXInfo->VBPtrOffset.isNegative();
315 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
319 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
320 return CXXInfo->LeadsWithZeroSizedBase;
326 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
327 return CXXInfo->VBPtrOffset;
331 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
332 return CXXInfo->BaseSharingVBPtr;
336 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
337 return CXXInfo->VBaseOffsets;
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool endsWithZeroSizedObject() const
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
CharUnits getPreferredAlignment() const
getPreferredFieldAlignment - Get the record preferred alignment in characters.
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
llvm::DenseMap< const CXXRecordDecl *, VBaseInfo > VBaseOffsetsMapTy
ASTRecordLayout & operator=(const ASTRecordLayout &)=delete
CharUnits getSize() const
getSize - Get the record size in characters.
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
bool hasVBPtr() const
hasVBPtr - Does this class have a virtual function table pointer.
bool leadsWithZeroSizedBase() const
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getNonVirtualAlignment() const
getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an object, which is the alignmen...
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
ASTRecordLayout(const ASTRecordLayout &)=delete
CharUnits getRequiredAlignment() const
CharUnits getSizeOfLargestEmptySubobject() const
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getPreferredNVAlignment() const
getPreferredNVAlignment - Get the preferred non-virtual alignment (in chars) of an object,...
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
const VBaseOffsetsMapTy & getVBaseOffsetsMap() const
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...
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a C++ struct/union/class.
CXXRecordDecl * getDefinition() const
CharUnits - This is an opaque type for sizes expressed in character units.
The JSON file list parser is used to communicate input to InstallAPI.
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
CharUnits VBaseOffset
The offset to this virtual base in the complete-object layout of this class.