From fd149202769f70af97bf738b9653ad2464dc5ef8 Mon Sep 17 00:00:00 2001 From: Kirill Yansitov <36601354+YazZz1k@users.noreply.github.com> Date: Wed, 31 Jan 2024 05:05:58 +0300 Subject: [PATCH] [CIR][CIRGen] Add missing visitor for ParenExpr (#428) Compilation of the following test ``` void foo6(A* a1) { A a2 = (*a1); } ``` fails with. ``` NYI UNREACHABLE executed at /home/huawei/cir/repo/llvm-project/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp:175! ``` Commit adds required visitor and fixes the issue. --- clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp | 2 +- clang/test/CIR/CodeGen/agg-copy.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp b/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp index 24b6145a33da..2ee53520fa0a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp @@ -172,7 +172,7 @@ class AggExprEmitter : public StmtVisitor { << S->getStmtClassName() << "\n"; llvm_unreachable("NYI"); } - void VisitParenExpr(ParenExpr *PE) { llvm_unreachable("NYI"); } + void VisitParenExpr(ParenExpr *PE) { Visit(PE->getSubExpr()); } void VisitGenericSelectionExpr(GenericSelectionExpr *GE) { llvm_unreachable("NYI"); } diff --git a/clang/test/CIR/CodeGen/agg-copy.c b/clang/test/CIR/CodeGen/agg-copy.c index cbc1565dd7f2..9b7f982716d5 100644 --- a/clang/test/CIR/CodeGen/agg-copy.c +++ b/clang/test/CIR/CodeGen/agg-copy.c @@ -72,4 +72,14 @@ A create() { A a; return a; } void foo5() { A a; a = create(); +} + +void foo6(A* a1) { + A a2 = (*a1); +// CHECK: cir.func {{.*@foo6}} +// CHECK: [[TMP0]] = cir.alloca !cir.ptr, cir.ptr >, ["a1", init] {alignment = 8 : i64} +// CHECK: [[TMP1]] = cir.alloca !ty_22A22, cir.ptr , ["a2", init] {alignment = 4 : i64} +// CHECK: cir.store %arg0, [[TMP0]] : !cir.ptr, cir.ptr > +// CHECK: [[TMP2]] = cir.load deref [[TMP0]] : cir.ptr >, !cir.ptr +// CHECK: cir.copy [[TMP2]] to [[TMP1]] : !cir.ptr } \ No newline at end of file