Skip to content

Commit 7850d25

Browse files
committed
[CIR] Implement BinCommaExpr for AggregateExpr
1 parent 72679c8 commit 7850d25

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
184184
cgf.cgm.errorNYI(e->getSourceRange(), "AggExprEmitter: VisitBinAssign");
185185
}
186186
void VisitBinComma(const BinaryOperator *e) {
187-
cgf.cgm.errorNYI(e->getSourceRange(), "AggExprEmitter: VisitBinComma");
187+
cgf.emitIgnoredExpr(e->getLHS());
188+
Visit(e->getRHS());
188189
}
189190
void VisitBinCmp(const BinaryOperator *e) {
190191
cgf.cgm.errorNYI(e->getSourceRange(), "AggExprEmitter: VisitBinCmp");

clang/test/CIR/CodeGen/struct.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,25 @@ void generic_selection() {
183183
// OGCG: %[[C_ADDR:.*]] = alloca i32, align 4
184184
// OGCG: %[[D_ADDR:.*]] = alloca %struct.CompleteS, align 4
185185
// OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[D_ADDR]], ptr align 4 %[[A_ADDR]], i64 8, i1 false)
186+
187+
void bin_comma() {
188+
CompleteS a = (CompleteS(), CompleteS());
189+
}
190+
191+
// CIR: cir.func{{.*}} @_Z9bin_commav()
192+
// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a", init]
193+
// CIR: %[[TMP_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["agg.tmp0"]
194+
// CIR: %[[ZERO:.*]] = cir.const #cir.zero : !rec_CompleteS
195+
// CIR: cir.store{{.*}} %[[ZERO]], %[[TMP_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
196+
// CIR: %[[ZERO:.*]] = cir.const #cir.zero : !rec_CompleteS
197+
// CIR: cir.store{{.*}} %[[ZERO]], %[[A_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
198+
199+
// LLVM: define{{.*}} void @_Z9bin_commav()
200+
// LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
201+
// LLVM: %[[TMP_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
202+
// LLVM: store %struct.CompleteS zeroinitializer, ptr %[[TMP_ADDR]], align 4
203+
// LLVM: store %struct.CompleteS zeroinitializer, ptr %[[A_ADDR]], align 4
204+
205+
// OGCG: define{{.*}} void @_Z9bin_commav()
206+
// OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
207+
// OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[A_ADDR]], i8 0, i64 8, i1 false)

0 commit comments

Comments
 (0)