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"
74 LLVM_PREFERRED_TYPE(
bool)
105 void print(raw_ostream &OS)
const;
131 llvm::StructType *CompleteObjectType;
135 llvm::StructType *BaseSubobjectType;
139 llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
143 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo> BitFields;
147 llvm::DenseMap<const CXXRecordDecl *, unsigned> NonVirtualBases;
150 llvm::DenseMap<const CXXRecordDecl *, unsigned> CompleteObjectVirtualBases;
155 bool IsZeroInitializable : 1;
160 bool IsZeroInitializableAsBase : 1;
164 llvm::StructType *BaseSubobjectType,
165 bool IsZeroInitializable,
166 bool IsZeroInitializableAsBase)
167 : CompleteObjectType(CompleteObjectType),
168 BaseSubobjectType(BaseSubobjectType),
169 IsZeroInitializable(IsZeroInitializable),
170 IsZeroInitializableAsBase(IsZeroInitializableAsBase) {}
175 return CompleteObjectType;
181 return BaseSubobjectType;
187 return IsZeroInitializable;
193 return IsZeroInitializableAsBase;
197 return FieldInfo.count(FD) != 0;
204 assert(FieldInfo.count(FD) &&
"Invalid field for record!");
205 return FieldInfo.lookup(FD);
211 return NonVirtualBases.count(RD);
215 assert(NonVirtualBases.count(RD) &&
"Invalid non-virtual base!");
216 return NonVirtualBases.lookup(RD);
222 assert(CompleteObjectVirtualBases.count(base) &&
"Invalid virtual base!");
223 return CompleteObjectVirtualBases.lookup(base);
229 assert(FD->
isBitField() &&
"Invalid call for non-bit-field decl!");
230 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo>::const_iterator
231 it = BitFields.find(FD);
232 assert(it != BitFields.end() &&
"Unable to find bitfield info");
236 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
bool containsFieldDecl(const FieldDecl *FD) 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.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
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...