Swift: extract BorrowExpr

This commit is contained in:
Alex Denisov
2023-11-13 15:14:24 +01:00
parent d21e27c717
commit 002f2a0985
16 changed files with 150 additions and 27 deletions

View File

@@ -103,11 +103,7 @@ MAP(swift::Expr, ExprTag)
MAP(swift::IdentityExpr, IdentityExprTag)
MAP(swift::ParenExpr, ParenExprTag)
MAP(swift::DotSelfExpr, DotSelfExprTag)
#if CODEQL_SWIFT_VERSION_GE(5, 9)
MAP(swift::BorrowExpr, void) // TODO (introduced in 5.9)
#else
MAP(swift::MoveExpr, void) // TODO (introduced in 5.8, gone in 5.9)
#endif
MAP(swift::BorrowExpr, BorrowExprTag)
MAP(swift::AwaitExpr, AwaitExprTag)
MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
MAP(swift::AnyTryExpr, AnyTryExprTag)

View File

@@ -76,6 +76,8 @@ lib/codeql/swift/elements/expr/AwaitExprConstructor.qll 55f185fe9a656db83807b90d
lib/codeql/swift/elements/expr/BinaryExprConstructor.qll 173dca8da8b4da92f5c45f78c9be0ed2d84fbd36d3471e87c2597f1832033acf 07136c27dcdb35a9cd2587d459a7eea64a6b3c0ad8ce7ffc7bb2cdfe26b6e9bd
lib/codeql/swift/elements/expr/BindOptionalExprConstructor.qll 839b01e4fb4d7a13d5d28f97bdb94ef5e5d645a20e4c46e710066c46baa7d042 d53ece261604bf5909f7afeb57ef1042ef28382ce2bb0c6f9790b3ce1d24749c
lib/codeql/swift/elements/expr/BooleanLiteralExprConstructor.qll 3ef212f498734fc2441ecfde9889164abb430c25fce9871f2dfcdc25114fe670 f9c498db8217ad2184b1fff3d6b0640a4c41b0643ac59cf672d738ba50341059
lib/codeql/swift/elements/expr/BorrowExpr.qll ea59e5dd3fcf85e114c3a24d7405b049f8c63ee19190c40bdfce5ff81489bd35 3e0dca0efab75d6042900de9099fc27ec89a44736bace371e1f7ad05f05daebf
lib/codeql/swift/elements/expr/BorrowExprConstructor.qll d13bd08a048dbb7a83b3882a1f58539f064376e8d96e784d5b4c6f8803aa3be7 8d8d2921ec30fa387a6adcf49f0fff4d8f96444010e36d1819792f5281d54ad7
lib/codeql/swift/elements/expr/BridgeFromObjCExpr.qll b95f6d0cac24cf6c1f84cb904a1f9384c5085d3c97ab0b4b6e2cd1daa35886b6 a374e4f84c2fead34325d71a2fd4aa7289a9210c169ec2fd475c24fec29121d4
lib/codeql/swift/elements/expr/BridgeFromObjCExprConstructor.qll db5793d44c554bab954b7c2458f3ce148ddcfff07c77ca4e0267736fda932042 7261f6ca92d0adc4dbb04d06f7a42956646d782d250d626d3c57fdf1d9ed3d8b
lib/codeql/swift/elements/expr/BridgeToObjCExpr.qll 9bd4eee52d5f1c50cb509814dcb6d458097fb0e813c5450394eb328fc5c99e6f eed912e1f3c0a49c8f6fb449deddd062f347c89336fe69d50837d38a1747e1fa
@@ -381,7 +383,7 @@ lib/codeql/swift/elements/type/UnresolvedTypeConstructor.qll 7f75d489b4d7ce65cae
lib/codeql/swift/elements/type/VariadicSequenceTypeConstructor.qll fc74a5a2a2effa28ef24509b20ee4373d97cf6e8c71840121bb031c6adedf584 c9b2effc1d01c13c5e6a74a111122fa79a2f6554dda3cb016d68ba397e566ec4
lib/codeql/swift/elements/type/WeakStorageType.qll edd13dd97b53040684409e187c1f975bcada6807c919e1345d8977144dbebb6f 9434c044d264a7f5f503a6422c106c9b8fedf74aaae314174473a29ea6ed17b9
lib/codeql/swift/elements/type/WeakStorageTypeConstructor.qll 5fdce3716aba6318522174a2c455a63480970222ae81c732fb19c6dd3ae2d271 60ea79d6943e129deba0deccb566cf9d73f78398b0f7f0212674d91287d6b2ae
lib/codeql/swift/elements.qll 55d216f8dfeae9871c08ed202b737be068182376870ea18a0f78adb4d035f365 55d216f8dfeae9871c08ed202b737be068182376870ea18a0f78adb4d035f365
lib/codeql/swift/elements.qll a3e46884bac3428bdec439ba97c65a69fea02e30b074b585f8db378844215fe3 a3e46884bac3428bdec439ba97c65a69fea02e30b074b585f8db378844215fe3
lib/codeql/swift/generated/AstNode.qll e00d6a46b16891778531a73722ae0b5842f849328e24aebe88bc30ac9fe438c2 40eaa0072d3ffecbff48d2baf88111daa86ef0f937abf24f032f2495739ef661
lib/codeql/swift/generated/AvailabilityInfo.qll e90fbfc3ec6830390e12a4695698d6efd8da4fa6a8a4189f466489a6dd103586 d9545da9e5d0c160679a4147001b4b1c664d9cb85ae1a169dd639c35046d274d
lib/codeql/swift/generated/AvailabilitySpec.qll 469bbd39d38dc68f1f6fb2e0766cc25b2f813c804fec44962910d5f7777632a2 57a953a8d5cf7031283393af1b3cfbc7f5941c9062e77950b32e5b5c6ae6b191
@@ -397,12 +399,12 @@ lib/codeql/swift/generated/KeyPathComponent.qll 55629a20538d7e8f4f4d4c7484e8bcfd
lib/codeql/swift/generated/Locatable.qll 41f040643ea146c8044be49fddea89bdd79efd2469617c863a4b2da0b1af3364 9a964dcbc7f5ffce2ee006ce0c9a9a99a988976fcd0446af2ba1b202911d7396
lib/codeql/swift/generated/Location.qll 5b37ecde83a871ef2089cf33e4743fc02d9cf8c676aafd9f157c59ffdb776d6b 076d8d3d2313931e8287d196854acf259700124d9c8bc591a6d36017f314260a
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 31f3667ab0dc5f93230ba876b4101898d2a5a4af306925082305eff3ad9c9c0e 31f3667ab0dc5f93230ba876b4101898d2a5a4af306925082305eff3ad9c9c0e
lib/codeql/swift/generated/ParentChild.qll 5cf57f71329d520286af1434bdc7549ee9e657f0ca66da15379e4974ced1b1b6 66829a7cb8c7e2657e7db86eabea7495418884b4c7d77bebdc814fc481fe4d24
lib/codeql/swift/generated/ParentChild.qll a00f7eecdc91d98ad421c6d883bf2cc6e92c213befdcc494bf8ad25f2c5d4ae2 cd2c70e5940a302108319bdc16d25f49df3165be5b94fa825b64b9b5771f117d
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll 3483726f6db9d978e40db75068d6a9ecad8f7c06516157fce783b26424bea729 864fedf2901de91f662a6d75a2eb7e26ed1a2a1a875a2b3c4e699dc7e7c4605e
lib/codeql/swift/generated/PureSynthConstructors.qll 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229
lib/codeql/swift/generated/Raw.qll fe51a0a1ba7ecae3338b3f776e5586a0f661083463cfc82c1884ef4971f7763c 65d637456c70a7b01b43301d7b9a19a4b35c53dbe6b792829bcb8d02b00a32e7
lib/codeql/swift/generated/Synth.qll 76e5b9ba4df278843acb8b513ce5796c28b8fdc89234c879c2a124c2a768b2e4 0d5076c1c4dad9bb4e2d5e13e8e62ddef96756f8fc5c028d7cc634d84c1da80b
lib/codeql/swift/generated/SynthConstructors.qll 1e03d6bb048432db4cd701cac70389307d64faf81eab6fa996c2107cac78075a 1e03d6bb048432db4cd701cac70389307d64faf81eab6fa996c2107cac78075a
lib/codeql/swift/generated/Raw.qll f15f0b35be65adb8027e17b5fd5478eabb5000ee887dafc5c40d8abd03ced3e3 75fc6fbb74e0720b736c13ec3627247c49f8201df929647cdb2985282abf23c1
lib/codeql/swift/generated/Synth.qll 93565d0244a9f5bf4ba3f19a0ffabef4b8dc48703c580b905ffeac716eea5445 74d977cfe6fbb3d90579dc45b40254549e686d91eb16999c9e69fec18ab7df28
lib/codeql/swift/generated/SynthConstructors.qll fbbf618c54843d86b4c38d7b27e12cce7661b49ce52573f791dd8fcb4bbd40f5 fbbf618c54843d86b4c38d7b27e12cce7661b49ce52573f791dd8fcb4bbd40f5
lib/codeql/swift/generated/UnknownFile.qll 5922b351b55d5becac0c1ad67b8d601bcc9499dce9ee4093b607101e7e299104 5922b351b55d5becac0c1ad67b8d601bcc9499dce9ee4093b607101e7e299104
lib/codeql/swift/generated/UnknownLocation.qll 67b8605ff5aaa0f3a8588fee2527eba5ec4e322562159c9af3d53486b7954ee9 67b8605ff5aaa0f3a8588fee2527eba5ec4e322562159c9af3d53486b7954ee9
lib/codeql/swift/generated/UnspecifiedElement.qll 01182fee4d5c86b551e89c79d0d645f5e85c0aeeeae9dcafcbd7721c3eb3cc14 cb95ab2b13da080ada10e0a3bd1b00577541c4bfe699cbd19ef45f1e00e7c651
@@ -463,6 +465,7 @@ lib/codeql/swift/generated/expr/AwaitExpr.qll 2fb54f4de6373f22ac33419d6d7c00914d
lib/codeql/swift/generated/expr/BinaryExpr.qll 3433ad4dc31b214e5eb4a8fc090000bded1cf07be7e779f9217f01518ace586f 3433ad4dc31b214e5eb4a8fc090000bded1cf07be7e779f9217f01518ace586f
lib/codeql/swift/generated/expr/BindOptionalExpr.qll 5d264f01c894ad5fe2bb3dbd2dcbac27d491e45678c1e85db686b50db691cf2e 7368a23160ddeb2f8d133579e8e990fe6cb47789e41b3461df3e5f66d855f6da
lib/codeql/swift/generated/expr/BooleanLiteralExpr.qll 6fc5314867f201e899199cf3289d0daa853bf49fd0e4300d8f3ee7ea05b0dd20 4355b2e49c2d7c9bb66094dd8f56bd112fbabb3fe2111b1ff7ec6d64333c8978
lib/codeql/swift/generated/expr/BorrowExpr.qll a46b7417349e85f8000300029af7003cb064300345fc87194d95d0a27019d901 6ccb224e19a237b3146df600c040a50998db40c03b410568f9b590f3d52f10dd
lib/codeql/swift/generated/expr/BridgeFromObjCExpr.qll 502efff92732eea47660679c29ff4ee2f79089edd570a8298352fdbb809e378d 502efff92732eea47660679c29ff4ee2f79089edd570a8298352fdbb809e378d
lib/codeql/swift/generated/expr/BridgeToObjCExpr.qll f46fe1dc0c39b471f3acde26e719cbfabe816075ad32b5a7090ec94f6ae2ed39 f46fe1dc0c39b471f3acde26e719cbfabe816075ad32b5a7090ec94f6ae2ed39
lib/codeql/swift/generated/expr/BuiltinLiteralExpr.qll e73fc5a38f0681543b9386fa523039de094b1550ff07c279bd60e1c3f6f243d0 03395da16415155096d7b01fe69a7d1cd27929481f7639cb927ffac1f4ba42e7

3
swift/ql/.gitattributes generated vendored
View File

@@ -78,6 +78,8 @@
/lib/codeql/swift/elements/expr/BinaryExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BindOptionalExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BooleanLiteralExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BorrowExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/BorrowExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeFromObjCExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeFromObjCExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeToObjCExpr.qll linguist-generated
@@ -465,6 +467,7 @@
/lib/codeql/swift/generated/expr/BinaryExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BindOptionalExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BooleanLiteralExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BorrowExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BridgeFromObjCExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BridgeToObjCExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BuiltinLiteralExpr.qll linguist-generated

View File

@@ -78,6 +78,7 @@ import codeql.swift.elements.expr.AwaitExpr
import codeql.swift.elements.expr.BinaryExpr
import codeql.swift.elements.expr.BindOptionalExpr
import codeql.swift.elements.expr.BooleanLiteralExpr
import codeql.swift.elements.expr.BorrowExpr
import codeql.swift.elements.expr.BridgeFromObjCExpr
import codeql.swift.elements.expr.BridgeToObjCExpr
import codeql.swift.elements.expr.BuiltinLiteralExpr

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `BorrowExpr`.
*/
private import codeql.swift.generated.expr.BorrowExpr
class BorrowExpr extends Generated::BorrowExpr { }

View File

@@ -0,0 +1,14 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module defines the hook used internally to tweak the characteristic predicate of
* `BorrowExpr` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `BorrowExpr` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructBorrowExpr(Raw::BorrowExpr id) { any() }

View File

@@ -2175,6 +2175,20 @@ private module Impl {
)
}
private Element getImmediateChildOfBorrowExpr(BorrowExpr e, int index, string partialPredicateCall) {
exists(int b, int bIdentityExpr, int n |
b = 0 and
bIdentityExpr =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and
n = bIdentityExpr and
(
none()
or
result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfBridgeFromObjCExpr(
BridgeFromObjCExpr e, int index, string partialPredicateCall
) {
@@ -5210,6 +5224,8 @@ private module Impl {
or
result = getImmediateChildOfBinaryExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBorrowExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBridgeFromObjCExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBridgeToObjCExpr(e, index, partialAccessor)

View File

@@ -1879,6 +1879,19 @@ module Raw {
override string toString() { result = "BinaryExpr" }
}
/**
* INTERNAL: Do not use.
* An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
*
* ```
* let y = ...
* let x = _borrow y
* ```
*/
class BorrowExpr extends @borrow_expr, IdentityExpr {
override string toString() { result = "BorrowExpr" }
}
/**
* INTERNAL: Do not use.
*/

View File

@@ -235,6 +235,10 @@ module Synth {
* INTERNAL: Do not use.
*/
TBooleanLiteralExpr(Raw::BooleanLiteralExpr id) { constructBooleanLiteralExpr(id) } or
/**
* INTERNAL: Do not use.
*/
TBorrowExpr(Raw::BorrowExpr id) { constructBorrowExpr(id) } or
/**
* INTERNAL: Do not use.
*/
@@ -1221,7 +1225,7 @@ module Synth {
* INTERNAL: Do not use.
*/
class TIdentityExpr =
TAwaitExpr or TDotSelfExpr or TParenExpr or TUnresolvedMemberChainResultExpr;
TAwaitExpr or TBorrowExpr or TDotSelfExpr or TParenExpr or TUnresolvedMemberChainResultExpr;
/**
* INTERNAL: Do not use.
@@ -1795,6 +1799,13 @@ module Synth {
result = TBooleanLiteralExpr(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBorrowExpr`, if possible.
*/
cached
TBorrowExpr convertBorrowExprFromRaw(Raw::Element e) { result = TBorrowExpr(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBridgeFromObjCExpr`, if possible.
@@ -3825,6 +3836,8 @@ module Synth {
TIdentityExpr convertIdentityExprFromRaw(Raw::Element e) {
result = convertAwaitExprFromRaw(e)
or
result = convertBorrowExprFromRaw(e)
or
result = convertDotSelfExprFromRaw(e)
or
result = convertParenExprFromRaw(e)
@@ -4711,6 +4724,13 @@ module Synth {
e = TBooleanLiteralExpr(result)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBorrowExpr` to a raw DB element, if possible.
*/
cached
Raw::Element convertBorrowExprToRaw(TBorrowExpr e) { e = TBorrowExpr(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBridgeFromObjCExpr` to a raw DB element, if possible.
@@ -6739,6 +6759,8 @@ module Synth {
Raw::Element convertIdentityExprToRaw(TIdentityExpr e) {
result = convertAwaitExprToRaw(e)
or
result = convertBorrowExprToRaw(e)
or
result = convertDotSelfExprToRaw(e)
or
result = convertParenExprToRaw(e)

View File

@@ -55,6 +55,7 @@ import codeql.swift.elements.expr.AwaitExprConstructor
import codeql.swift.elements.expr.BinaryExprConstructor
import codeql.swift.elements.expr.BindOptionalExprConstructor
import codeql.swift.elements.expr.BooleanLiteralExprConstructor
import codeql.swift.elements.expr.BorrowExprConstructor
import codeql.swift.elements.expr.BridgeFromObjCExprConstructor
import codeql.swift.elements.expr.BridgeToObjCExprConstructor
import codeql.swift.elements.expr.CallExprConstructor

View File

@@ -0,0 +1,25 @@
// generated by codegen/codegen.py
/**
* This module provides the generated definition of `BorrowExpr`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.IdentityExpr
module Generated {
/**
* An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
*
* ```
* let y = ...
* let x = _borrow y
* ```
* INTERNAL: Do not reference the `Generated::BorrowExpr` class directly.
* Use the subclass `BorrowExpr`, where the following predicates are available.
*/
class BorrowExpr extends Synth::TBorrowExpr, IdentityExpr {
override string getAPrimaryQlClass() { result = "BorrowExpr" }
}
}

View File

@@ -958,6 +958,7 @@ force_value_exprs( //dir=expr
@identity_expr =
@await_expr
| @borrow_expr
| @dot_self_expr
| @paren_expr
| @unresolved_member_chain_result_expr
@@ -1292,6 +1293,10 @@ binary_exprs( //dir=expr
unique int id: @binary_expr
);
borrow_exprs( //dir=expr
unique int id: @borrow_expr
);
bridge_from_obj_c_exprs( //dir=expr
unique int id: @bridge_from_obj_c_expr
);

View File

@@ -1,8 +1,9 @@
| identity_expressions.swift:4:9:4:14 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:9:4:9 | self |
| identity_expressions.swift:4:9:4:21 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:9:4:19 | .x |
| identity_expressions.swift:4:28:4:31 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:29:4:29 | 42 |
| identity_expressions.swift:8:5:8:9 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:8:6:8:8 | call to A.init() |
| identity_expressions.swift:11:28:11:43 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:11:29:11:42 | await ... |
| identity_expressions.swift:11:29:11:42 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:11:35:11:42 | call to create() |
| identity_expressions.swift:14:5:14:21 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:14:11:14:21 | call to process() |
| identity_expressions.swift:14:11:14:19 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:14:12:14:12 | process() |
| identity_expressions.swift:5:9:5:14 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:9:5:9 | self |
| identity_expressions.swift:5:9:5:21 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:9:5:19 | .x |
| identity_expressions.swift:5:28:5:31 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:29:5:29 | 42 |
| identity_expressions.swift:9:5:9:9 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:9:6:9:8 | call to A.init() |
| identity_expressions.swift:12:28:12:43 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:12:29:12:42 | await ... |
| identity_expressions.swift:12:29:12:42 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:12:35:12:42 | call to create() |
| identity_expressions.swift:15:5:15:21 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:15:11:15:21 | call to process() |
| identity_expressions.swift:15:11:15:19 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:15:12:15:12 | process() |
| identity_expressions.swift:18:9:18:17 | BorrowExpr | BorrowExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:18:17:18:17 | x |

View File

@@ -1,8 +1,9 @@
| identity_expressions.swift:4:9:4:14 | .self | A |
| identity_expressions.swift:4:9:4:21 | .self | @lvalue Int |
| identity_expressions.swift:4:28:4:31 | (...) | (Int) |
| identity_expressions.swift:8:5:8:9 | (...) | (A) |
| identity_expressions.swift:11:28:11:43 | (...) | (A) |
| identity_expressions.swift:11:29:11:42 | await ... | A |
| identity_expressions.swift:14:5:14:21 | await ... | () |
| identity_expressions.swift:14:11:14:19 | (...) | (() async -> ()) |
| identity_expressions.swift:5:9:5:14 | .self | A |
| identity_expressions.swift:5:9:5:21 | .self | @lvalue Int |
| identity_expressions.swift:5:28:5:31 | (...) | (Int) |
| identity_expressions.swift:9:5:9:9 | (...) | (A) |
| identity_expressions.swift:12:28:12:43 | (...) | (A) |
| identity_expressions.swift:12:29:12:42 | await ... | A |
| identity_expressions.swift:15:5:15:21 | await ... | () |
| identity_expressions.swift:15:11:15:19 | (...) | (() async -> ()) |
| identity_expressions.swift:18:9:18:17 | BorrowExpr | Int |

View File

@@ -1,3 +1,4 @@
//codeql-extractor-options: -enable-experimental-move-only
class A {
var x: Int
init() {
@@ -13,3 +14,5 @@ func process() async { _ = (await create())}
Task.init {
await (process)()
}
let x = 42
let _ = _borrow x

View File

@@ -1350,3 +1350,14 @@ class ConsumeExpr(Expr):
```
"""
sub_expr: Expr | child
class BorrowExpr(IdentityExpr):
"""
An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
```
let y = ...
let x = _borrow y
```
"""
pass