Skip to content

Commit d00fec3

Browse files
authored
Merge pull request #9336 from MathiasVP/swift-decls-in-cfg
Swift: CFG for local declarations
2 parents e03646a + 4356155 commit d00fec3

File tree

3 files changed

+448
-105
lines changed

3 files changed

+448
-105
lines changed

swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,37 @@ module Decls {
946946
}
947947
}
948948

949+
/**
950+
* The control-flow of a type declaration. This is necessary to skip past local type
951+
* declarations that occur inside bodies like in:
952+
* ```swift
953+
* func foo() -> Int {
954+
* let x = 42
955+
* class C {}
956+
* return x
957+
* }
958+
* ```
959+
*/
960+
private class TypeDeclTree extends AstLeafTree {
961+
override TypeDecl ast;
962+
}
963+
964+
/**
965+
* The control-flow of a function declaration. This is necessary to skip past local function
966+
* declarations that occur inside bodies like in:
967+
* ```swift
968+
* func foo() -> Int {
969+
* let x = 42
970+
* func bar() { ... }
971+
* return x
972+
* }
973+
* ```
974+
*/
975+
private class AbstractFunctionDeclTree extends AstLeafTree {
976+
override AbstractFunctionDecl ast;
977+
}
978+
979+
/** The control-flow of a function declaration body. */
949980
class FuncDeclTree extends StandardPreOrderTree, TFuncDeclElement {
950981
AbstractFunctionDecl ast;
951982

0 commit comments

Comments
 (0)