r223902 - DebugInfo: Correct location information for array accesses to elements of variable array type.

David Blaikie dblaikie at gmail.com
Tue Dec 9 17:34:25 PST 2014


Author: dblaikie
Date: Tue Dec  9 19:34:25 2014
New Revision: 223902

URL: http://llvm.org/viewvc/llvm-project?rev=223902&view=rev
Log:
DebugInfo: Correct location information for array accesses to elements of variable array type.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=223902&r1=223901&r2=223902&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec  9 19:34:25 2014
@@ -2407,6 +2407,9 @@ LValue CodeGenFunction::EmitArraySubscri
     // The element count here is the total number of non-VLA elements.
     llvm::Value *numElements = getVLASize(vla).first;
 
+    if (auto *DI = getDebugInfo())
+      DI->EmitLocation(Builder, E->getLocStart());
+
     // Effectively, the multiply by the VLA size is part of the GEP.
     // GEP indexes are signed, and scaling an index isn't permitted to
     // signed-overflow, so we use the same semantics for our explicit

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=223902&r1=223901&r2=223902&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Tue Dec  9 19:34:25 2014
@@ -90,6 +90,15 @@ void f8() {
       src1)[src2()];
 }
 
+// CHECK-LABEL: define
+void f9(int i) {
+  int src1[1][i];
+  int src2();
+#line 1000
+  auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]]
+      src1)[src2()];
+}
+
 // CHECK: [[DBG_F1]] = metadata !{i32 100,
 // CHECK: [[DBG_FOO_VALUE]] = metadata !{i32 200,
 // CHECK: [[DBG_FOO_REF]] = metadata !{i32 202,
@@ -101,3 +110,4 @@ void f8() {
 // CHECK: [[DBG_F6]] = metadata !{i32 700,
 // CHECK: [[DBG_F7]] = metadata !{i32 800,
 // CHECK: [[DBG_F8]] = metadata !{i32 900,
+// CHECK: [[DBG_F9]] = metadata !{i32 1000,





More information about the cfe-commits mailing list