CPP: Make LambdaCapture an Element.

This commit is contained in:
Geoffrey White
2019-08-05 18:55:26 +01:00
parent 6462da736b
commit 29000c411c
3 changed files with 14 additions and 5 deletions

View File

@@ -98,12 +98,12 @@ class Closure extends Class {
/**
* Information about a value captured as part of a lambda expression.
*/
class LambdaCapture extends @lambdacapture {
string toString() {
class LambdaCapture extends Locatable, @lambdacapture {
override string toString() {
result = getField().toString()
}
string getCanonicalQLClass() { result = "LambdaCapture" }
override string getCanonicalQLClass() { result = "LambdaCapture" }
/**
* Holds if this capture was made implicitly.
@@ -133,7 +133,7 @@ class LambdaCapture extends @lambdacapture {
* For implicit captures, this is the first location within the "{...}" part of the lambda
* expression which accesses the captured variable.
*/
Location getLocation() {
override Location getLocation() {
lambda_capture(this, _, _, _, _, _, result)
}

View File

@@ -1026,7 +1026,8 @@ frienddecls(
| @namequalifier
| @specialnamequalifyingelement
| @static_assert
| @type_mention;
| @type_mention
| @lambdacapture;
@exprparent = @element;

View File

@@ -24,8 +24,10 @@
| captures.cpp:3:6:3:6 | definition of x |
| captures.cpp:3:6:3:6 | x |
| captures.cpp:3:6:3:6 | x |
| captures.cpp:3:6:3:6 | x |
| captures.cpp:3:9:3:9 | (captured this) |
| captures.cpp:3:9:3:9 | definition of (captured this) |
| captures.cpp:3:9:3:12 | (captured this) |
| captures.cpp:3:9:3:12 | this |
| captures.cpp:3:15:3:15 | definition of operator() |
| captures.cpp:3:15:3:15 | operator() |
@@ -56,11 +58,13 @@
| captures.cpp:9:9:9:9 | operator() |
| captures.cpp:9:9:11:5 | { ... } |
| captures.cpp:10:7:10:7 | (captured this) |
| captures.cpp:10:7:10:7 | (captured this) |
| captures.cpp:10:7:10:7 | call to b |
| captures.cpp:10:7:10:7 | definition of (captured this) |
| captures.cpp:10:7:10:15 | ExprStmt |
| captures.cpp:10:9:10:9 | definition of x |
| captures.cpp:10:9:10:9 | x |
| captures.cpp:10:9:10:9 | x |
| captures.cpp:10:9:10:13 | ... + ... |
| captures.cpp:10:13:10:13 | 1 |
| captures.cpp:11:5:11:5 | return ... |
@@ -84,6 +88,7 @@
| captures.cpp:15:6:15:6 | definition of x |
| captures.cpp:15:6:15:6 | x |
| captures.cpp:15:6:15:6 | x |
| captures.cpp:15:6:15:6 | x |
| captures.cpp:15:9:15:9 | definition of operator() |
| captures.cpp:15:9:15:9 | operator() |
| captures.cpp:15:9:17:5 | { ... } |
@@ -123,6 +128,7 @@
| captures.cpp:22:23:22:23 | definition of x |
| captures.cpp:22:23:22:23 | x |
| captures.cpp:22:23:22:23 | x |
| captures.cpp:22:23:22:23 | x |
| captures.cpp:22:25:22:25 | definition of operator() |
| captures.cpp:22:25:22:25 | operator() |
| captures.cpp:22:30:22:30 | definition of z |
@@ -134,6 +140,7 @@
| captures.cpp:23:16:23:16 | (reference dereference) |
| captures.cpp:23:16:23:16 | definition of y |
| captures.cpp:23:16:23:16 | y |
| captures.cpp:23:16:23:16 | y |
| captures.cpp:23:20:23:20 | z |
| captures.cpp:26:3:26:24 | return ... |
| captures.cpp:26:10:26:17 | (const lambda [] type at line 22, col. 19)... |
@@ -176,6 +183,7 @@
| end_pos.cpp:9:17:9:17 | ii |
| end_pos.cpp:9:17:9:18 | (reference to) |
| end_pos.cpp:9:17:9:18 | ii |
| end_pos.cpp:9:17:9:18 | ii |
| end_pos.cpp:9:20:9:20 | definition of operator() |
| end_pos.cpp:9:20:9:20 | operator() |
| end_pos.cpp:9:27:11:5 | { ... } |