]> granicus.if.org Git - clang/commitdiff
DebugInfo: Correct the location of initializations of auto.
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 9 Dec 2014 22:04:13 +0000 (22:04 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 9 Dec 2014 22:04:13 +0000 (22:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223839 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenCXX/debug-info-line.cpp

index be3a5bf6e169f97b8b2ad9ec21db89095031c524..bdb3eaf5499f3aea0b397d34cd9ab0c4382bb185 100644 (file)
@@ -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.
index 97da9ef307b0fe5dd9d7d8594ad31b07e62263eb..b754a39366642c3074d6e2f1234c9b48a7f7352d 100644 (file)
@@ -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) {
index a80a199512eadf28c2e8659b5413cf73872737ee..bfef0c9a8d60eb90fd66c1a9ba89d5dee918df70 100644 (file)
@@ -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.
index f87a24c5b3d6df2224cc26ca36a026513e4a82c0..8bf30e4853a3ed94afc3eb0a6906aab722f0f40e 100644 (file)
@@ -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,