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;
90 struct CXXRecordLayoutInfo {
115 bool HasOwnVFPtr : 1;
120 bool HasExtendableVFPtr : 1;
125 bool EndsWithZeroSizedObject : 1;
129 bool LeadsWithZeroSizedBase : 1;
132 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> PrimaryBase;
138 using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
141 BaseOffsetsMapTy BaseOffsets;
149 CXXRecordLayoutInfo *CXXInfo =
nullptr;
156 using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
169 bool EndsWithZeroSizedObject,
bool LeadsWithZeroSizedBase,
170 const BaseOffsetsMapTy &BaseOffsets,
201 return FieldOffsets[FieldNo];
211 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
213 return CXXInfo->NonVirtualSize;
219 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
221 return CXXInfo->NonVirtualAlignment;
228 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
230 return CXXInfo->PreferredNVAlignment;
235 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
237 return CXXInfo->PrimaryBase.getPointer();
243 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
245 return CXXInfo->PrimaryBase.getInt();
250 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
253 assert(CXXInfo->BaseOffsets.count(
Base) &&
"Did not find base!");
255 return CXXInfo->BaseOffsets[
Base];
260 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
263 assert(CXXInfo->VBaseOffsets.count(VBase) &&
"Did not find base!");
265 return CXXInfo->VBaseOffsets[VBase].VBaseOffset;
269 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
270 return CXXInfo->SizeOfLargestEmptySubobject;
281 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
282 return CXXInfo->HasOwnVFPtr;
289 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
290 return CXXInfo->HasExtendableVFPtr;
301 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
302 return hasVBPtr() && !CXXInfo->BaseSharingVBPtr;
307 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
308 return !CXXInfo->VBPtrOffset.isNegative();
314 return CXXInfo && CXXInfo->EndsWithZeroSizedObject;
318 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
319 return CXXInfo->LeadsWithZeroSizedBase;
325 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
326 return CXXInfo->VBPtrOffset;
330 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
331 return CXXInfo->BaseSharingVBPtr;
335 assert(CXXInfo &&
"Record layout does not have C++ specific info!");
336 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 adjustement.
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.