9#ifndef LLVM_CLANG_LIB_CODEGEN_CGRECORDLAYOUT_H
10#define LLVM_CLANG_LIB_CODEGEN_CGRECORDLAYOUT_H
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/IR/DerivedTypes.h"
104 void print(raw_ostream &OS)
const;
130 llvm::StructType *CompleteObjectType;
134 llvm::StructType *BaseSubobjectType;
138 llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
142 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo> BitFields;
146 llvm::DenseMap<const CXXRecordDecl *, unsigned> NonVirtualBases;
149 llvm::DenseMap<const CXXRecordDecl *, unsigned> CompleteObjectVirtualBases;
154 bool IsZeroInitializable : 1;
159 bool IsZeroInitializableAsBase : 1;
163 llvm::StructType *BaseSubobjectType,
164 bool IsZeroInitializable,
165 bool IsZeroInitializableAsBase)
166 : CompleteObjectType(CompleteObjectType),
167 BaseSubobjectType(BaseSubobjectType),
168 IsZeroInitializable(IsZeroInitializable),
169 IsZeroInitializableAsBase(IsZeroInitializableAsBase) {}
174 return CompleteObjectType;
180 return BaseSubobjectType;
186 return IsZeroInitializable;
192 return IsZeroInitializableAsBase;
199 assert(FieldInfo.count(FD) &&
"Invalid field for record!");
200 return FieldInfo.lookup(FD);
206 return NonVirtualBases.count(RD);
210 assert(NonVirtualBases.count(RD) &&
"Invalid non-virtual base!");
211 return NonVirtualBases.lookup(RD);
217 assert(CompleteObjectVirtualBases.count(base) &&
"Invalid virtual base!");
218 return CompleteObjectVirtualBases.lookup(base);
224 assert(FD->
isBitField() &&
"Invalid call for non-bit-field decl!");
225 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo>::const_iterator
226 it = BitFields.find(FD);
227 assert(it != BitFields.end() &&
"Unable to find bitfield info");
231 void print(raw_ostream &OS)
const;
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.
Represents a C++ struct/union/class.
CharUnits - This is an opaque type for sizes expressed in character units.
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
CGRecordLayout(llvm::StructType *CompleteObjectType, llvm::StructType *BaseSubobjectType, bool IsZeroInitializable, bool IsZeroInitializableAsBase)
void print(raw_ostream &OS) const
unsigned getNonVirtualBaseLLVMFieldNo(const CXXRecordDecl *RD) const
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.
bool isZeroInitializableAsBase() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer when considered as a bas...
llvm::StructType * getBaseSubobjectLLVMType() const
Return the "base subobject" LLVM type associated with this record.
bool isZeroInitializable() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer.
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.
bool hasNonVirtualBaseLLVMField(const CXXRecordDecl *RD) const
unsigned getVirtualBaseIndex(const CXXRecordDecl *base) const
Return the LLVM field index corresponding to the given virtual base.
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
YAML serialization mapping.
Structure with information about how a bitfield should be accessed.
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
CharUnits VolatileStorageOffset
The offset of the bitfield storage from the start of the struct.
unsigned VolatileOffset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
unsigned Offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
unsigned VolatileStorageSize
The storage size in bits which should be used when accessing this bitfield.
void print(raw_ostream &OS) const
CGBitFieldInfo(unsigned Offset, unsigned Size, bool IsSigned, unsigned StorageSize, CharUnits StorageOffset)
unsigned Size
The total size of the bit-field, in bits.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
unsigned IsSigned
Whether the bit-field is signed.
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...