Skip to content

Commit 9311733

Browse files
committed
Swift: extract missing cases of AccessorKind and AccessSemantics
This resolves the warnings that were showing up during extractor-pack compilation.
1 parent 36e7235 commit 9311733

File tree

11 files changed

+159
-30
lines changed

11 files changed

+159
-30
lines changed

swift/extractor/translators/DeclTranslator.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ std::optional<codeql::AccessorDecl> DeclTranslator::translateAccessorDecl(
231231
case swift::AccessorKind::DidSet:
232232
entry->is_did_set = true;
233233
break;
234+
case swift::AccessorKind::Read:
235+
entry->is_read = true;
236+
break;
237+
case swift::AccessorKind::Modify:
238+
entry->is_modify = true;
239+
break;
240+
case swift::AccessorKind::Address:
241+
entry->is_unsafe_address = true;
242+
break;
243+
case swift::AccessorKind::MutableAddress:
244+
entry->is_unsafe_mutable_address = true;
245+
break;
234246
}
235247
fillAbstractFunctionDecl(decl, *entry);
236248
return entry;

swift/extractor/translators/ExprTranslator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ void ExprTranslator::fillAccessorSemantics(const T& ast, TrapClassOf<T>& entry)
1616
case swift::AccessSemantics::Ordinary:
1717
entry.has_ordinary_semantics = true;
1818
break;
19+
case swift::AccessSemantics::DistributedThunk:
20+
entry.has_distributed_thunk_semantics = true;
21+
break;
1922
}
2023
}
2124

swift/ql/lib/codeql/swift/generated/Raw.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ module Raw {
261261
predicate isWillSet() { accessor_decl_is_will_set(this) }
262262

263263
predicate isDidSet() { accessor_decl_is_did_set(this) }
264+
265+
predicate isRead() { accessor_decl_is_read(this) }
266+
267+
predicate isModify() { accessor_decl_is_modify(this) }
268+
269+
predicate isUnsafeAddress() { accessor_decl_is_unsafe_address(this) }
270+
271+
predicate isUnsafeMutableAddress() { accessor_decl_is_unsafe_mutable_address(this) }
264272
}
265273

266274
class AssociatedTypeDecl extends @associated_type_decl, AbstractTypeParamDecl {
@@ -403,6 +411,8 @@ module Raw {
403411
}
404412

405413
predicate hasOrdinarySemantics() { decl_ref_expr_has_ordinary_semantics(this) }
414+
415+
predicate hasDistributedThunkSemantics() { decl_ref_expr_has_distributed_thunk_semantics(this) }
406416
}
407417

408418
class DefaultArgumentExpr extends @default_argument_expr, Expr {
@@ -851,6 +861,10 @@ module Raw {
851861
}
852862

853863
predicate hasOrdinarySemantics() { member_ref_expr_has_ordinary_semantics(this) }
864+
865+
predicate hasDistributedThunkSemantics() {
866+
member_ref_expr_has_distributed_thunk_semantics(this)
867+
}
854868
}
855869

856870
class MetatypeConversionExpr extends @metatype_conversion_expr, ImplicitConversionExpr {
@@ -918,6 +932,10 @@ module Raw {
918932
}
919933

920934
predicate hasOrdinarySemantics() { subscript_expr_has_ordinary_semantics(this) }
935+
936+
predicate hasDistributedThunkSemantics() {
937+
subscript_expr_has_distributed_thunk_semantics(this)
938+
}
921939
}
922940

923941
class TryExpr extends @try_expr, AnyTryExpr {

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,29 @@ module Generated {
2626
* Holds if this accessor is a `didSet`, called after the property is set.
2727
*/
2828
predicate isDidSet() { Synth::convertAccessorDeclToRaw(this).(Raw::AccessorDecl).isDidSet() }
29+
30+
/**
31+
* Holds if this accessor is a `_read` coroutine, yielding a borrowed value of the property.
32+
*/
33+
predicate isRead() { Synth::convertAccessorDeclToRaw(this).(Raw::AccessorDecl).isRead() }
34+
35+
/**
36+
* Holds if this accessor is a `_modify` coroutine, yielding an inout value of the property.
37+
*/
38+
predicate isModify() { Synth::convertAccessorDeclToRaw(this).(Raw::AccessorDecl).isModify() }
39+
40+
/**
41+
* Holds if this accessor is an `unsafeAddress` immutable addressor.
42+
*/
43+
predicate isUnsafeAddress() {
44+
Synth::convertAccessorDeclToRaw(this).(Raw::AccessorDecl).isUnsafeAddress()
45+
}
46+
47+
/**
48+
* Holds if this accessor is an `unsafeMutableAddress` mutable addressor.
49+
*/
50+
predicate isUnsafeMutableAddress() {
51+
Synth::convertAccessorDeclToRaw(this).(Raw::AccessorDecl).isUnsafeMutableAddress()
52+
}
2953
}
3054
}

swift/ql/lib/codeql/swift/generated/expr/DeclRefExpr.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,12 @@ module Generated {
7575
predicate hasOrdinarySemantics() {
7676
Synth::convertDeclRefExprToRaw(this).(Raw::DeclRefExpr).hasOrdinarySemantics()
7777
}
78+
79+
/**
80+
* Holds if this declaration ref expression has distributed thunk semantics.
81+
*/
82+
predicate hasDistributedThunkSemantics() {
83+
Synth::convertDeclRefExprToRaw(this).(Raw::DeclRefExpr).hasDistributedThunkSemantics()
84+
}
7885
}
7986
}

swift/ql/lib/codeql/swift/generated/expr/MemberRefExpr.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ module Generated {
2929
predicate hasOrdinarySemantics() {
3030
Synth::convertMemberRefExprToRaw(this).(Raw::MemberRefExpr).hasOrdinarySemantics()
3131
}
32+
33+
/**
34+
* Holds if this member ref expression has distributed thunk semantics.
35+
*/
36+
predicate hasDistributedThunkSemantics() {
37+
Synth::convertMemberRefExprToRaw(this).(Raw::MemberRefExpr).hasDistributedThunkSemantics()
38+
}
3239
}
3340
}

swift/ql/lib/codeql/swift/generated/expr/SubscriptExpr.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@ module Generated {
5858
predicate hasOrdinarySemantics() {
5959
Synth::convertSubscriptExprToRaw(this).(Raw::SubscriptExpr).hasOrdinarySemantics()
6060
}
61+
62+
/**
63+
* Holds if this subscript expression has distributed thunk semantics.
64+
*/
65+
predicate hasDistributedThunkSemantics() {
66+
Synth::convertSubscriptExprToRaw(this).(Raw::SubscriptExpr).hasDistributedThunkSemantics()
67+
}
6168
}
6269
}

swift/ql/lib/swift.dbscheme

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,26 @@ accessor_decl_is_did_set( //dir=decl
524524
int id: @accessor_decl ref
525525
);
526526

527+
#keyset[id]
528+
accessor_decl_is_read( //dir=decl
529+
int id: @accessor_decl ref
530+
);
531+
532+
#keyset[id]
533+
accessor_decl_is_modify( //dir=decl
534+
int id: @accessor_decl ref
535+
);
536+
537+
#keyset[id]
538+
accessor_decl_is_unsafe_address( //dir=decl
539+
int id: @accessor_decl ref
540+
);
541+
542+
#keyset[id]
543+
accessor_decl_is_unsafe_mutable_address( //dir=decl
544+
int id: @accessor_decl ref
545+
);
546+
527547
associated_type_decls( //dir=decl
528548
unique int id: @associated_type_decl
529549
);
@@ -771,6 +791,11 @@ decl_ref_expr_has_ordinary_semantics( //dir=expr
771791
int id: @decl_ref_expr ref
772792
);
773793

794+
#keyset[id]
795+
decl_ref_expr_has_distributed_thunk_semantics( //dir=expr
796+
int id: @decl_ref_expr ref
797+
);
798+
774799
default_argument_exprs( //dir=expr
775800
unique int id: @default_argument_expr,
776801
int param_decl: @param_decl_or_none ref,
@@ -1319,6 +1344,11 @@ member_ref_expr_has_ordinary_semantics( //dir=expr
13191344
int id: @member_ref_expr ref
13201345
);
13211346

1347+
#keyset[id]
1348+
member_ref_expr_has_distributed_thunk_semantics( //dir=expr
1349+
int id: @member_ref_expr ref
1350+
);
1351+
13221352
metatype_conversion_exprs( //dir=expr
13231353
unique int id: @metatype_conversion_expr
13241354
);
@@ -1408,6 +1438,11 @@ subscript_expr_has_ordinary_semantics( //dir=expr
14081438
int id: @subscript_expr ref
14091439
);
14101440

1441+
#keyset[id]
1442+
subscript_expr_has_distributed_thunk_semantics( //dir=expr
1443+
int id: @subscript_expr ref
1444+
);
1445+
14111446
try_exprs( //dir=expr
14121447
unique int id: @try_expr
14131448
);

0 commit comments

Comments
 (0)