Skip to content

Commit 776a296

Browse files
authored
Swift: extract isInOut for parameters
1 parent 4a02505 commit 776a296

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

swift/codegen/schema.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ ConcreteVarDecl:
11031103

11041104
ParamDecl:
11051105
_extends: VarDecl
1106+
is_inout: predicate
11061107

11071108
AssociatedTypeDecl:
11081109
_extends: AbstractTypeParamDecl

swift/extractor/visitors/DeclVisitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
6666
void visitParamDecl(swift::ParamDecl* decl) {
6767
auto label = dispatcher_.assignNewLabel(decl);
6868
dispatcher_.emit(ParamDeclsTrap{label});
69+
if (decl->isInOut()) {
70+
dispatcher_.emit(ParamDeclIsInoutTrap{label});
71+
}
6972
emitVarDecl(decl, label);
7073
}
7174

swift/ql/lib/codeql/swift/generated/decl/ParamDecl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ import codeql.swift.elements.decl.VarDecl
33

44
class ParamDeclBase extends @param_decl, VarDecl {
55
override string getAPrimaryQlClass() { result = "ParamDecl" }
6+
7+
predicate isInout() { param_decl_is_inout(this) }
68
}

swift/ql/lib/swift.dbscheme

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,11 @@ param_decls(
20622062
unique int id: @param_decl
20632063
);
20642064

2065+
#keyset[id]
2066+
param_decl_is_inout(
2067+
int id: @param_decl ref
2068+
);
2069+
20652070
associated_type_decls(
20662071
unique int id: @associated_type_decl
20672072
);

0 commit comments

Comments
 (0)