Skip to content

Commit 45dfb2a

Browse files
committed
Add more test coverage
1 parent 4a1d1bb commit 45dfb2a

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,6 +3387,12 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
33873387
auto *FD = LambdaCaptureFields.lookup(BD);
33883388
return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
33893389
}
3390+
// Suppress debug location updates when visiting the binding, since the
3391+
// binding may emit instructions that would otherwise be associated with the
3392+
// binding itself, rather than the expression referencing the binding. (this
3393+
// leads to jumpy debug stepping behavior where the location/debugger jump
3394+
// back to the binding declaration, then back to the expression referencing
3395+
// the binding)
33903396
DisableDebugLocationUpdates D(*this);
33913397
return EmitLValue(BD->getBinding(), NotKnownNonNull);
33923398
}

clang/test/DebugInfo/CXX/structured-binding.cpp

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
// CHECK: #dbg_declare(ptr %{{[0-9]+}}, ![[VAR_4:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 4),
88
// CHECK: #dbg_declare(ptr %z1, ![[VAR_5:[0-9]+]], !DIExpression()
99
// CHECK: #dbg_declare(ptr %z2, ![[VAR_6:[0-9]+]], !DIExpression()
10-
// CHECK: load ptr, ptr %z1, {{.*}}!dbg ![[Z1_DEBUG_LOC:[0-9]+]]
10+
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y1_DEBUG_LOC:[0-9]+]]
11+
// CHECK: getelementptr inbounds nuw %struct.A, ptr {{.*}}, i32 0, i32 1, !dbg ![[Y2_DEBUG_LOC:[0-9]+]]
12+
// CHECK: load ptr, ptr %z2, {{.*}}!dbg ![[Z2_DEBUG_LOC:[0-9]+]]
13+
// CHECK: getelementptr inbounds [2 x i32], ptr {{.*}}, i64 0, i64 1, !dbg ![[A2_DEBUG_LOC:[0-9]+]]
14+
// CHECK: getelementptr inbounds nuw { i32, i32 }, ptr {{.*}}, i32 0, i32 1, !dbg ![[C2_DEBUG_LOC:[0-9]+]]
15+
// CHECK: extractelement <2 x i32> {{.*}}, i32 1, !dbg ![[V2_DEBUG_LOC:[0-9]+]]
1116
// CHECK: ![[VAR_0]] = !DILocalVariable(name: "a"
1217
// CHECK: ![[VAR_1]] = !DILocalVariable(name: "x1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
1318
// CHECK: ![[VAR_2]] = !DILocalVariable(name: "y1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
@@ -47,9 +52,41 @@ int f() {
4752
auto [x1, y1] = a;
4853
auto &[x2, y2] = a;
4954
auto [z1, z2] = B{1, 2};
50-
return x1 + y1 + x2 + y2 +
51-
// CHECK: ![[Z1_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
52-
z1 //
53-
+ //
54-
z2; //
55+
int array[2] = {3, 4};
56+
auto &[a1, a2] = array;
57+
_Complex int cmplx = {1, 2};
58+
auto &[c1, c2] = cmplx;
59+
int vctr __attribute__ ((vector_size (sizeof(int)*2)))= {1, 2};
60+
auto &[v1, v2] = vctr;
61+
return //
62+
x1 //
63+
+ //
64+
// CHECK: ![[Y1_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
65+
y1 //
66+
+ //
67+
x2 //
68+
+ //
69+
// CHECK: ![[Y2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
70+
y2 //
71+
+ //
72+
z1 //
73+
+ //
74+
// CHECK: ![[Z2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
75+
z2 //
76+
+ //
77+
a1 //
78+
+ //
79+
// CHECK: ![[A2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
80+
a2 //
81+
+ //
82+
c1 //
83+
+ //
84+
// CHECK: ![[C2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
85+
c2 //
86+
+ //
87+
v1 //
88+
+ //
89+
// CHECK: ![[V2_DEBUG_LOC]] = !DILocation(line: [[@LINE+1]]
90+
v2 //
91+
;
5592
}

0 commit comments

Comments
 (0)