mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: make result a child in ThenStmt
This commit is contained in:
2
swift/ql/.generated.list
generated
2
swift/ql/.generated.list
generated
@@ -409,7 +409,7 @@ lib/codeql/swift/generated/Locatable.qll 6cb437dd7ff7331429ec6586b0af50b1af15e4f
|
||||
lib/codeql/swift/generated/Location.qll 3f3bad413be87d05a596fe7b8004f415c2caa98cb759021a6aad20b589b7d700 ed30ed646962b3ffb6b47c97c6434fe47a6b1ea8e3f2e0589577bea5cf96c88e
|
||||
lib/codeql/swift/generated/MacroRole.qll aaf5631c49de81e046854955341202d6d3516713cd09bc2e7b870e40c261cc9f 6cd17d40cbf1d8fa4ef01dfb8b3462b7cee902e6058fb76417c2035be12481d1
|
||||
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 06393a08e8da36106c5ec6efb9f1bd56a5c7b3d3f3d0bcefc6fa07fa96860c31 06393a08e8da36106c5ec6efb9f1bd56a5c7b3d3f3d0bcefc6fa07fa96860c31
|
||||
lib/codeql/swift/generated/ParentChild.qll 2489604e46253d81d7f8e3a8f0a7905481e5b2811d5016794ce5b66846cec22e f10627c078437dc9b8ce98d2a1559e660f86e2aea1d42feac1a79f2e68eeae8a
|
||||
lib/codeql/swift/generated/ParentChild.qll eae164aa8a78e883e707fba6c671ff2cd0ddab1084b0871fc5ae27c44cded4c5 3af88b63e21d58090f9702e6e4716a5b8a5a65897b8c92362b6e3c0fba60ddc2
|
||||
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll 5355be9da8b778d1d8ae60d25d9c3394477da24f94e8a6ab4484c6a16d07cd7c 075438c1762ec0a7775004b39032dcf85aada038a4269e6f428c34b8282786e9
|
||||
lib/codeql/swift/generated/PureSynthConstructors.qll 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229
|
||||
lib/codeql/swift/generated/Raw.qll 10633b948918d315b98b6ff6733d4c368e082c5afd78334c0862291f9d883216 66abde4c9a2283773033d90a4633c1203d6563fc238ddbd48fdf1b910f90021a
|
||||
|
||||
@@ -3781,14 +3781,17 @@ private module Impl {
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfThenStmt(ThenStmt e, int index, string partialPredicateCall) {
|
||||
exists(int b, int bStmt, int n |
|
||||
exists(int b, int bStmt, int n, int nResult |
|
||||
b = 0 and
|
||||
bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and
|
||||
n = bStmt and
|
||||
nResult = n + 1 and
|
||||
(
|
||||
none()
|
||||
or
|
||||
result = getImmediateChildOfStmt(e, index - b, partialPredicateCall)
|
||||
or
|
||||
index = n and result = e.getImmediateResult() and partialPredicateCall = "Result()"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3476,8 +3476,75 @@ cfg.swift:
|
||||
# 577| getBase(): [CallExpr] call to getMyProtocolImpl()
|
||||
# 577| getFunction(): [DeclRefExpr] getMyProtocolImpl()
|
||||
# 577| getMethodRef(): [DeclRefExpr] source()
|
||||
# 580| [Comment] // ---
|
||||
# 580|
|
||||
# 580| [NamedFunction] singleStmtExpr(_:)
|
||||
# 580| InterfaceType = (Int) -> ()
|
||||
# 580| getParam(0): [ParamDecl] x
|
||||
# 580| Type = Int
|
||||
# 580| getBody(): [BraceStmt] { ... }
|
||||
# 581| getVariable(0): [ConcreteVarDecl] a
|
||||
# 581| Type = Int
|
||||
# 585| getVariable(1): [ConcreteVarDecl] b
|
||||
# 585| Type = Int
|
||||
# 581| getElement(0): [PatternBindingDecl] var ... = ...
|
||||
# 581| getInit(0): [SingleValueStmtExpr] SingleValueStmtExpr
|
||||
# 581| getStmt(): [SwitchStmt] switch x { ... }
|
||||
# 581| getExpr(): [DeclRefExpr] x
|
||||
# 582| getCase(0): [CaseStmt] case ...
|
||||
# 582| getLabel(0): [CaseLabelItem] =~ ...
|
||||
# 582| getPattern(): [ExprPattern] =~ ...
|
||||
# 582| getSubExpr(): [BinaryExpr] ... .~=(_:_:) ...
|
||||
# 582| getFunction(): [MethodLookupExpr] .~=(_:_:)
|
||||
# 582| getBase(): [TypeExpr] Range<Int>.Type
|
||||
# 582| getTypeRepr(): [TypeRepr] Range<Int>
|
||||
# 582| getMethodRef(): [DeclRefExpr] ~=(_:_:)
|
||||
# 582| getArgument(0): [Argument] : ... ...<(_:_:) ...
|
||||
# 582| getExpr(): [BinaryExpr] ... ...<(_:_:) ...
|
||||
# 582| getFunction(): [MethodLookupExpr] ...<(_:_:)
|
||||
# 582| getBase(): [TypeExpr] Int.Type
|
||||
# 582| getTypeRepr(): [TypeRepr] Int
|
||||
# 582| getMethodRef(): [DeclRefExpr] ..<(_:_:)
|
||||
# 582| getArgument(0): [Argument] : 0
|
||||
# 582| getExpr(): [IntegerLiteralExpr] 0
|
||||
# 582| getArgument(1): [Argument] : 5
|
||||
# 582| getExpr(): [IntegerLiteralExpr] 5
|
||||
# 582| getArgument(1): [Argument] : $match
|
||||
# 582| getExpr(): [DeclRefExpr] $match
|
||||
# 582| getBody(): [BraceStmt] { ... }
|
||||
# 582| getElement(0): [ThenStmt] ThenStmt
|
||||
# 582| getResult(): [IntegerLiteralExpr] 1
|
||||
# 583| getCase(1): [CaseStmt] case ...
|
||||
# 583| getLabel(0): [CaseLabelItem] _
|
||||
# 583| getPattern(): [AnyPattern] _
|
||||
# 583| getBody(): [BraceStmt] { ... }
|
||||
# 583| getElement(0): [ThenStmt] ThenStmt
|
||||
# 583| getResult(): [IntegerLiteralExpr] 2
|
||||
# 581| getPattern(0): [NamedPattern] a
|
||||
# 585| getElement(1): [PatternBindingDecl] var ... = ...
|
||||
# 585| getInit(0): [SingleValueStmtExpr] SingleValueStmtExpr
|
||||
# 585| getStmt(): [IfStmt] if ... then { ... } else { ... }
|
||||
# 585| getCondition(): [StmtCondition] StmtCondition
|
||||
# 585| getElement(0): [ConditionElement] ... .<(_:_:) ...
|
||||
# 585| getBoolean(): [BinaryExpr] ... .<(_:_:) ...
|
||||
# 585| getFunction(): [MethodLookupExpr] .<(_:_:)
|
||||
# 585| getBase(): [TypeExpr] Int.Type
|
||||
# 585| getTypeRepr(): [TypeRepr] Int
|
||||
# 585| getMethodRef(): [DeclRefExpr] <(_:_:)
|
||||
# 585| getArgument(0): [Argument] : x
|
||||
# 585| getExpr(): [DeclRefExpr] x
|
||||
# 585| getArgument(1): [Argument] : 42
|
||||
# 585| getExpr(): [IntegerLiteralExpr] 42
|
||||
# 585| getBoolean().getFullyConverted(): [ParenExpr] (...)
|
||||
# 585| getThen(): [BraceStmt] { ... }
|
||||
# 585| getElement(0): [ThenStmt] ThenStmt
|
||||
# 585| getResult(): [IntegerLiteralExpr] 1
|
||||
# 585| getElse(): [BraceStmt] { ... }
|
||||
# 585| getElement(0): [ThenStmt] ThenStmt
|
||||
# 585| getResult(): [IntegerLiteralExpr] 2
|
||||
# 585| getPattern(0): [NamedPattern] b
|
||||
# 582| [ConcreteVarDecl] $match
|
||||
# 582| Type = Int
|
||||
# 587| [Comment] // ---
|
||||
# 587|
|
||||
declarations.swift:
|
||||
# 1| [StructDecl] Foo
|
||||
# 2| getMember(0): [PatternBindingDecl] var ... = ...
|
||||
|
||||
@@ -577,4 +577,11 @@ func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) {
|
||||
sink(arg: getMyProtocolImpl().source())
|
||||
}
|
||||
|
||||
func singleStmtExpr(_ x: Int) {
|
||||
let a = switch x {
|
||||
case 0..<5: 1
|
||||
default: 2
|
||||
}
|
||||
let b = if (x < 42) { 1 } else { 2 }
|
||||
}
|
||||
// ---
|
||||
|
||||
@@ -1006,7 +1006,7 @@ class ThenStmt(Stmt):
|
||||
```
|
||||
the literal expressions `1`, `2` and `3` are wrapped in `ThenStmt`.
|
||||
"""
|
||||
result: Expr
|
||||
result: Expr | child
|
||||
|
||||
class DoCatchStmt(LabeledStmt):
|
||||
body: Stmt | child
|
||||
|
||||
Reference in New Issue
Block a user