Skip to content

Commit

Permalink
[CIR][CIRGen] Add missing visitor for ParenExpr (llvm#428)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
YazZz1k authored and lanza committed Apr 17, 2024
1 parent 2c4626f commit fd14920
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
<< 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");
}
Expand Down
10 changes: 10 additions & 0 deletions clang/test/CIR/CodeGen/agg-copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<!ty_22A22>, cir.ptr <!cir.ptr<!ty_22A22>>, ["a1", init] {alignment = 8 : i64}
// CHECK: [[TMP1]] = cir.alloca !ty_22A22, cir.ptr <!ty_22A22>, ["a2", init] {alignment = 4 : i64}
// CHECK: cir.store %arg0, [[TMP0]] : !cir.ptr<!ty_22A22>, cir.ptr <!cir.ptr<!ty_22A22>>
// CHECK: [[TMP2]] = cir.load deref [[TMP0]] : cir.ptr <!cir.ptr<!ty_22A22>>, !cir.ptr<!ty_22A22>
// CHECK: cir.copy [[TMP2]] to [[TMP1]] : !cir.ptr<!ty_22A22>
}

0 comments on commit fd14920

Please sign in to comment.