File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
test/library/codingstandards/cpp/scope Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,22 @@ module Internal {
57
57
// A catch-block `Handler`, whose parent is the `TryStmt`
58
58
e .( Handler ) .getParent ( ) = result
59
59
or
60
+ // The parent scope of a lambda is the scope in which the lambda expression is defined.
61
+ //
62
+ // Lambda functions are defined in a generated `Closure` class, as the `operator()` function. We choose the
63
+ // enclosing statement of the lambda expression as the parent scope of the lambda function. This is so we can
64
+ // determine the order of definition if a variable is defined in the same scope as the lambda expression.
65
+ exists ( Closure lambdaClosure |
66
+ lambdaClosure .getLambdaFunction ( ) = e and
67
+ lambdaClosure .getLambdaExpression ( ) .getEnclosingStmt ( ) = result
68
+ )
69
+ or
60
70
not exists ( Loop loop | loop .getAChild ( ) = e ) and
61
71
not exists ( IfStmt ifStmt | ifStmt .getThen ( ) = e or ifStmt .getElse ( ) = e ) and
62
72
not exists ( SwitchStmt switchStmt | switchStmt .getStmt ( ) = e ) and
63
73
not exists ( CatchBlock c | c .getParameter ( ) = e ) and
64
74
not e instanceof Handler and
75
+ not exists ( Closure lambdaClosure | lambdaClosure .getLambdaFunction ( ) = e ) and
65
76
if exists ( e .getParentScope ( ) )
66
77
then result = e .getParentScope ( )
67
78
else (
Original file line number Diff line number Diff line change 77
77
| test.cpp:27:28:27:28 | operator= | file://:0:0:0:0 | decltype([...](...){...}) |
78
78
| test.cpp:27:29:27:29 | id1 | file://:0:0:0:0 | decltype([...](...){...}) |
79
79
| test.cpp:27:29:27:31 | id1 | test.cpp:26:15:28:11 | { ... } |
80
- | test.cpp:27:33:27:33 | operator() | file://:0:0:0:0 | decltype([...](...){...}) |
80
+ | test.cpp:27:33:27:33 | operator() | test.cpp:27:13:27:53 | declaration |
81
81
| test.cpp:27:36:27:52 | { ... } | test.cpp:27:33:27:33 | operator() |
82
82
| test.cpp:27:38:27:50 | declaration | test.cpp:27:36:27:52 | { ... } |
83
83
| test.cpp:27:42:27:44 | id1 | test.cpp:27:36:27:52 | { ... } |
You can’t perform that action at this time.
0 commit comments