C#: Add missing CFG edge from generic catch block to finally block

This commit is contained in:
Tom Hvitved
2020-04-21 20:27:29 +02:00
parent bd075a7de0
commit 5b5f9adfc6
3 changed files with 8 additions and 9 deletions

View File

@@ -1710,9 +1710,9 @@ module ControlFlow {
exists(getAThrownException(ts, cfe, c)) and
result = first(ts.getCatchClause(0))
or
exists(SpecificCatchClause scc, int i | scc = ts.getCatchClause(i) |
cfe = scc and
scc = last(ts.getCatchClause(i), c) and
exists(CatchClause cc, int i | cc = ts.getCatchClause(i) |
cfe = cc and
cc = last(ts.getCatchClause(i), c) and
(
// Flow from one `catch` clause to the next
result = first(ts.getCatchClause(i + 1)) and
@@ -1725,7 +1725,7 @@ module ControlFlow {
)
or
cfe = last(ts.getCatchClause(i), c) and
cfe = last(scc.getFilterClause(), _) and
cfe = last(cc.getFilterClause(), _) and
(
// Flow from last element of `catch` clause filter to next `catch` clause
result = first(ts.getCatchClause(i + 1)) and
@@ -1739,7 +1739,7 @@ module ControlFlow {
)
or
// Flow from last element of a `catch` block to first element of `finally` block
cfe = lastCatchClauseBlock(scc, c) and
cfe = lastCatchClauseBlock(cc, c) and
result = first(ts.getFinally())
)
or

View File

@@ -1625,7 +1625,6 @@ dominance
| Finally.cs:217:5:231:5 | {...} | Finally.cs:218:9:229:9 | try {...} ... |
| Finally.cs:218:9:229:9 | try {...} ... | Finally.cs:219:9:221:9 | {...} |
| Finally.cs:219:9:221:9 | {...} | Finally.cs:220:13:220:37 | ...; |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:227:9:229:9 | {...} |
| Finally.cs:220:13:220:37 | ...; | Finally.cs:220:31:220:35 | "Try" |
| Finally.cs:220:31:220:35 | "Try" | Finally.cs:220:13:220:36 | call to method WriteLine |
| Finally.cs:220:31:220:35 | "Try" | Finally.cs:222:9:225:9 | catch {...} |
@@ -4538,7 +4537,6 @@ postDominance
| Finally.cs:217:5:231:5 | {...} | Finally.cs:216:10:216:12 | enter M11 |
| Finally.cs:218:9:229:9 | try {...} ... | Finally.cs:217:5:231:5 | {...} |
| Finally.cs:219:9:221:9 | {...} | Finally.cs:218:9:229:9 | try {...} ... |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:220:31:220:35 | "Try" |
| Finally.cs:220:13:220:37 | ...; | Finally.cs:219:9:221:9 | {...} |
| Finally.cs:220:31:220:35 | "Try" | Finally.cs:220:13:220:37 | ...; |
| Finally.cs:223:9:225:9 | {...} | Finally.cs:222:9:225:9 | catch {...} |
@@ -4546,6 +4544,7 @@ postDominance
| Finally.cs:224:13:224:39 | ...; | Finally.cs:223:9:225:9 | {...} |
| Finally.cs:224:31:224:37 | "Catch" | Finally.cs:224:13:224:39 | ...; |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:220:13:220:36 | call to method WriteLine |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:224:13:224:38 | call to method WriteLine |
| Finally.cs:228:13:228:40 | call to method WriteLine | Finally.cs:228:31:228:39 | "Finally" |
| Finally.cs:228:13:228:41 | ...; | Finally.cs:227:9:229:9 | {...} |
| Finally.cs:228:31:228:39 | "Finally" | Finally.cs:228:13:228:41 | ...; |
@@ -6985,7 +6984,6 @@ blockDominance
| Finally.cs:216:10:216:12 | enter M11 | Finally.cs:222:9:225:9 | catch {...} |
| Finally.cs:216:10:216:12 | enter M11 | Finally.cs:227:9:229:9 | {...} |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:220:13:220:36 | call to method WriteLine |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:227:9:229:9 | {...} |
| Finally.cs:222:9:225:9 | catch {...} | Finally.cs:222:9:225:9 | catch {...} |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:227:9:229:9 | {...} |
| Foreach.cs:6:10:6:11 | enter M1 | Foreach.cs:6:10:6:11 | enter M1 |
@@ -8793,11 +8791,11 @@ postBlockDominance
| Finally.cs:211:13:211:29 | [finally: exception(Exception)] ...; | Finally.cs:211:13:211:29 | [finally: exception(Exception)] ...; |
| Finally.cs:211:13:211:29 | [finally: exception(ExceptionA)] ...; | Finally.cs:211:13:211:29 | [finally: exception(ExceptionA)] ...; |
| Finally.cs:216:10:216:12 | enter M11 | Finally.cs:216:10:216:12 | enter M11 |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:216:10:216:12 | enter M11 |
| Finally.cs:220:13:220:36 | call to method WriteLine | Finally.cs:220:13:220:36 | call to method WriteLine |
| Finally.cs:222:9:225:9 | catch {...} | Finally.cs:222:9:225:9 | catch {...} |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:216:10:216:12 | enter M11 |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:220:13:220:36 | call to method WriteLine |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:222:9:225:9 | catch {...} |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:227:9:229:9 | {...} |
| Foreach.cs:6:10:6:11 | enter M1 | Foreach.cs:6:10:6:11 | enter M1 |
| Foreach.cs:6:10:6:11 | exit M1 | Foreach.cs:6:10:6:11 | enter M1 |

View File

@@ -1829,6 +1829,7 @@
| Finally.cs:220:31:220:35 | "Try" | Finally.cs:222:9:225:9 | catch {...} | semmle.label | exception(OutOfMemoryException) |
| Finally.cs:222:9:225:9 | catch {...} | Finally.cs:223:9:225:9 | {...} | semmle.label | successor |
| Finally.cs:223:9:225:9 | {...} | Finally.cs:224:13:224:39 | ...; | semmle.label | successor |
| Finally.cs:224:13:224:38 | call to method WriteLine | Finally.cs:227:9:229:9 | {...} | semmle.label | successor |
| Finally.cs:224:13:224:39 | ...; | Finally.cs:224:31:224:37 | "Catch" | semmle.label | successor |
| Finally.cs:224:31:224:37 | "Catch" | Finally.cs:224:13:224:38 | call to method WriteLine | semmle.label | successor |
| Finally.cs:227:9:229:9 | {...} | Finally.cs:228:13:228:41 | ...; | semmle.label | successor |