Skip to content

Commit 937824f

Browse files
gitolegxlauko
authored andcommitted
[CIR][Codegen][Bugfix] use record layout to generate index for a field (llvm#270)
This is a minor fix similar to the one introduced in llvm#263. Basically, all calls to the `buildLValueForFieldInitialization` are even with the origin codegen `emitLValueForFieldInitialization` calls, i.e. the field index is calculated from the record layout, but not from the decl `field->getFieldIndex()`. Added just one test, because looks like we need to implement some `NYI` features first to test another places e.g. in `CIRGenExprAgg.cpp`, though I could miss something. Anyway, given the original codegen doesn't use `getFieldIndex` in these places, we also should not. All the remaining usages of `getFieldIndex` are ok.
1 parent 8989018 commit 937824f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,9 +1586,8 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
15861586
if (curInitIndex == NumInitElements && Dest.isZeroed() &&
15871587
CGF.getTypes().isZeroInitializable(ExprToVisit->getType()))
15881588
break;
1589-
15901589
LValue LV = CGF.buildLValueForFieldInitialization(
1591-
DestLV, field, field->getName(), field->getFieldIndex());
1590+
DestLV, field, field->getName());
15921591
// We never generate write-barries for initialized fields.
15931592
assert(!UnimplementedFeature::setNonGC());
15941593

0 commit comments

Comments
 (0)