Skip to content

Commit c89eb13

Browse files
authored
[CIR] Handle implicit value init constants (llvm#164504)
This adds a handle for VisitImplicitValueInitExpr in ConstExprEmitter.
1 parent 4cb91e7 commit c89eb13

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,7 @@ class ConstExprEmitter
10281028

10291029
mlir::Attribute VisitImplicitValueInitExpr(ImplicitValueInitExpr *e,
10301030
QualType t) {
1031-
cgm.errorNYI(e->getBeginLoc(),
1032-
"ConstExprEmitter::VisitImplicitValueInitExpr");
1033-
return {};
1031+
return cgm.getBuilder().getZeroInitAttr(cgm.convertType(t));
10341032
}
10351033

10361034
mlir::Attribute VisitInitListExpr(InitListExpr *ile, QualType t) {

clang/test/CIR/CodeGen/struct-init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ struct S {
99
int a, b, c;
1010
};
1111

12+
S partial_init = { 1 };
13+
14+
// CIR: cir.global external @partial_init = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<0> : !s32i, #cir.int<0> : !s32i}> : !rec_S
15+
// LLVM: @partial_init = global %struct.S { i32 1, i32 0, i32 0 }
16+
// OGCG: @partial_init = global %struct.S { i32 1, i32 0, i32 0 }
17+
1218
void init() {
1319
S s1 = {1, 2, 3};
1420
S s2 = {4, 5};

0 commit comments

Comments
 (0)