Skip to content

Commit 29000c4

Browse files
committed
CPP: Make LambdaCapture an Element.
1 parent 6462da7 commit 29000c4

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ class Closure extends Class {
9898
/**
9999
* Information about a value captured as part of a lambda expression.
100100
*/
101-
class LambdaCapture extends @lambdacapture {
102-
string toString() {
101+
class LambdaCapture extends Locatable, @lambdacapture {
102+
override string toString() {
103103
result = getField().toString()
104104
}
105105

106-
string getCanonicalQLClass() { result = "LambdaCapture" }
106+
override string getCanonicalQLClass() { result = "LambdaCapture" }
107107

108108
/**
109109
* Holds if this capture was made implicitly.
@@ -133,7 +133,7 @@ class LambdaCapture extends @lambdacapture {
133133
* For implicit captures, this is the first location within the "{...}" part of the lambda
134134
* expression which accesses the captured variable.
135135
*/
136-
Location getLocation() {
136+
override Location getLocation() {
137137
lambda_capture(this, _, _, _, _, _, result)
138138
}
139139

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,8 @@ frienddecls(
10261026
| @namequalifier
10271027
| @specialnamequalifyingelement
10281028
| @static_assert
1029-
| @type_mention;
1029+
| @type_mention
1030+
| @lambdacapture;
10301031

10311032
@exprparent = @element;
10321033

cpp/ql/test/library-tests/lambdas/captures/elements.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
| captures.cpp:3:6:3:6 | definition of x |
2525
| captures.cpp:3:6:3:6 | x |
2626
| captures.cpp:3:6:3:6 | x |
27+
| captures.cpp:3:6:3:6 | x |
2728
| captures.cpp:3:9:3:9 | (captured this) |
2829
| captures.cpp:3:9:3:9 | definition of (captured this) |
30+
| captures.cpp:3:9:3:12 | (captured this) |
2931
| captures.cpp:3:9:3:12 | this |
3032
| captures.cpp:3:15:3:15 | definition of operator() |
3133
| captures.cpp:3:15:3:15 | operator() |
@@ -56,11 +58,13 @@
5658
| captures.cpp:9:9:9:9 | operator() |
5759
| captures.cpp:9:9:11:5 | { ... } |
5860
| captures.cpp:10:7:10:7 | (captured this) |
61+
| captures.cpp:10:7:10:7 | (captured this) |
5962
| captures.cpp:10:7:10:7 | call to b |
6063
| captures.cpp:10:7:10:7 | definition of (captured this) |
6164
| captures.cpp:10:7:10:15 | ExprStmt |
6265
| captures.cpp:10:9:10:9 | definition of x |
6366
| captures.cpp:10:9:10:9 | x |
67+
| captures.cpp:10:9:10:9 | x |
6468
| captures.cpp:10:9:10:13 | ... + ... |
6569
| captures.cpp:10:13:10:13 | 1 |
6670
| captures.cpp:11:5:11:5 | return ... |
@@ -84,6 +88,7 @@
8488
| captures.cpp:15:6:15:6 | definition of x |
8589
| captures.cpp:15:6:15:6 | x |
8690
| captures.cpp:15:6:15:6 | x |
91+
| captures.cpp:15:6:15:6 | x |
8792
| captures.cpp:15:9:15:9 | definition of operator() |
8893
| captures.cpp:15:9:15:9 | operator() |
8994
| captures.cpp:15:9:17:5 | { ... } |
@@ -123,6 +128,7 @@
123128
| captures.cpp:22:23:22:23 | definition of x |
124129
| captures.cpp:22:23:22:23 | x |
125130
| captures.cpp:22:23:22:23 | x |
131+
| captures.cpp:22:23:22:23 | x |
126132
| captures.cpp:22:25:22:25 | definition of operator() |
127133
| captures.cpp:22:25:22:25 | operator() |
128134
| captures.cpp:22:30:22:30 | definition of z |
@@ -134,6 +140,7 @@
134140
| captures.cpp:23:16:23:16 | (reference dereference) |
135141
| captures.cpp:23:16:23:16 | definition of y |
136142
| captures.cpp:23:16:23:16 | y |
143+
| captures.cpp:23:16:23:16 | y |
137144
| captures.cpp:23:20:23:20 | z |
138145
| captures.cpp:26:3:26:24 | return ... |
139146
| captures.cpp:26:10:26:17 | (const lambda [] type at line 22, col. 19)... |
@@ -176,6 +183,7 @@
176183
| end_pos.cpp:9:17:9:17 | ii |
177184
| end_pos.cpp:9:17:9:18 | (reference to) |
178185
| end_pos.cpp:9:17:9:18 | ii |
186+
| end_pos.cpp:9:17:9:18 | ii |
179187
| end_pos.cpp:9:20:9:20 | definition of operator() |
180188
| end_pos.cpp:9:20:9:20 | operator() |
181189
| end_pos.cpp:9:27:11:5 | { ... } |

0 commit comments

Comments
 (0)