summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-12-09 22:04:13 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-12-09 22:04:13 +0000
commit7f138811cd27f5835e7781d3f1cf0797b26af9b9 (patch)
tree174bb1aa2f2ecae1b4aa7ad765bc41f345ea8662
parentbd8f3c1f61b4fb880322466bcfa7ba300cee38ab (diff)
downloadbcm5719-llvm-7f138811cd27f5835e7781d3f1cf0797b26af9b9.tar.gz
bcm5719-llvm-7f138811cd27f5835e7781d3f1cf0797b26af9b9.zip
DebugInfo: Correct the location of initializations of auto.
llvm-svn: 223839
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp5
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h3
-rw-r--r--clang/test/CodeGenCXX/debug-info-line.cpp8
4 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index be3a5bf6e16..bdb3eaf5499 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -869,9 +869,12 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
ImplicitCastExpr l2r(ImplicitCastExpr::OnStack, type, CK_LValueToRValue,
&declRef, VK_RValue);
+ // FIXME: Pass a specific location for the expr init so that the store is
+ // attributed to a reasonable location - otherwise it may be attributed to
+ // locations of subexpressions in the initialization.
EmitExprAsInit(&l2r, &blockFieldPseudoVar,
MakeAddrLValue(blockField, type, align),
- /*captured by init*/ false);
+ /*captured by init*/ false, SourceLocation());
}
// Activate the cleanup if layout pushed one.
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 97da9ef307b..b754a393666 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1126,7 +1126,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
if (!constant) {
LValue lv = MakeAddrLValue(Loc, type, alignment);
lv.setNonGC(true);
- return EmitExprAsInit(Init, &D, lv, capturedByInit);
+ return EmitExprAsInit(Init, &D, lv, capturedByInit, D.getLocation());
}
if (!emission.IsConstantAggregate) {
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index a80a199512e..bfef0c9a8d6 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1545,8 +1545,7 @@ public:
/// EmitExprAsInit - Emits the code necessary to initialize a
/// location in memory with the given initializer.
void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
- bool capturedByInit,
- SourceLocation DbgLoc = SourceLocation());
+ bool capturedByInit, SourceLocation DbgLoc);
/// hasVolatileMember - returns true if aggregate type has a volatile
/// member.
diff --git a/clang/test/CodeGenCXX/debug-info-line.cpp b/clang/test/CodeGenCXX/debug-info-line.cpp
index f87a24c5b3d..8bf30e4853a 100644
--- a/clang/test/CodeGenCXX/debug-info-line.cpp
+++ b/clang/test/CodeGenCXX/debug-info-line.cpp
@@ -50,9 +50,17 @@ void f3() {
complex_sink() += complex_src();
}
+// CHECK-LABEL: define
+void f4() {
+#line 500
+ auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]]
+ = src();
+}
+
// CHECK: [[DBG_F1]] = metadata !{i32 100,
// CHECK: [[DBG_FOO_VALUE]] = metadata !{i32 200,
// CHECK: [[DBG_FOO_REF]] = metadata !{i32 202,
// CHECK: [[DBG_FOO_COMPLEX]] = metadata !{i32 204,
// CHECK: [[DBG_F2]] = metadata !{i32 300,
// CHECK: [[DBG_F3]] = metadata !{i32 400,
+// CHECK: [[DBG_F4]] = metadata !{i32 500,
OpenPOWER on IntegriCloud