Skip to content

Commit b364647

Browse files
committed
Swift: add stubs for new exprs
1 parent d937234 commit b364647

File tree

15 files changed

+128
-3
lines changed

15 files changed

+128
-3
lines changed

swift/codegen/schema.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ OtherConstructorDeclRefExpr:
543543
OverloadSetRefExpr:
544544
_extends: Expr
545545

546+
PackExpr:
547+
_extends: Expr
548+
546549
PropertyWrapperValuePlaceholderExpr:
547550
_extends: Expr
548551

@@ -552,6 +555,9 @@ RebindSelfInConstructorExpr:
552555
sub_expr: Expr
553556
self: VarDecl
554557

558+
ReifyPackExpr:
559+
_extends: ImplicitConversionExpr
560+
555561
SequenceExpr:
556562
_extends: Expr
557563
_children:

swift/ql/lib/codeql/swift/elements.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ import codeql.swift.elements.expr.OptionalTryExpr
150150
import codeql.swift.elements.expr.OtherConstructorDeclRefExpr
151151
import codeql.swift.elements.expr.OverloadSetRefExpr
152152
import codeql.swift.elements.expr.OverloadedDeclRefExpr
153+
import codeql.swift.elements.expr.PackExpr
153154
import codeql.swift.elements.expr.ParenExpr
154155
import codeql.swift.elements.expr.PointerToPointerExpr
155156
import codeql.swift.elements.expr.PostfixUnaryExpr
@@ -158,6 +159,7 @@ import codeql.swift.elements.expr.PropertyWrapperValuePlaceholderExpr
158159
import codeql.swift.elements.expr.ProtocolMetatypeToObjectExpr
159160
import codeql.swift.elements.expr.RebindSelfInConstructorExpr
160161
import codeql.swift.elements.expr.RegexLiteralExpr
162+
import codeql.swift.elements.expr.ReifyPackExpr
161163
import codeql.swift.elements.expr.SelfApplyExpr
162164
import codeql.swift.elements.expr.SequenceExpr
163165
import codeql.swift.elements.expr.StringLiteralExpr
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.expr.PackExpr
3+
4+
class PackExpr extends PackExprBase { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.Raw
3+
4+
predicate constructPackExpr(Raw::PackExpr id) { any() }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.expr.ReifyPackExpr
3+
4+
class ReifyPackExpr extends ReifyPackExprBase { }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
2+
private import codeql.swift.generated.Raw
3+
4+
predicate constructReifyPackExpr(Raw::ReifyPackExpr id) { any() }

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,19 @@ private module Impl {
15741574
)
15751575
}
15761576

1577+
private Element getImmediateChildOfPackExpr(PackExpr e, int index, string partialPredicateCall) {
1578+
exists(int b, int bExpr, int n |
1579+
b = 0 and
1580+
bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and
1581+
n = bExpr and
1582+
(
1583+
none()
1584+
or
1585+
result = getImmediateChildOfExpr(e, index - b, partialPredicateCall)
1586+
)
1587+
)
1588+
}
1589+
15771590
private Element getImmediateChildOfPropertyWrapperValuePlaceholderExpr(
15781591
PropertyWrapperValuePlaceholderExpr e, int index, string partialPredicateCall
15791592
) {
@@ -2681,6 +2694,23 @@ private module Impl {
26812694
)
26822695
}
26832696

2697+
private Element getImmediateChildOfReifyPackExpr(
2698+
ReifyPackExpr e, int index, string partialPredicateCall
2699+
) {
2700+
exists(int b, int bImplicitConversionExpr, int n |
2701+
b = 0 and
2702+
bImplicitConversionExpr =
2703+
b + 1 +
2704+
max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and
2705+
n = bImplicitConversionExpr and
2706+
(
2707+
none()
2708+
or
2709+
result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall)
2710+
)
2711+
)
2712+
}
2713+
26842714
private Element getImmediateChildOfSelfApplyExpr(
26852715
SelfApplyExpr e, int index, string partialPredicateCall
26862716
) {
@@ -4957,6 +4987,8 @@ private module Impl {
49574987
or
49584988
result = getImmediateChildOfOtherConstructorDeclRefExpr(e, index, partialAccessor)
49594989
or
4990+
result = getImmediateChildOfPackExpr(e, index, partialAccessor)
4991+
or
49604992
result = getImmediateChildOfPropertyWrapperValuePlaceholderExpr(e, index, partialAccessor)
49614993
or
49624994
result = getImmediateChildOfRebindSelfInConstructorExpr(e, index, partialAccessor)
@@ -5081,6 +5113,8 @@ private module Impl {
50815113
or
50825114
result = getImmediateChildOfRegexLiteralExpr(e, index, partialAccessor)
50835115
or
5116+
result = getImmediateChildOfReifyPackExpr(e, index, partialAccessor)
5117+
or
50845118
result = getImmediateChildOfStringToPointerExpr(e, index, partialAccessor)
50855119
or
50865120
result = getImmediateChildOfSubscriptExpr(e, index, partialAccessor)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ module Raw {
517517

518518
class OverloadSetRefExpr extends @overload_set_ref_expr, Expr { }
519519

520+
class PackExpr extends @pack_expr, Expr {
521+
override string toString() { result = "PackExpr" }
522+
}
523+
520524
class PropertyWrapperValuePlaceholderExpr extends @property_wrapper_value_placeholder_expr, Expr {
521525
override string toString() { result = "PropertyWrapperValuePlaceholderExpr" }
522526
}
@@ -838,6 +842,10 @@ module Raw {
838842
override string toString() { result = "RegexLiteralExpr" }
839843
}
840844

845+
class ReifyPackExpr extends @reify_pack_expr, ImplicitConversionExpr {
846+
override string toString() { result = "ReifyPackExpr" }
847+
}
848+
841849
class SelfApplyExpr extends @self_apply_expr, ApplyExpr {
842850
Expr getBase() { self_apply_exprs(this, result) }
843851
}

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ module Synth {
157157
constructOtherConstructorDeclRefExpr(id)
158158
} or
159159
TOverloadedDeclRefExpr(Raw::OverloadedDeclRefExpr id) { constructOverloadedDeclRefExpr(id) } or
160+
TPackExpr(Raw::PackExpr id) { constructPackExpr(id) } or
160161
TParenExpr(Raw::ParenExpr id) { constructParenExpr(id) } or
161162
TPointerToPointerExpr(Raw::PointerToPointerExpr id) { constructPointerToPointerExpr(id) } or
162163
TPostfixUnaryExpr(Raw::PostfixUnaryExpr id) { constructPostfixUnaryExpr(id) } or
@@ -171,6 +172,7 @@ module Synth {
171172
constructRebindSelfInConstructorExpr(id)
172173
} or
173174
TRegexLiteralExpr(Raw::RegexLiteralExpr id) { constructRegexLiteralExpr(id) } or
175+
TReifyPackExpr(Raw::ReifyPackExpr id) { constructReifyPackExpr(id) } or
174176
TSequenceExpr(Raw::SequenceExpr id) { constructSequenceExpr(id) } or
175177
TStringLiteralExpr(Raw::StringLiteralExpr id) { constructStringLiteralExpr(id) } or
176178
TStringToPointerExpr(Raw::StringToPointerExpr id) { constructStringToPointerExpr(id) } or
@@ -385,7 +387,7 @@ module Synth {
385387
TKeyPathDotExpr or TKeyPathExpr or TLazyInitializerExpr or TLiteralExpr or TLookupExpr or
386388
TMakeTemporarilyEscapableExpr or TObjCSelectorExpr or TOneWayExpr or TOpaqueValueExpr or
387389
TOpenExistentialExpr or TOptionalEvaluationExpr or TOtherConstructorDeclRefExpr or
388-
TOverloadSetRefExpr or TPropertyWrapperValuePlaceholderExpr or
390+
TOverloadSetRefExpr or TPackExpr or TPropertyWrapperValuePlaceholderExpr or
389391
TRebindSelfInConstructorExpr or TSequenceExpr or TSuperRefExpr or TTapExpr or
390392
TTupleElementExpr or TTupleExpr or TTypeExpr or TUnresolvedDeclRefExpr or
391393
TUnresolvedDotExpr or TUnresolvedMemberExpr or TUnresolvedPatternExpr or
@@ -405,8 +407,9 @@ module Synth {
405407
TFunctionConversionExpr or TInOutToPointerExpr or TInjectIntoOptionalExpr or
406408
TLinearFunctionExpr or TLinearFunctionExtractOriginalExpr or
407409
TLinearToDifferentiableFunctionExpr or TLoadExpr or TMetatypeConversionExpr or
408-
TPointerToPointerExpr or TProtocolMetatypeToObjectExpr or TStringToPointerExpr or
409-
TUnderlyingToOpaqueExpr or TUnevaluatedInstanceExpr or TUnresolvedTypeConversionExpr;
410+
TPointerToPointerExpr or TProtocolMetatypeToObjectExpr or TReifyPackExpr or
411+
TStringToPointerExpr or TUnderlyingToOpaqueExpr or TUnevaluatedInstanceExpr or
412+
TUnresolvedTypeConversionExpr;
410413

411414
class TLiteralExpr =
412415
TBuiltinLiteralExpr or TInterpolatedStringLiteralExpr or TNilLiteralExpr or
@@ -942,6 +945,9 @@ module Synth {
942945
result = TOverloadedDeclRefExpr(e)
943946
}
944947

948+
cached
949+
TPackExpr convertPackExprFromRaw(Raw::Element e) { result = TPackExpr(e) }
950+
945951
cached
946952
TParenExpr convertParenExprFromRaw(Raw::Element e) { result = TParenExpr(e) }
947953

@@ -976,6 +982,9 @@ module Synth {
976982
cached
977983
TRegexLiteralExpr convertRegexLiteralExprFromRaw(Raw::Element e) { result = TRegexLiteralExpr(e) }
978984

985+
cached
986+
TReifyPackExpr convertReifyPackExprFromRaw(Raw::Element e) { result = TReifyPackExpr(e) }
987+
979988
cached
980989
TSequenceExpr convertSequenceExprFromRaw(Raw::Element e) { result = TSequenceExpr(e) }
981990

@@ -1759,6 +1768,8 @@ module Synth {
17591768
or
17601769
result = convertOverloadSetRefExprFromRaw(e)
17611770
or
1771+
result = convertPackExprFromRaw(e)
1772+
or
17621773
result = convertPropertyWrapperValuePlaceholderExprFromRaw(e)
17631774
or
17641775
result = convertRebindSelfInConstructorExprFromRaw(e)
@@ -1855,6 +1866,8 @@ module Synth {
18551866
or
18561867
result = convertProtocolMetatypeToObjectExprFromRaw(e)
18571868
or
1869+
result = convertReifyPackExprFromRaw(e)
1870+
or
18581871
result = convertStringToPointerExprFromRaw(e)
18591872
or
18601873
result = convertUnderlyingToOpaqueExprFromRaw(e)
@@ -2630,6 +2643,9 @@ module Synth {
26302643
e = TOverloadedDeclRefExpr(result)
26312644
}
26322645

2646+
cached
2647+
Raw::Element convertPackExprToRaw(TPackExpr e) { e = TPackExpr(result) }
2648+
26332649
cached
26342650
Raw::Element convertParenExprToRaw(TParenExpr e) { e = TParenExpr(result) }
26352651

@@ -2664,6 +2680,9 @@ module Synth {
26642680
cached
26652681
Raw::Element convertRegexLiteralExprToRaw(TRegexLiteralExpr e) { e = TRegexLiteralExpr(result) }
26662682

2683+
cached
2684+
Raw::Element convertReifyPackExprToRaw(TReifyPackExpr e) { e = TReifyPackExpr(result) }
2685+
26672686
cached
26682687
Raw::Element convertSequenceExprToRaw(TSequenceExpr e) { e = TSequenceExpr(result) }
26692688

@@ -3447,6 +3466,8 @@ module Synth {
34473466
or
34483467
result = convertOverloadSetRefExprToRaw(e)
34493468
or
3469+
result = convertPackExprToRaw(e)
3470+
or
34503471
result = convertPropertyWrapperValuePlaceholderExprToRaw(e)
34513472
or
34523473
result = convertRebindSelfInConstructorExprToRaw(e)
@@ -3543,6 +3564,8 @@ module Synth {
35433564
or
35443565
result = convertProtocolMetatypeToObjectExprToRaw(e)
35453566
or
3567+
result = convertReifyPackExprToRaw(e)
3568+
or
35463569
result = convertStringToPointerExprToRaw(e)
35473570
or
35483571
result = convertUnderlyingToOpaqueExprToRaw(e)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import codeql.swift.elements.expr.OptionalEvaluationExprConstructor
113113
import codeql.swift.elements.expr.OptionalTryExprConstructor
114114
import codeql.swift.elements.expr.OtherConstructorDeclRefExprConstructor
115115
import codeql.swift.elements.expr.OverloadedDeclRefExprConstructor
116+
import codeql.swift.elements.expr.PackExprConstructor
116117
import codeql.swift.elements.expr.ParenExprConstructor
117118
import codeql.swift.elements.expr.PointerToPointerExprConstructor
118119
import codeql.swift.elements.expr.PostfixUnaryExprConstructor
@@ -121,6 +122,7 @@ import codeql.swift.elements.expr.PropertyWrapperValuePlaceholderExprConstructor
121122
import codeql.swift.elements.expr.ProtocolMetatypeToObjectExprConstructor
122123
import codeql.swift.elements.expr.RebindSelfInConstructorExprConstructor
123124
import codeql.swift.elements.expr.RegexLiteralExprConstructor
125+
import codeql.swift.elements.expr.ReifyPackExprConstructor
124126
import codeql.swift.elements.expr.SequenceExprConstructor
125127
import codeql.swift.elements.expr.StringLiteralExprConstructor
126128
import codeql.swift.elements.expr.StringToPointerExprConstructor

0 commit comments

Comments
 (0)