From f5869c4ac58bc8d1ec1226a8d2cbf6ba8f7f83d1 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 8 Dec 2014 21:48:57 +0000 Subject: [PATCH] DebugInfo: Ensure the store for an assignment is attributed to the beginning of the assignment expression git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223699 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 2 ++ test/CodeGenCXX/debug-info-line.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/CodeGenCXX/debug-info-line.cpp diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 1a3a61a76d..6ced6e18f9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -3133,6 +3133,8 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { RValue RV = EmitAnyExpr(E->getRHS()); LValue LV = EmitCheckedLValue(E->getLHS(), TCK_Store); + if (CGDebugInfo *DI = getDebugInfo()) + DI->EmitLocation(Builder, E->getLocStart()); EmitStoreThroughLValue(RV, LV); return LV; } diff --git a/test/CodeGenCXX/debug-info-line.cpp b/test/CodeGenCXX/debug-info-line.cpp new file mode 100644 index 0000000000..0434de5e10 --- /dev/null +++ b/test/CodeGenCXX/debug-info-line.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s + +int src(); int* sink(); + +void f1() { +#line 100 + * // The store for the assignment should be attributed to the start of the + // assignment expression here, regardless of the location of subexpressions. + ( + sink + ( + ) + + + 3 + ) + = + src + ( + ) + + + 42 + ; + // CHECK: store {{.*}}, !dbg [[DBG1:!.*]] +} + +// CHECK: [[DBG1]] = metadata !{i32 100, {{.*}} -- 2.40.0