diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp index ce0c3c4cfa93..51533c2310bf 100644 --- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp @@ -657,8 +657,8 @@ void CIRGenFunction::buildNullabilityCheck(LValue LHS, mlir::Value RHS, void CIRGenFunction::buildScalarInit(const Expr *init, mlir::Location loc, LValue lvalue, bool capturedByInit) { // TODO: this is where a lot of ObjC lifetime stuff would be done. - mlir::Value value = buildScalarExpr(init); SourceLocRAIIObject Loc{*this, loc}; + mlir::Value value = buildScalarExpr(init); buildStoreThroughLValue(RValue::get(value), lvalue); return; } diff --git a/clang/test/CIR/CodeGen/ctor-srcloc-fix.cpp b/clang/test/CIR/CodeGen/ctor-srcloc-fix.cpp new file mode 100644 index 000000000000..f70d1f8428d4 --- /dev/null +++ b/clang/test/CIR/CodeGen/ctor-srcloc-fix.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s + +struct e { e(int); }; +e *g = new e(0); + +//CHECK: {{%.*}} = cir.const(#cir.int<1> : !u64i) : !u64i loc(#loc11) +//CHECK: {{%.*}} = cir.call @_Znwm(%1) : (!u64i) -> !cir.ptr loc(#loc6)