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" 84 :
Offset(), Size(), IsSigned(), StorageSize(), StorageOffset() {}
87 unsigned StorageSize,
CharUnits StorageOffset)
88 : Offset(Offset), Size(Size), IsSigned(IsSigned),
89 StorageSize(StorageSize), StorageOffset(StorageOffset) {}
91 void print(raw_ostream &OS)
const;
99 uint64_t
Offset, uint64_t Size,
100 uint64_t StorageSize,
117 llvm::StructType *CompleteObjectType;
121 llvm::StructType *BaseSubobjectType;
125 llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
129 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo> BitFields;
133 llvm::DenseMap<const CXXRecordDecl *, unsigned> NonVirtualBases;
136 llvm::DenseMap<const CXXRecordDecl *, unsigned> CompleteObjectVirtualBases;
141 bool IsZeroInitializable : 1;
146 bool IsZeroInitializableAsBase : 1;
150 llvm::StructType *BaseSubobjectType,
151 bool IsZeroInitializable,
152 bool IsZeroInitializableAsBase)
153 : CompleteObjectType(CompleteObjectType),
154 BaseSubobjectType(BaseSubobjectType),
155 IsZeroInitializable(IsZeroInitializable),
156 IsZeroInitializableAsBase(IsZeroInitializableAsBase) {}
161 return CompleteObjectType;
167 return BaseSubobjectType;
173 return IsZeroInitializable;
179 return IsZeroInitializableAsBase;
186 assert(FieldInfo.count(FD) &&
"Invalid field for record!");
187 return FieldInfo.lookup(FD);
191 assert(NonVirtualBases.count(RD) &&
"Invalid non-virtual base!");
192 return NonVirtualBases.lookup(RD);
198 assert(CompleteObjectVirtualBases.count(base) &&
"Invalid virtual base!");
199 return CompleteObjectVirtualBases.lookup(base);
205 assert(FD->
isBitField() &&
"Invalid call for non-bit-field decl!");
206 llvm::DenseMap<const FieldDecl *, CGBitFieldInfo>::const_iterator
207 it = BitFields.find(FD);
208 assert(it != BitFields.end() &&
"Unable to find bitfield info");
212 void print(raw_ostream &OS)
const;
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
CGBitFieldInfo(unsigned Offset, unsigned Size, bool IsSigned, unsigned StorageSize, CharUnits StorageOffset)
bool isZeroInitializableAsBase() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer when considered as a bas...
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Represents a member of a struct/union/class.
unsigned getNonVirtualBaseLLVMFieldNo(const CXXRecordDecl *RD) const
unsigned Size
The total size of the bit-field, in bits.
bool isBitField() const
Determines whether this field is a bitfield.
CharUnits - This is an opaque type for sizes expressed in character units.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
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.
llvm::StructType * getBaseSubobjectLLVMType() const
Return the "base subobject" LLVM type associated with this record.
unsigned Offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
bool isZeroInitializable() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer.
CGRecordLayout(llvm::StructType *CompleteObjectType, llvm::StructType *BaseSubobjectType, bool IsZeroInitializable, bool IsZeroInitializableAsBase)
Dataflow Directional Tag Classes.
unsigned IsSigned
Whether the bit-field is signed.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
llvm::StructType * getLLVMType() const
Return the "complete object" LLVM type associated with this record.
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.
unsigned getVirtualBaseIndex(const CXXRecordDecl *base) const
Return the LLVM field index corresponding to the given virtual base.
Structure with information about how a bitfield should be accessed.
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.