Skip to content

Commit 58135ea

Browse files
authored
[CIR] Backport UnaryExtension for AggregateExpr (#1948)
Backporting UnaryExtension for AggregateExpr from the upstream
1 parent 66c5964 commit 58135ea

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
186186
}
187187
void VisitCoyieldExpr(CoyieldExpr *E) { llvm_unreachable("NYI"); }
188188
void VisitUnaryCoawait(UnaryOperator *E) { llvm_unreachable("NYI"); }
189-
void VisitUnaryExtension(UnaryOperator *E) { llvm_unreachable("NYI"); }
189+
void VisitUnaryExtension(UnaryOperator *E) { Visit(E->getSubExpr()); }
190190
void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E) {
191191
llvm_unreachable("NYI");
192192
}

clang/test/CIR/CodeGen/struct.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ void designated_init_update_expr() {
196196
// CHECK: cir.store{{.*}} %[[CONST_1]], %[[ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
197197
// CHECK: %[[ELEM_1_PTR:.*]] = cir.get_member %[[C_ADDR]][1] {name = "b"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s8i>
198198

199+
void unary_extension() {
200+
CompleteS a = __extension__ CompleteS();
201+
}
202+
203+
// CHECK: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a"]
204+
// CHECK: %[[ZERO_INIT:.*]] = cir.const #cir.zero : !rec_CompleteS
205+
// CHECK: cir.store{{.*}} %[[ZERO_INIT]], %[[A_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
206+
199207
void generic_selection() {
200208
CompleteS a;
201209
CompleteS b;
@@ -219,4 +227,4 @@ void choose_expr() {
219227
// CHECK: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a"]
220228
// CHECK: %[[B_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["b"]
221229
// CHECK: %[[C_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["c", init]
222-
// CHECK: cir.copy %[[A_ADDR]] to %[[C_ADDR]] : !cir.ptr<!rec_CompleteS>
230+
// CHECK: cir.copy %[[A_ADDR]] to %[[C_ADDR]] : !cir.ptr<!rec_CompleteS>

0 commit comments

Comments
 (0)