@@ -95,7 +95,7 @@ struct CGRecordLowering {
95
95
CGRecordLowering (CodeGenTypes &Types, const RecordDecl *D, bool Packed);
96
96
// Short helper routines.
97
97
// / Constructs a MemberInfo instance from an offset and llvm::Type *.
98
- MemberInfo StorageInfo (CharUnits Offset, llvm::Type *Data) {
98
+ static MemberInfo StorageInfo (CharUnits Offset, llvm::Type *Data) {
99
99
return MemberInfo (Offset, MemberInfo::Field, Data);
100
100
}
101
101
@@ -104,7 +104,7 @@ struct CGRecordLowering {
104
104
// / fields of the same formal type. We want to emit a layout with
105
105
// / these discrete storage units instead of combining them into a
106
106
// / continuous run.
107
- bool isDiscreteBitFieldABI () {
107
+ bool isDiscreteBitFieldABI () const {
108
108
return Context.getTargetInfo ().getCXXABI ().isMicrosoft () ||
109
109
D->isMsStruct (Context);
110
110
}
@@ -121,60 +121,60 @@ struct CGRecordLowering {
121
121
// / other bases, which complicates layout in specific ways.
122
122
// /
123
123
// / Note specifically that the ms_struct attribute doesn't change this.
124
- bool isOverlappingVBaseABI () {
124
+ bool isOverlappingVBaseABI () const {
125
125
return !Context.getTargetInfo ().getCXXABI ().isMicrosoft ();
126
126
}
127
127
128
128
// / Wraps llvm::Type::getIntNTy with some implicit arguments.
129
- llvm::Type *getIntNType (uint64_t NumBits) {
129
+ llvm::Type *getIntNType (uint64_t NumBits) const {
130
130
unsigned AlignedBits = llvm::alignTo (NumBits, Context.getCharWidth ());
131
131
return llvm::Type::getIntNTy (Types.getLLVMContext (), AlignedBits);
132
132
}
133
133
// / Get the LLVM type sized as one character unit.
134
- llvm::Type *getCharType () {
134
+ llvm::Type *getCharType () const {
135
135
return llvm::Type::getIntNTy (Types.getLLVMContext (),
136
136
Context.getCharWidth ());
137
137
}
138
138
// / Gets an llvm type of size NumChars and alignment 1.
139
- llvm::Type *getByteArrayType (CharUnits NumChars) {
139
+ llvm::Type *getByteArrayType (CharUnits NumChars) const {
140
140
assert (!NumChars.isZero () && " Empty byte arrays aren't allowed." );
141
141
llvm::Type *Type = getCharType ();
142
142
return NumChars == CharUnits::One () ? Type :
143
143
(llvm::Type *)llvm::ArrayType::get (Type, NumChars.getQuantity ());
144
144
}
145
145
// / Gets the storage type for a field decl and handles storage
146
146
// / for itanium bitfields that are smaller than their declared type.
147
- llvm::Type *getStorageType (const FieldDecl *FD) {
147
+ llvm::Type *getStorageType (const FieldDecl *FD) const {
148
148
llvm::Type *Type = Types.ConvertTypeForMem (FD->getType ());
149
149
if (!FD->isBitField ()) return Type;
150
150
if (isDiscreteBitFieldABI ()) return Type;
151
151
return getIntNType (std::min (FD->getBitWidthValue (Context),
152
152
(unsigned )Context.toBits (getSize (Type))));
153
153
}
154
154
// / Gets the llvm Basesubobject type from a CXXRecordDecl.
155
- llvm::Type *getStorageType (const CXXRecordDecl *RD) {
155
+ llvm::Type *getStorageType (const CXXRecordDecl *RD) const {
156
156
return Types.getCGRecordLayout (RD).getBaseSubobjectLLVMType ();
157
157
}
158
- CharUnits bitsToCharUnits (uint64_t BitOffset) {
158
+ CharUnits bitsToCharUnits (uint64_t BitOffset) const {
159
159
return Context.toCharUnitsFromBits (BitOffset);
160
160
}
161
- CharUnits getSize (llvm::Type *Type) {
161
+ CharUnits getSize (llvm::Type *Type) const {
162
162
return CharUnits::fromQuantity (DataLayout.getTypeAllocSize (Type));
163
163
}
164
- CharUnits getAlignment (llvm::Type *Type) {
164
+ CharUnits getAlignment (llvm::Type *Type) const {
165
165
return CharUnits::fromQuantity (DataLayout.getABITypeAlign (Type));
166
166
}
167
- bool isZeroInitializable (const FieldDecl *FD) {
167
+ bool isZeroInitializable (const FieldDecl *FD) const {
168
168
return Types.isZeroInitializable (FD->getType ());
169
169
}
170
- bool isZeroInitializable (const RecordDecl *RD) {
170
+ bool isZeroInitializable (const RecordDecl *RD) const {
171
171
return Types.isZeroInitializable (RD);
172
172
}
173
173
void appendPaddingBytes (CharUnits Size) {
174
174
if (!Size.isZero ())
175
175
FieldTypes.push_back (getByteArrayType (Size));
176
176
}
177
- uint64_t getFieldBitOffset (const FieldDecl *FD) {
177
+ uint64_t getFieldBitOffset (const FieldDecl *FD) const {
178
178
return Layout.getFieldOffset (FD->getFieldIndex ());
179
179
}
180
180
// Layout routines.
0 commit comments