File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
test/library/codingstandards/cpp/scope Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,25 @@ module Internal {
38
38
or
39
39
exists ( SwitchStmt switchStmt | switchStmt .getStmt ( ) = e and result = switchStmt )
40
40
or
41
+ // A catch-block parameter, whose parent is the `Handler`
42
+ exists ( CatchBlock c | c .getParameter ( ) = e and result = c .getParent ( ) )
43
+ or
44
+ // A catch-block `Handler`, whose parent is the `TryStmt`
45
+ e .( Handler ) .getParent ( ) = result
46
+ or
41
47
not exists ( Loop loop | loop .getAChild ( ) = e ) and
42
48
not exists ( IfStmt ifStmt | ifStmt .getThen ( ) = e or ifStmt .getElse ( ) = e ) and
43
49
not exists ( SwitchStmt switchStmt | switchStmt .getStmt ( ) = e ) and
50
+ not exists ( CatchBlock c | c .getParameter ( ) = e ) and
51
+ not e instanceof Handler and
44
52
if exists ( e .getParentScope ( ) )
45
53
then result = e .getParentScope ( )
46
54
else (
47
- // Statements do no have a parent scope, so return the enclosing block.
55
+ // Statements do not have a parent scope, so return the enclosing block.
48
56
result = e .( Stmt ) .getEnclosingBlock ( )
49
57
or
58
+ // Expressions do not have a parent scope, so return the enclosing block.
50
59
result = e .( Expr ) .getEnclosingBlock ( )
51
- or
52
- // Catch block parameters don't have an enclosing scope, so attach them to the
53
- // the block itself
54
- exists ( CatchBlock cb |
55
- e = cb .getParameter ( ) and
56
- result = cb
57
- )
58
60
)
59
61
}
60
62
}
Original file line number Diff line number Diff line change 83
83
| test.cpp:27:42:27:44 | id1 | test.cpp:27:36:27:52 | { ... } |
84
84
| test.cpp:27:47:27:49 | 10 | test.cpp:27:36:27:52 | { ... } |
85
85
| test.cpp:27:52:27:52 | return ... | test.cpp:27:36:27:52 | { ... } |
86
- | test.cpp:28:24:28:26 | id1 | test.cpp:28:29:30:11 | { ... } |
87
- | test.cpp:28:29:30:11 | <handler> | test.cpp:13:9:31:9 | { ... } |
86
+ | test.cpp:28:24:28:26 | id1 | test.cpp:28:29:30:11 | <handler> |
87
+ | test.cpp:28:29:30:11 | <handler> | test.cpp:26:11:28:11 | try { ... } |
88
88
| test.cpp:28:29:30:11 | { ... } | test.cpp:13:9:31:9 | { ... } |
89
89
| test.cpp:29:13:29:20 | declaration | test.cpp:28:29:30:11 | { ... } |
90
90
| test.cpp:29:17:29:19 | id1 | test.cpp:28:29:30:11 | { ... } |
You can’t perform that action at this time.
0 commit comments