Skip to content

Commit 407ecfe

Browse files
authored
[CIR][NFC] Cleanup MissingFeature asserts in RecordLayoutBuilder (#161605)
This change cleans up some cir::MissingFeature asserts in CIRGenRecordLayoutBuilder.cpp. In a couple of cases the asserts were stale markers that we failed to remove when the correspond support was implemented. In one case, a cir::MissingFeature::bitfields() assert was ambiguous in meaning and has been replaced by a comment and something more specific. The missing feature in this case is just a bit of debug code to verify certain bitfield-related conditions. This check should be added, but it is not functionally required.
1 parent 5ed678a commit 407ecfe

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ struct MissingFeatures {
133133
// RecordType
134134
static bool skippedLayout() { return false; }
135135
static bool astRecordDeclAttr() { return false; }
136-
static bool recordZeroInit() { return false; }
137136
static bool recordZeroInitPadding() { return false; }
138137
static bool zeroSizeRecordMembers() { return false; }
139138

@@ -192,6 +191,7 @@ struct MissingFeatures {
192191
static bool builtinCheckKind() { return false; }
193192
static bool cgCapturedStmtInfo() { return false; }
194193
static bool cgFPOptionsRAII() { return false; }
194+
static bool checkBitfieldClipping() { return false; }
195195
static bool cirgenABIInfo() { return false; }
196196
static bool cleanupAfterErrorDiags() { return false; }
197197
static bool cleanupsToDeactivate() { return false; }

clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,8 @@ void CIRRecordLowering::lower(bool nonVirtualBaseType) {
296296
}
297297

298298
llvm::stable_sort(members);
299-
// TODO: implement clipTailPadding once bitfields are implemented
300-
assert(!cir::MissingFeatures::bitfields());
301-
assert(!cir::MissingFeatures::recordZeroInit());
299+
// TODO: Verify bitfield clipping
300+
assert(!cir::MissingFeatures::checkBitfieldClipping());
302301

303302
members.push_back(makeStorageInfo(size, getUIntNType(8)));
304303
determinePacked(nonVirtualBaseType);
@@ -319,9 +318,11 @@ void CIRRecordLowering::fillOutputFields() {
319318
fieldIdxMap[member.fieldDecl->getCanonicalDecl()] =
320319
fieldTypes.size() - 1;
321320
// A field without storage must be a bitfield.
322-
assert(!cir::MissingFeatures::bitfields());
323-
if (!member.data)
321+
if (!member.data) {
322+
assert(member.fieldDecl &&
323+
"member.data is a nullptr so member.fieldDecl should not be");
324324
setBitFieldInfo(member.fieldDecl, member.offset, fieldTypes.back());
325+
}
325326
} else if (member.kind == MemberInfo::InfoKind::Base) {
326327
nonVirtualBases[member.cxxRecordDecl] = fieldTypes.size() - 1;
327328
} else if (member.kind == MemberInfo::InfoKind::VBase) {
@@ -697,13 +698,9 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, cir::RecordType *ty) {
697698
ty ? *ty : cir::RecordType{}, baseTy ? baseTy : cir::RecordType{},
698699
(bool)lowering.zeroInitializable, (bool)lowering.zeroInitializableAsBase);
699700

700-
assert(!cir::MissingFeatures::recordZeroInit());
701-
702701
rl->nonVirtualBases.swap(lowering.nonVirtualBases);
703702
rl->completeObjectVirtualBases.swap(lowering.virtualBases);
704703

705-
assert(!cir::MissingFeatures::bitfields());
706-
707704
// Add all the field numbers.
708705
rl->fieldIdxMap.swap(lowering.fieldIdxMap);
709706

0 commit comments

Comments
 (0)