зеркало из https://github.com/github/codeql.git
Swift: extract MaterizliePackExpr
This commit is contained in:
Родитель
cca05e0a82
Коммит
5cd74213cc
|
@ -199,7 +199,7 @@ MAP(swift::Expr, ExprTag)
|
|||
MAP(swift::MacroExpansionExpr, void) // unexpanded macro in an expr context, skipping
|
||||
MAP(swift::CopyExpr, CopyExprTag)
|
||||
MAP(swift::ConsumeExpr, ConsumeExprTag)
|
||||
MAP(swift::MaterializePackExpr, void) // TODO (introduced in 5.9)
|
||||
MAP(swift::MaterializePackExpr, MaterializePackExprTag)
|
||||
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
|
||||
|
||||
MAP(swift::Decl, DeclTag)
|
||||
|
|
|
@ -669,4 +669,11 @@ codeql::ConsumeExpr ExprTranslator::translateConsumeExpr(const swift::ConsumeExp
|
|||
return entry;
|
||||
}
|
||||
|
||||
codeql::MaterializePackExpr ExprTranslator::translateMaterializePackExpr(
|
||||
const swift::MaterializePackExpr& expr) {
|
||||
auto entry = createExprEntry(expr);
|
||||
entry.sub_expr = dispatcher.fetchLabel(expr.getFromExpr());
|
||||
return entry;
|
||||
}
|
||||
|
||||
} // namespace codeql
|
||||
|
|
|
@ -124,6 +124,7 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
|
|||
codeql::PackElementExpr translatePackElementExpr(const swift::PackElementExpr& expr);
|
||||
codeql::CopyExpr translateCopyExpr(const swift::CopyExpr& expr);
|
||||
codeql::ConsumeExpr translateConsumeExpr(const swift::ConsumeExpr& expr);
|
||||
codeql::MaterializePackExpr translateMaterializePackExpr(const swift::MaterializePackExpr& expr);
|
||||
|
||||
private:
|
||||
void fillClosureExpr(const swift::AbstractClosureExpr& expr, codeql::ClosureExpr& entry);
|
||||
|
|
|
@ -170,6 +170,8 @@ lib/codeql/swift/elements/expr/LoadExprConstructor.qll 56727367026e84469b8ee2e0b
|
|||
lib/codeql/swift/elements/expr/LookupExpr.qll 7fb2fa23233abcd1f2cf4cdde60d6db13e31d41bf3f77cdbed6c2e46a2a0408b 553ce4073d2aaf13e92fac564bef631f77f11a79ec626d74182cf95e02ff9a55
|
||||
lib/codeql/swift/elements/expr/MagicIdentifierLiteralExprConstructor.qll fa4ec214889913ebfc5f3e987245905285ae2d6a399e153b087dd5528efac68c 95980be351868456adbafc6c7a78be83f3c7d5ed2305f6ee1a2e6b6ce72bcec6
|
||||
lib/codeql/swift/elements/expr/MakeTemporarilyEscapableExprConstructor.qll 9bb400af8070add0fc981abd35908c5a73790f9c003a32b0e8b02b9032a1530f 93944b8b4f1b89e3bf89fed13593c2def22d5fbcf74aaf18a0fa83c620706f11
|
||||
lib/codeql/swift/elements/expr/MaterializePackExpr.qll 31d679e86efb6488114a6b53c594d6be75b3eb431ec172f5f6b93e7b7aa4f2b0 1607775f840452d1cc4e0c9b1460c95b6f686867a295fdc27eeb0b6cd99121ce
|
||||
lib/codeql/swift/elements/expr/MaterializePackExprConstructor.qll ef8e1f20d5ef63bfe0c8e53657e3e2c7ff29c4601d956b3e2ccfc7b0b0a8bd09 dad7e4fc171c733bf5e547f1ba1a2028986bef52c5f7a3990ba5335d15f113ae
|
||||
lib/codeql/swift/elements/expr/MemberRefExprConstructor.qll 3ce4c9f3be7cb01f63b835047ad2fff025004fd88b84d6855b8dc61ec9c79e8b d79da455bea22a1ec236e8b11eac3620ef6049620e26ac0585b4c1cd223adeb4
|
||||
lib/codeql/swift/elements/expr/MetatypeConversionExpr.qll 89f9314c791beca8b0c3f8da79afd535cfeee64ae917e73e9adfcd66af0c8d89 02802318fb288960e2af184778e187e1401e34755be878dae1f97871c0849e49
|
||||
lib/codeql/swift/elements/expr/MetatypeConversionExprConstructor.qll b69711c629d43a53a1eec3b299a6fb5a60e5eb71d751694e89a42fc5b18acf5f 851eda459f0c53c7c83af68a1b2b6946e94a60b13ba54ee674657a32514dad20
|
||||
|
@ -386,7 +388,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 34a49e70c33620aae14b9370dc6fdc702fbf292c206d9ebfaa23c8e7680480df 34a49e70c33620aae14b9370dc6fdc702fbf292c206d9ebfaa23c8e7680480df
|
||||
lib/codeql/swift/elements.qll 16d27aa2184e864cca9da089068935b393c1ab08f2ad33a64ebe3f7f3c223636 16d27aa2184e864cca9da089068935b393c1ab08f2ad33a64ebe3f7f3c223636
|
||||
lib/codeql/swift/generated/AstNode.qll 68877daa9e14b462247ac6b7b724f5e683288e39953a8ebb02a362b7d1df8e4c 54d3512744738e1ee15645f3af116437053cb5209687f4106361a1943b38b666
|
||||
lib/codeql/swift/generated/AvailabilityInfo.qll e74e218a1ab00416cb8823610ff93642101aa784aa61cbc2b4deef61471a5bac e2c6c19860dc3e6e211041c95d8e6d52c3505ccff7018b80a849735cc98141af
|
||||
lib/codeql/swift/generated/AvailabilitySpec.qll a8afc5071887a67b4e0dec27356ab8cbf3e176b5358cb34c785e3015b2cad5a2 c7f88b0d701612c821359c983b3102f31b23edc211c3dcfe97de5adec61af386
|
||||
|
@ -403,12 +405,12 @@ 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 fffa8748471139e0143521443cb7bf566db136f932e80e1917e7ab7140389835 c7768c3ad33fb1934b7b8955d09fe1d2978187e8d1f59a9ba0595f5bcb884d2d
|
||||
lib/codeql/swift/generated/ParentChild.qll d0702695f17a129d51546ca7a4f8d2cc53e5b2ce1525a48ee1182b852f1935a5 c37d5ec2c208797db3698fa676cadce5f825a86ff38c0f803fcf500b0bfb57bb
|
||||
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll 5355be9da8b778d1d8ae60d25d9c3394477da24f94e8a6ab4484c6a16d07cd7c 075438c1762ec0a7775004b39032dcf85aada038a4269e6f428c34b8282786e9
|
||||
lib/codeql/swift/generated/PureSynthConstructors.qll 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229
|
||||
lib/codeql/swift/generated/Raw.qll 31fc7cb2d45a8699447116df6bd3ddaa9b630d437d7a898b8054371a7bc92f6e b997210dccad7802e3ba9326d803eed61aa9fc6748f9e04d8184fde5d1cba63c
|
||||
lib/codeql/swift/generated/Synth.qll 62abfaec75a308f222d8a7b8bb3260a1226977c253e87dbf9fc74f6e35398f53 c45d3237d9bdfb11d0372a5a1997d794a94a7eeeba3938d234bbbf802dacd9ad
|
||||
lib/codeql/swift/generated/SynthConstructors.qll 73604e68bac553fe06b52aa768cd5f876b3cf85ee88bca96f7e2e4db76ef997f 73604e68bac553fe06b52aa768cd5f876b3cf85ee88bca96f7e2e4db76ef997f
|
||||
lib/codeql/swift/generated/Raw.qll 18d26216cf811999fb3fd0025af22fbbbcb49047eb9a4f470e75a04d955ee962 8b80c9395b95efaa0c66a9e81f78570749c3e429b0d867af45a49be2f0b19823
|
||||
lib/codeql/swift/generated/Synth.qll 7a34f9ad85123dabf2d3be871d4936287b8683f11169731ca43c5cefa358f388 690ac3af3e3e149504313aaa34a6f21bf36860733c3b468f53a893fa0f95633a
|
||||
lib/codeql/swift/generated/SynthConstructors.qll 5959cd4a3fc672015ee9956e63cded1dce7093308c2ad25bd090f0e0c690ed11 5959cd4a3fc672015ee9956e63cded1dce7093308c2ad25bd090f0e0c690ed11
|
||||
lib/codeql/swift/generated/UnknownFile.qll 5325944cf96a72d5d224597745e15960fb6a9448b96b6644ececd6344dfd9d74 5325944cf96a72d5d224597745e15960fb6a9448b96b6644ececd6344dfd9d74
|
||||
lib/codeql/swift/generated/UnknownLocation.qll dfdeb8eedb2564eccaac416695784ea04fe9754a3e109e8484c695021af4e554 dfdeb8eedb2564eccaac416695784ea04fe9754a3e109e8484c695021af4e554
|
||||
lib/codeql/swift/generated/UnspecifiedElement.qll 8ecc275cc131fe5aa61052299e10c49c3718f96416df9eeacabf5aea34d97982 b02dfcf0df3859551b176e065291da943670ab4da6ed84d02a0861ff689001c6
|
||||
|
@ -538,6 +540,7 @@ lib/codeql/swift/generated/expr/LoadExpr.qll 9265a4f06e272480e283461b258469c5b36
|
|||
lib/codeql/swift/generated/expr/LookupExpr.qll 5b208bcdd29ba178792577407bcb23d4eb4d2fcdfbc3a3bc30c0b941af66afa9 2c527bc4532d1dc6fc2cae5ac6c1f0ec2fe995e8b6fc14ca84c71cc6da795d99
|
||||
lib/codeql/swift/generated/expr/MagicIdentifierLiteralExpr.qll 6d546bab38827f6ddeef37f7673c407c477a5078c2896f31267b35089faef4d2 3ed3c377d0b00cbbc6651e73b55a136f37f0775a214677d27e7897217a62d70b
|
||||
lib/codeql/swift/generated/expr/MakeTemporarilyEscapableExpr.qll 7b47ab5ae1fb0e8e3358772d9859a78b50a71b1bf0169d44a456525dfa52edba 888ac156f58271997aea04f4f446078fe53110dd77fc27c206837e096fa8c1b5
|
||||
lib/codeql/swift/generated/expr/MaterializePackExpr.qll 4b83978e6b057b2184e80080a8492cc755261034939dc85dee62ab83cca86aca bcde91f0de245aae9c7b56c4d09680c3415725bc1713447ec9d395554488e8de
|
||||
lib/codeql/swift/generated/expr/MemberRefExpr.qll 10649102fc1fa0f4dd2b55be1f39a7829122326a4aff721689d627ea09b57668 2058f2a9e45393ed090b824e30b93d46f173b2e6cb658dded9f859ba233e88fc
|
||||
lib/codeql/swift/generated/expr/MetatypeConversionExpr.qll 7f9b6fbe2f323db1a42060b3de13a08b2076520755cea3fb789cbca1afd9042c 7f9b6fbe2f323db1a42060b3de13a08b2076520755cea3fb789cbca1afd9042c
|
||||
lib/codeql/swift/generated/expr/MethodLookupExpr.qll ddf900d711863aae63d886f64b3b3442000a600c810fd8742da2f9dcab90e2c4 1bb1e033a7969f562a83b827790e6b27b39ae5180bf3e4e35ca9c9388a244ffd
|
||||
|
@ -875,6 +878,8 @@ test/extractor-tests/generated/expr/OpenExistentialExpr/OpenExistentialExpr_getT
|
|||
test/extractor-tests/generated/expr/OptionalEvaluationExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
|
||||
test/extractor-tests/generated/expr/OptionalTryExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
|
||||
test/extractor-tests/generated/expr/OtherInitializerRefExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
|
||||
test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr.ql e7629f03e4235d911a186cec0861f782d8f2f67e5662df07fe9ea0757d69fe47 2dc23a2280fc993b08770fd4212f6f279a3dbd8bb9b9a64bce1eefde48b3e7df
|
||||
test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr_getType.ql cd2313750edc2f21ee5e811f4c207da538a3975d544d8ab6c8daae2684992db3 808769558d857e55d32b57253f29bdf0a98f4835eeea3b6eb0f3485c469f3891
|
||||
test/extractor-tests/generated/expr/PackExpansionExpr/PackElementExpr.ql cd0a90689c84e4c0b0ed0b2175e269d9f7b3cc5ec37dc6dc8911000561b40d9d 7f505eca22c08b51af8f0b3722e4cfb5359d5b85f152845c6ee8049cbd0b8708
|
||||
test/extractor-tests/generated/expr/PackExpansionExpr/PackElementExpr_getType.ql 44fd25a08560015c6657bf345d945ada3c22eb661685c48132e246302d2f7a3d 8b2ac56ea6943fa87da59ca4c3bc0ef3cbf2690c263277b3583dcf9032a1edcc
|
||||
test/extractor-tests/generated/expr/PackExpansionExpr/PackExpansionExpr.ql e6d88ab4016e070f620396d9a66b601761bf44182dc3691b8ca362475abecf2b f740b618d2daae07da25ee4c8618c0dabbf806c9c48aa71c9d342da14d98b4f9
|
||||
|
|
|
@ -172,6 +172,8 @@
|
|||
/lib/codeql/swift/elements/expr/LookupExpr.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MagicIdentifierLiteralExprConstructor.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MakeTemporarilyEscapableExprConstructor.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MaterializePackExpr.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MaterializePackExprConstructor.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MemberRefExprConstructor.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MetatypeConversionExpr.qll linguist-generated
|
||||
/lib/codeql/swift/elements/expr/MetatypeConversionExprConstructor.qll linguist-generated
|
||||
|
@ -540,6 +542,7 @@
|
|||
/lib/codeql/swift/generated/expr/LookupExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MagicIdentifierLiteralExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MakeTemporarilyEscapableExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MaterializePackExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MemberRefExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MetatypeConversionExpr.qll linguist-generated
|
||||
/lib/codeql/swift/generated/expr/MethodLookupExpr.qll linguist-generated
|
||||
|
@ -877,6 +880,8 @@
|
|||
/test/extractor-tests/generated/expr/OptionalEvaluationExpr/MISSING_SOURCE.txt linguist-generated
|
||||
/test/extractor-tests/generated/expr/OptionalTryExpr/MISSING_SOURCE.txt linguist-generated
|
||||
/test/extractor-tests/generated/expr/OtherInitializerRefExpr/MISSING_SOURCE.txt linguist-generated
|
||||
/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr.ql linguist-generated
|
||||
/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr_getType.ql linguist-generated
|
||||
/test/extractor-tests/generated/expr/PackExpansionExpr/PackElementExpr.ql linguist-generated
|
||||
/test/extractor-tests/generated/expr/PackExpansionExpr/PackElementExpr_getType.ql linguist-generated
|
||||
/test/extractor-tests/generated/expr/PackExpansionExpr/PackExpansionExpr.ql linguist-generated
|
||||
|
|
|
@ -1444,6 +1444,14 @@ module Exprs {
|
|||
}
|
||||
}
|
||||
|
||||
private class MaterializePackExprTree extends AstStandardPostOrderTree {
|
||||
override MaterializePackExpr ast;
|
||||
|
||||
final override ControlFlowElement getChildElement(int i) {
|
||||
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
|
||||
}
|
||||
}
|
||||
|
||||
/** Control-flow for Move Semantics. See the QLDoc for `CopyExpr` for details. */
|
||||
private class CopyExprTree extends AstStandardPostOrderTree {
|
||||
override CopyExpr ast;
|
||||
|
|
|
@ -146,6 +146,7 @@ import codeql.swift.elements.expr.LoadExpr
|
|||
import codeql.swift.elements.expr.LookupExpr
|
||||
import codeql.swift.elements.expr.MagicIdentifierLiteralExpr
|
||||
import codeql.swift.elements.expr.MakeTemporarilyEscapableExpr
|
||||
import codeql.swift.elements.expr.MaterializePackExpr
|
||||
import codeql.swift.elements.expr.MemberRefExpr
|
||||
import codeql.swift.elements.expr.MetatypeConversionExpr
|
||||
import codeql.swift.elements.expr.MethodLookupExpr
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// 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 `MaterializePackExpr`.
|
||||
*/
|
||||
|
||||
private import codeql.swift.generated.expr.MaterializePackExpr
|
||||
|
||||
/**
|
||||
* An expression that materializes a pack during expansion. Appears around PackExpansionExpr.
|
||||
*
|
||||
* More details:
|
||||
* https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
|
||||
*/
|
||||
class MaterializePackExpr extends Generated::MaterializePackExpr { }
|
14
swift/ql/lib/codeql/swift/elements/expr/MaterializePackExprConstructor.qll
сгенерированный
Normal file
14
swift/ql/lib/codeql/swift/elements/expr/MaterializePackExprConstructor.qll
сгенерированный
Normal 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
|
||||
* `MaterializePackExpr` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
||||
private import codeql.swift.generated.Raw
|
||||
|
||||
/**
|
||||
* The characteristic predicate of `MaterializePackExpr` synthesized instances.
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
predicate constructMaterializePackExpr(Raw::MaterializePackExpr id) { any() }
|
|
@ -1639,6 +1639,24 @@ private module Impl {
|
|||
)
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfMaterializePackExpr(
|
||||
MaterializePackExpr e, int index, string partialPredicateCall
|
||||
) {
|
||||
exists(int b, int bExpr, int n, int nSubExpr |
|
||||
b = 0 and
|
||||
bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and
|
||||
n = bExpr and
|
||||
nSubExpr = n + 1 and
|
||||
(
|
||||
none()
|
||||
or
|
||||
result = getImmediateChildOfExpr(e, index - b, partialPredicateCall)
|
||||
or
|
||||
index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private Element getImmediateChildOfObjCSelectorExpr(
|
||||
ObjCSelectorExpr e, int index, string partialPredicateCall
|
||||
) {
|
||||
|
@ -5196,6 +5214,8 @@ private module Impl {
|
|||
or
|
||||
result = getImmediateChildOfMakeTemporarilyEscapableExpr(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfMaterializePackExpr(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfObjCSelectorExpr(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfOneWayExpr(e, index, partialAccessor)
|
||||
|
|
|
@ -1508,6 +1508,22 @@ module Raw {
|
|||
Expr getSubExpr() { make_temporarily_escapable_exprs(this, _, _, result) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* An expression that materializes a pack during expansion. Appears around PackExpansionExpr.
|
||||
*
|
||||
* More details:
|
||||
* https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
|
||||
*/
|
||||
class MaterializePackExpr extends @materialize_pack_expr, Expr {
|
||||
override string toString() { result = "MaterializePackExpr" }
|
||||
|
||||
/**
|
||||
* Gets the sub expression of this materialize pack expression.
|
||||
*/
|
||||
Expr getSubExpr() { materialize_pack_exprs(this, result) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
|
|
@ -503,6 +503,10 @@ module Synth {
|
|||
TMakeTemporarilyEscapableExpr(Raw::MakeTemporarilyEscapableExpr id) {
|
||||
constructMakeTemporarilyEscapableExpr(id)
|
||||
} or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
TMaterializePackExpr(Raw::MaterializePackExpr id) { constructMaterializePackExpr(id) } or
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
*/
|
||||
|
@ -1223,13 +1227,14 @@ module Synth {
|
|||
TExplicitCastExpr or TForceValueExpr or TIdentityExpr or TIfExpr or
|
||||
TImplicitConversionExpr or TInOutExpr or TKeyPathApplicationExpr or TKeyPathDotExpr or
|
||||
TKeyPathExpr or TLazyInitializationExpr or TLiteralExpr or TLookupExpr or
|
||||
TMakeTemporarilyEscapableExpr or TObjCSelectorExpr or TOneWayExpr or TOpaqueValueExpr or
|
||||
TOpenExistentialExpr or TOptionalEvaluationExpr or TOtherInitializerRefExpr or
|
||||
TOverloadedDeclRefExpr or TPackElementExpr or TPackExpansionExpr or
|
||||
TPropertyWrapperValuePlaceholderExpr or TRebindSelfInInitializerExpr or TSequenceExpr or
|
||||
TSingleValueStmtExpr or TSuperRefExpr or TTapExpr or TTupleElementExpr or TTupleExpr or
|
||||
TTypeExpr or TUnresolvedDeclRefExpr or TUnresolvedDotExpr or TUnresolvedMemberExpr or
|
||||
TUnresolvedPatternExpr or TUnresolvedSpecializeExpr or TVarargExpansionExpr;
|
||||
TMakeTemporarilyEscapableExpr or TMaterializePackExpr or TObjCSelectorExpr or TOneWayExpr or
|
||||
TOpaqueValueExpr or TOpenExistentialExpr or TOptionalEvaluationExpr or
|
||||
TOtherInitializerRefExpr or TOverloadedDeclRefExpr or TPackElementExpr or
|
||||
TPackExpansionExpr or TPropertyWrapperValuePlaceholderExpr or
|
||||
TRebindSelfInInitializerExpr or TSequenceExpr or TSingleValueStmtExpr or TSuperRefExpr or
|
||||
TTapExpr or TTupleElementExpr or TTupleExpr or TTypeExpr or TUnresolvedDeclRefExpr or
|
||||
TUnresolvedDotExpr or TUnresolvedMemberExpr or TUnresolvedPatternExpr or
|
||||
TUnresolvedSpecializeExpr or TVarargExpansionExpr;
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
|
@ -2294,6 +2299,15 @@ module Synth {
|
|||
result = TMakeTemporarilyEscapableExpr(e)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TMaterializePackExpr`, if possible.
|
||||
*/
|
||||
cached
|
||||
TMaterializePackExpr convertMaterializePackExprFromRaw(Raw::Element e) {
|
||||
result = TMaterializePackExpr(e)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a raw element to a synthesized `TMemberRefExpr`, if possible.
|
||||
|
@ -3809,6 +3823,8 @@ module Synth {
|
|||
or
|
||||
result = convertMakeTemporarilyEscapableExprFromRaw(e)
|
||||
or
|
||||
result = convertMaterializePackExprFromRaw(e)
|
||||
or
|
||||
result = convertObjCSelectorExprFromRaw(e)
|
||||
or
|
||||
result = convertOneWayExprFromRaw(e)
|
||||
|
@ -5237,6 +5253,15 @@ module Synth {
|
|||
e = TMakeTemporarilyEscapableExpr(result)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TMaterializePackExpr` to a raw DB element, if possible.
|
||||
*/
|
||||
cached
|
||||
Raw::Element convertMaterializePackExprToRaw(TMaterializePackExpr e) {
|
||||
e = TMaterializePackExpr(result)
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* Converts a synthesized `TMemberRefExpr` to a raw DB element, if possible.
|
||||
|
@ -6752,6 +6777,8 @@ module Synth {
|
|||
or
|
||||
result = convertMakeTemporarilyEscapableExprToRaw(e)
|
||||
or
|
||||
result = convertMaterializePackExprToRaw(e)
|
||||
or
|
||||
result = convertObjCSelectorExprToRaw(e)
|
||||
or
|
||||
result = convertOneWayExprToRaw(e)
|
||||
|
|
|
@ -114,6 +114,7 @@ import codeql.swift.elements.expr.LinearToDifferentiableFunctionExprConstructor
|
|||
import codeql.swift.elements.expr.LoadExprConstructor
|
||||
import codeql.swift.elements.expr.MagicIdentifierLiteralExprConstructor
|
||||
import codeql.swift.elements.expr.MakeTemporarilyEscapableExprConstructor
|
||||
import codeql.swift.elements.expr.MaterializePackExprConstructor
|
||||
import codeql.swift.elements.expr.MemberRefExprConstructor
|
||||
import codeql.swift.elements.expr.MetatypeConversionExprConstructor
|
||||
import codeql.swift.elements.expr.MethodLookupExprConstructor
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// generated by codegen/codegen.py
|
||||
/**
|
||||
* This module provides the generated definition of `MaterializePackExpr`.
|
||||
* INTERNAL: Do not import directly.
|
||||
*/
|
||||
|
||||
private import codeql.swift.generated.Synth
|
||||
private import codeql.swift.generated.Raw
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
/**
|
||||
* INTERNAL: This module contains the fully generated definition of `MaterializePackExpr` and should not
|
||||
* be referenced directly.
|
||||
*/
|
||||
module Generated {
|
||||
/**
|
||||
* An expression that materializes a pack during expansion. Appears around PackExpansionExpr.
|
||||
*
|
||||
* More details:
|
||||
* https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
|
||||
* INTERNAL: Do not reference the `Generated::MaterializePackExpr` class directly.
|
||||
* Use the subclass `MaterializePackExpr`, where the following predicates are available.
|
||||
*/
|
||||
class MaterializePackExpr extends Synth::TMaterializePackExpr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "MaterializePackExpr" }
|
||||
|
||||
/**
|
||||
* Gets the sub expression of this materialize pack expression.
|
||||
*
|
||||
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
|
||||
* behavior of both the `Immediate` and non-`Immediate` versions.
|
||||
*/
|
||||
Expr getImmediateSubExpr() {
|
||||
result =
|
||||
Synth::convertExprFromRaw(Synth::convertMaterializePackExprToRaw(this)
|
||||
.(Raw::MaterializePackExpr)
|
||||
.getSubExpr())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sub expression of this materialize pack expression.
|
||||
*/
|
||||
final Expr getSubExpr() {
|
||||
exists(Expr immediate |
|
||||
immediate = this.getImmediateSubExpr() and
|
||||
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -798,6 +798,7 @@ arguments( //dir=expr
|
|||
| @literal_expr
|
||||
| @lookup_expr
|
||||
| @make_temporarily_escapable_expr
|
||||
| @materialize_pack_expr
|
||||
| @obj_c_selector_expr
|
||||
| @one_way_expr
|
||||
| @opaque_value_expr
|
||||
|
@ -1130,6 +1131,11 @@ make_temporarily_escapable_exprs( //dir=expr
|
|||
int sub_expr: @expr_or_none ref
|
||||
);
|
||||
|
||||
materialize_pack_exprs( //dir=expr
|
||||
unique int id: @materialize_pack_expr,
|
||||
int sub_expr: @expr_or_none ref
|
||||
);
|
||||
|
||||
obj_c_selector_exprs( //dir=expr
|
||||
unique int id: @obj_c_selector_expr,
|
||||
int sub_expr: @expr_or_none ref,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
| test.swift:11:25:11:27 | MaterializePackExpr | hasType: | yes | getSubExpr: | test.swift:11:25:11:27 | call to a() |
|
11
swift/ql/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr.ql
сгенерированный
Normal file
11
swift/ql/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr.ql
сгенерированный
Normal file
|
@ -0,0 +1,11 @@
|
|||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements
|
||||
import TestUtils
|
||||
|
||||
from MaterializePackExpr x, string hasType, Expr getSubExpr
|
||||
where
|
||||
toBeTested(x) and
|
||||
not x.isUnknown() and
|
||||
(if x.hasType() then hasType = "yes" else hasType = "no") and
|
||||
getSubExpr = x.getSubExpr()
|
||||
select x, "hasType:", hasType, "getSubExpr:", getSubExpr
|
|
@ -0,0 +1 @@
|
|||
| test.swift:11:25:11:27 | MaterializePackExpr | each C |
|
7
swift/ql/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr_getType.ql
сгенерированный
Normal file
7
swift/ql/test/extractor-tests/generated/expr/PackExpansionExpr/MaterializePackExpr_getType.ql
сгенерированный
Normal file
|
@ -0,0 +1,7 @@
|
|||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements
|
||||
import TestUtils
|
||||
|
||||
from MaterializePackExpr x
|
||||
where toBeTested(x) and not x.isUnknown()
|
||||
select x, x.getType()
|
|
@ -1 +1,2 @@
|
|||
| test.swift:2:18:2:23 | PackElementExpr | hasType: | yes | getSubExpr: | test.swift:2:23:2:23 | t |
|
||||
| test.swift:11:20:11:27 | PackElementExpr | hasType: | yes | getSubExpr: | test.swift:11:25:11:27 | MaterializePackExpr |
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
| test.swift:2:18:2:23 | PackElementExpr | \u03c4_1_0 |
|
||||
| test.swift:11:20:11:27 | PackElementExpr | \u03c4_1_0 |
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
| test.swift:2:11:2:23 | PackExpansionExpr | hasType: | yes | getPatternExpr: | test.swift:2:18:2:23 | PackElementExpr |
|
||||
| test.swift:11:13:11:27 | PackExpansionExpr | hasType: | yes | getPatternExpr: | test.swift:11:20:11:27 | PackElementExpr |
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
| test.swift:2:11:2:23 | PackExpansionExpr | repeat each T |
|
||||
| test.swift:11:13:11:27 | PackExpansionExpr | repeat Optional<each C> |
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
func makeTuple<each T>(_ t: repeat each T) -> (repeat each T) {
|
||||
return (repeat each t)
|
||||
}
|
||||
let _ = makeTuple("A", 2)
|
||||
let _ = makeTuple("A", 2)
|
||||
|
||||
struct Packs<each C> {
|
||||
func a() -> (repeat each C) {
|
||||
fatalError()
|
||||
}
|
||||
public func b() -> (repeat Optional<each C>) {
|
||||
return (repeat each a())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1328,6 +1328,16 @@ class PackElementExpr(Expr):
|
|||
"""
|
||||
sub_expr: Expr | child
|
||||
|
||||
@qltest.test_with(PackExpansionExpr)
|
||||
class MaterializePackExpr(Expr):
|
||||
"""
|
||||
An expression that materializes a pack during expansion. Appears around PackExpansionExpr.
|
||||
|
||||
More details:
|
||||
https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
|
||||
"""
|
||||
sub_expr: Expr | child
|
||||
|
||||
class CopyExpr(Expr):
|
||||
"""
|
||||
An expression that forces value to be copied. In the example below, `copy` marks the copy expression:
|
||||
|
|
Загрузка…
Ссылка в новой задаче