Skip to content

Commit

Permalink
[CIR][CIRGen][Bugfix] Fix source location in ctors (llvm#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
YazZz1k authored and lanza committed Apr 17, 2024
1 parent efea52f commit 598f1d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CIR/CodeGen/ctor-srcloc-fix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir-enable -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<!void> loc(#loc6)

0 comments on commit 598f1d5

Please sign in to comment.