Skip to content

Commit 8243c36

Browse files
authored
[CIR] Upstream CXXParenListInitExpr for AggregateExpr (#161876)
Upstream the CXXParenListInitExpr support for AggregateExpr
1 parent c06aa2e commit 8243c36

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
213213
}
214214
void VisitChooseExpr(const ChooseExpr *e) { Visit(e->getChosenSubExpr()); }
215215
void VisitCXXParenListInitExpr(CXXParenListInitExpr *e) {
216-
cgf.cgm.errorNYI(e->getSourceRange(),
217-
"AggExprEmitter: VisitCXXParenListInitExpr");
216+
visitCXXParenListOrInitListExpr(e, e->getInitExprs(),
217+
e->getInitializedFieldInUnion(),
218+
e->getArrayFiller());
218219
}
220+
219221
void VisitArrayInitLoopExpr(const ArrayInitLoopExpr *e,
220222
llvm::Value *outerBegin = nullptr) {
221223
cgf.cgm.errorNYI(e->getSourceRange(),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7+
8+
struct CompleteS {
9+
int a;
10+
char b;
11+
};
12+
13+
void cxx_paren_list_init_expr() { CompleteS a(1, 'a'); }
14+
15+
// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a", init]
16+
// CIR: %[[ELEM_0_PTR:.*]] = cir.get_member %[[A_ADDR]][0] {name = "a"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s32i>
17+
// CIR: %[[ELEM_0_VAL:.*]] = cir.const #cir.int<1> : !s32i
18+
// CIR: cir.store{{.*}} %[[ELEM_0_VAL]], %[[ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
19+
// CIR: %[[ELEM_1_PTR:.*]] = cir.get_member %[[A_ADDR]][1] {name = "b"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s8i>
20+
// CIR: %[[ELEM_1_VAL:.*]] = cir.const #cir.int<97> : !s8i
21+
// CIR: cir.store{{.*}} %[[ELEM_1_VAL]], %[[ELEM_1_PTR]] : !s8i, !cir.ptr<!s8i>
22+
23+
// LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
24+
// LLVM: %[[ELEM_0_PTR:.*]] = getelementptr %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 0
25+
// LLVM: store i32 1, ptr %[[ELEM_0_PTR]], align 4
26+
// LLVM: %[[ELEM_1_PTR:.*]] = getelementptr %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 1
27+
// LLVM: store i8 97, ptr %[[ELEM_1_PTR]], align 4
28+
29+
// OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
30+
// OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[A_ADDR]], ptr align 4 @__const._Z24cxx_paren_list_init_exprv.a, i64 8, i1 false)

0 commit comments

Comments
 (0)