Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,7 @@ module Stmts {
astLast(ast.getACatch().getBody(), last, c)
or
// We failed to match on any of the clauses.
// TODO: This can actually only happen if the enclosing function is marked with 'throws'.
// So we could make this more precise.
ast.getEnclosingFunction().isThrowing() and
astLast(ast.getLastCatch(), last, c) and
c = any(MatchingCompletion mc | not mc.isMatch())
}
Expand Down
15 changes: 14 additions & 1 deletion swift/ql/lib/codeql/swift/elements/decl/Function.qll
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
private import swift
private import codeql.swift.generated.decl.Function
private import codeql.swift.elements.decl.Method

/**
* A function.
*/
class Function extends Generated::Function, Callable {
override string toString() { result = this.getName() }

/**
* Holds if this is a throwing function.
*
* For example, this function is a throwing function:
*
* ```swift
* func myFunc() throws -> String {
* // ...
* }
* ```
*/
predicate isThrowing() { this.getInterfaceType().(AnyFunctionType).isThrowing() }
}

/**
Expand Down