Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
return Visit(e->getSubExpr());
}

mlir::Value VisitCXXDefaultArgExpr(CXXDefaultArgExpr *dae) {
CIRGenFunction::CXXDefaultArgExprScope scope(cgf, dae);
return Visit(dae->getExpr());
}
mlir::Value VisitCXXDefaultInitExpr(CXXDefaultInitExpr *die) {
CIRGenFunction::CXXDefaultInitExprScope scope(cgf, die);
return Visit(die->getExpr());
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CIR/CodeGen/defaultarg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,25 @@ void foo() {
// OGCG: %[[TMP0:.*]] = alloca i32
// OGCG: store i32 42, ptr %[[TMP0]]
// OGCG: call void @_Z3barRKi(ptr {{.*}} %[[TMP0]])

struct S
{
S(int n = 2);
};

void test_ctor_defaultarg() {
S s;
}

// CIR: cir.func {{.*}} @_Z20test_ctor_defaultargv()
// CIR: %[[S:.*]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["s", init]
// CIR: %[[TWO:.*]] = cir.const #cir.int<2> : !s32i
// CIR: cir.call @_ZN1SC1Ei(%[[S]], %[[TWO]]) : (!cir.ptr<!rec_S>, !s32i) -> ()

// LLVM: define{{.*}} @_Z20test_ctor_defaultargv()
// LLVM: %[[S:.*]] = alloca %struct.S
// LLVM: call void @_ZN1SC1Ei(ptr %[[S]], i32 2)

// OGCG: define{{.*}} @_Z20test_ctor_defaultargv()
// OGCG: %[[S:.*]] = alloca %struct.S
// OGCG: call void @_ZN1SC1Ei(ptr{{.*}} %[[S]], i32 {{.*}} 2)