зеркало из https://github.com/github/codeql.git
Merge pull request #14190 from github/alexdenisov/await-inconsistencies
Swift: fix CFG for identity expressions (await, dot_self, parent)
This commit is contained in:
Коммит
6ce7a56b41
|
@ -125,7 +125,9 @@ module Stmts {
|
|||
c instanceof SimpleCompletion
|
||||
}
|
||||
|
||||
predicate firstInner(ControlFlowElement first) { astFirst(ast.getFirstElement(), first) }
|
||||
predicate firstInner(ControlFlowElement first) {
|
||||
astFirst(ast.getFirstElement().getFullyUnresolved(), first)
|
||||
}
|
||||
|
||||
/** Gets the body of the i'th `defer` statement. */
|
||||
private BraceStmt getDeferStmtBody(int i) {
|
||||
|
@ -181,32 +183,32 @@ module Stmts {
|
|||
|
||||
predicate lastInner(ControlFlowElement last, Completion c) {
|
||||
// Normal exit and no defer statements
|
||||
astLast(ast.getLastElement(), last, c) and
|
||||
astLast(ast.getLastElement().getFullyUnresolved(), last, c) and
|
||||
not exists(this.getFirstDeferStmtBody()) and
|
||||
c instanceof NormalCompletion
|
||||
or
|
||||
// Normal exit from the last defer statement to be executed
|
||||
astLast(this.getLastDeferStmtBody(), last, c) and
|
||||
astLast(this.getLastDeferStmtBody().getFullyUnresolved(), last, c) and
|
||||
c instanceof NormalCompletion
|
||||
or
|
||||
// Abnormal exit without any defer statements
|
||||
not c instanceof NormalCompletion and
|
||||
astLast(ast.getAnElement(), last, c) and
|
||||
astLast(ast.getAnElement().getFullyUnresolved(), last, c) and
|
||||
not exists(this.getFirstDeferStmtBody())
|
||||
}
|
||||
|
||||
override predicate succ(ControlFlowElement pred, ControlFlowElement succ, Completion c) {
|
||||
// left-to-right evaluation of statements
|
||||
exists(int i |
|
||||
astLast(ast.getElement(i), pred, c) and
|
||||
astFirst(ast.getElement(i + 1), succ) and
|
||||
astLast(ast.getElement(i).getFullyUnresolved(), pred, c) and
|
||||
astFirst(ast.getElement(i + 1).getFullyUnresolved(), succ) and
|
||||
c instanceof NormalCompletion
|
||||
)
|
||||
or
|
||||
// Flow from last elements to the first defer statement to be executed
|
||||
c instanceof NormalCompletion and
|
||||
astLast(ast.getLastElement(), pred, c) and
|
||||
astFirst(this.getFirstDeferStmtBody(), succ)
|
||||
astLast(ast.getLastElement().getFullyUnresolved(), pred, c) and
|
||||
astFirst(this.getFirstDeferStmtBody().getFullyUnresolved(), succ)
|
||||
or
|
||||
// Flow from a defer statement to the next defer to be executed
|
||||
c instanceof NormalCompletion and
|
||||
|
@ -218,7 +220,7 @@ module Stmts {
|
|||
// Abnormal exit from an element to the first defer statement to be executed.
|
||||
not c instanceof NormalCompletion and
|
||||
exists(int i |
|
||||
astLast(ast.getElement(i), pred, c) and
|
||||
astLast(ast.getElement(i).getFullyUnresolved(), pred, c) and
|
||||
astFirst(this.getDeferStmtBodyAfterStmt(i), succ)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
multipleSuccessors
|
||||
| method_lookups.swift:42:9:42:19 | call to baz(_:) | successor | method_lookups.swift:42:3:42:19 | await ... |
|
||||
| method_lookups.swift:42:9:42:19 | call to baz(_:) | successor | method_lookups.swift:44:7:44:7 | f |
|
||||
| method_lookups.swift:48:9:48:19 | call to foo(_:_:) | successor | method_lookups.swift:48:3:48:19 | await ... |
|
||||
| method_lookups.swift:48:9:48:19 | call to foo(_:_:) | successor | method_lookups.swift:49:9:49:11 | .bar() |
|
||||
| method_lookups.swift:49:9:49:15 | call to bar() | successor | method_lookups.swift:49:3:49:15 | await ... |
|
||||
| method_lookups.swift:49:9:49:15 | call to bar() | successor | method_lookups.swift:50:9:50:13 | .baz(_:) |
|
||||
| method_lookups.swift:50:9:50:19 | call to baz(_:) | successor | method_lookups.swift:50:3:50:19 | await ... |
|
||||
| method_lookups.swift:50:9:50:19 | call to baz(_:) | successor | method_lookups.swift:52:7:52:7 | f |
|
||||
deadEnd
|
||||
| method_lookups.swift:42:3:42:19 | await ... |
|
||||
| method_lookups.swift:48:3:48:19 | await ... |
|
||||
| method_lookups.swift:49:3:49:15 | await ... |
|
||||
| method_lookups.swift:50:3:50:19 | await ... |
|
|
@ -1,17 +0,0 @@
|
|||
multipleSuccessors
|
||||
| methodlookup.swift:37:11:37:30 | call to instanceMethod() | successor | methodlookup.swift:37:5:37:30 | await ... |
|
||||
| methodlookup.swift:37:11:37:30 | call to instanceMethod() | successor | methodlookup.swift:40:5:40:9 | .staticMethod() |
|
||||
| methodlookup.swift:47:11:47:30 | call to instanceMethod() | successor | methodlookup.swift:47:5:47:30 | await ... |
|
||||
| methodlookup.swift:47:11:47:30 | call to instanceMethod() | successor | methodlookup.swift:48:11:48:11 | Baz.Type |
|
||||
| methodlookup.swift:48:11:48:35 | call to { ... } | successor | methodlookup.swift:48:5:48:35 | await ... |
|
||||
| methodlookup.swift:48:11:48:35 | call to { ... } | successor | methodlookup.swift:50:11:50:15 | .classMethod() |
|
||||
| methodlookup.swift:50:11:50:27 | call to classMethod() | successor | methodlookup.swift:50:5:50:27 | await ... |
|
||||
| methodlookup.swift:50:11:50:27 | call to classMethod() | successor | methodlookup.swift:51:11:51:15 | .staticMethod() |
|
||||
| methodlookup.swift:51:11:51:28 | call to staticMethod() | successor | methodlookup.swift:43:6:52:1 | exit { ... } (normal) |
|
||||
| methodlookup.swift:51:11:51:28 | call to staticMethod() | successor | methodlookup.swift:51:5:51:28 | await ... |
|
||||
deadEnd
|
||||
| methodlookup.swift:37:5:37:30 | await ... |
|
||||
| methodlookup.swift:47:5:47:30 | await ... |
|
||||
| methodlookup.swift:48:5:48:35 | await ... |
|
||||
| methodlookup.swift:50:5:50:27 | await ... |
|
||||
| methodlookup.swift:51:5:51:28 | await ... |
|
Загрузка…
Ссылка в новой задаче