r223839 - DebugInfo: Correct the location of initializations of auto.

David Blaikie dblaikie at gmail.com
Tue Dec 9 14:04:14 PST 2014


Author: dblaikie
Date: Tue Dec  9 16:04:13 2014
New Revision: 223839

URL: http://llvm.org/viewvc/llvm-project?rev=223839&view=rev
Log:
DebugInfo: Correct the location of initializations of auto.

Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=223839&r1=223838&r2=223839&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Dec  9 16:04:13 2014
@@ -869,9 +869,12 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
       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.

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=223839&r1=223838&r2=223839&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Dec  9 16:04:13 2014
@@ -1126,7 +1126,7 @@ void CodeGenFunction::EmitAutoVarInit(co
   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) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=223839&r1=223838&r2=223839&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Dec  9 16:04:13 2014
@@ -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.

Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=223839&r1=223838&r2=223839&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Tue Dec  9 16:04:13 2014
@@ -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,





More information about the cfe-commits mailing list