Skip to content

Commit 7c666e2

Browse files
authored
[CIR] Implement UnaryExtension for AggregateExpr (#161820)
Implement the UnaryExtension support for AggregateExpr
1 parent 8243c36 commit 7c666e2

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
144144
void VisitUnaryCoawait(UnaryOperator *e) {
145145
cgf.cgm.errorNYI(e->getSourceRange(), "AggExprEmitter: VisitUnaryCoawait");
146146
}
147-
void VisitUnaryExtension(UnaryOperator *e) {
148-
cgf.cgm.errorNYI(e->getSourceRange(),
149-
"AggExprEmitter: VisitUnaryExtension");
150-
}
147+
void VisitUnaryExtension(UnaryOperator *e) { Visit(e->getSubExpr()); }
151148
void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *e) {
152149
cgf.cgm.errorNYI(e->getSourceRange(),
153150
"AggExprEmitter: VisitSubstNonTypeTemplateParmExpr");

clang/test/CIR/CodeGen/struct.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,20 @@ void generic_selection() {
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)
186186

187+
void unary_extension() {
188+
CompleteS a = __extension__ CompleteS();
189+
}
190+
191+
// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a", init]
192+
// CIR: %[[ZERO_INIT:.*]] = cir.const #cir.zero : !rec_CompleteS
193+
// CIR: cir.store{{.*}} %[[ZERO_INIT]], %[[A_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
194+
195+
// LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
196+
// LLVM: store %struct.CompleteS zeroinitializer, ptr %[[A_ADDR]], align 4
197+
198+
// OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
199+
// OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[A_ADDR]], i8 0, i64 8, i1 false)
200+
187201
void bin_comma() {
188202
CompleteS a = (CompleteS(), CompleteS());
189203
}

0 commit comments

Comments
 (0)