10 #ifndef LLVM_CLANG_LIB_CODEGEN_CGRECORDLAYOUT_H
11 #define LLVM_CLANG_LIB_CODEGEN_CGRECORDLAYOUT_H
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/IR/DerivedTypes.h"
89 : Offset(Offset), Size(Size), IsSigned(IsSigned),
90 StorageSize(StorageSize), StorageOffset(StorageOffset) {}
92 void print(raw_ostream &OS)
const;
118 llvm::StructType *CompleteObjectType;
122 llvm::StructType *BaseSubobjectType;
126 llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
130 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo> BitFields;
134 llvm::DenseMap<const CXXRecordDecl *, unsigned> NonVirtualBases;
137 llvm::DenseMap<const CXXRecordDecl *, unsigned> CompleteObjectVirtualBases;
142 bool IsZeroInitializable : 1;
147 bool IsZeroInitializableAsBase : 1;
151 llvm::StructType *BaseSubobjectType,
152 bool IsZeroInitializable,
153 bool IsZeroInitializableAsBase)
154 : CompleteObjectType(CompleteObjectType),
155 BaseSubobjectType(BaseSubobjectType),
156 IsZeroInitializable(IsZeroInitializable),
157 IsZeroInitializableAsBase(IsZeroInitializableAsBase) {}
162 return CompleteObjectType;
168 return BaseSubobjectType;
174 return IsZeroInitializable;
180 return IsZeroInitializableAsBase;
187 assert(FieldInfo.count(FD) &&
"Invalid field for record!");
188 return FieldInfo.lookup(FD);
192 assert(NonVirtualBases.count(RD) &&
"Invalid non-virtual base!");
193 return NonVirtualBases.lookup(RD);
199 assert(CompleteObjectVirtualBases.count(base) &&
"Invalid virtual base!");
200 return CompleteObjectVirtualBases.lookup(base);
206 assert(FD->
isBitField() &&
"Invalid call for non-bit-field decl!");
207 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo>::const_iterator
208 it = BitFields.find(FD);
209 assert(it != BitFields.end() &&
"Unable to find bitfield info");
213 void print(raw_ostream &OS)
const;
bool isBitField() const
Determines whether this field is a bitfield.
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
CGBitFieldInfo(unsigned Offset, unsigned Size, bool IsSigned, unsigned StorageSize, CharUnits StorageOffset)
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.
llvm::StructType * getLLVMType() const
Return the "complete object" LLVM type associated with this record.
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
unsigned getVirtualBaseIndex(const CXXRecordDecl *base) const
Return the LLVM field index corresponding to the given virtual base.
unsigned Size
The total size of the bit-field, in bits.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZeroInitializableAsBase() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer when considered as a bas...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
static CGBitFieldInfo MakeInfo(class CodeGenTypes &Types, const FieldDecl *FD, uint64_t Offset, uint64_t Size, uint64_t StorageSize, CharUnits StorageOffset)
Given a bit-field decl, build an appropriate helper object for accessing that field (which is expecte...
CGRecordLayout(llvm::StructType *CompleteObjectType, llvm::StructType *BaseSubobjectType, bool IsZeroInitializable, bool IsZeroInitializableAsBase)
void print(raw_ostream &OS) const
void print(raw_ostream &OS) const
unsigned getNonVirtualBaseLLVMFieldNo(const CXXRecordDecl *RD) const
unsigned IsSigned
Whether the bit-field is signed.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
bool isZeroInitializable() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
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.
llvm::StructType * getBaseSubobjectLLVMType() const
Return the "base subobject" LLVM type associated with this record.
Structure with information about how a bitfield should be accessed.