diff --git a/misc/codegen/templates/ql_db.mustache b/misc/codegen/templates/ql_db.mustache index e63e0aae9034..a82ff78ec51f 100644 --- a/misc/codegen/templates/ql_db.mustache +++ b/misc/codegen/templates/ql_db.mustache @@ -29,9 +29,79 @@ module Raw { {{type}} {{getter}}({{#is_indexed}}int index{{/is_indexed}}) { {{tablename}}({{#tableparams}}{{^first}}, {{/first}}{{param}}{{/tableparams}}) } + {{#is_indexed}} + /** + * Gets the number of {{doc_plural}}. + {{#internal}} + * INTERNAL: Do not use. + {{/internal}} + */ + int getNumberOf{{plural}}() { + result = count(int i | {{tablename}}(this, i, _)) + } + {{/is_indexed}} {{/synth}} {{/properties}} } + + {{#final}} + private Element getImmediateChildOf{{name}}({{name}} e, int index) { + {{^has_children}}none(){{/has_children}} + {{#has_children}} + {{! n is the base offset 0, for ease of generation }} + {{! n is constructed to be strictly greater than the indexes for children }} + exists(int n{{#all_children}}, int n{{property.singular}}{{/all_children}} | + n = 0 + {{#all_children}} + {{#property}} + {{#synth}} + and + n{{singular}} = n{{prev}} + {{/synth}} + {{^synth}} + {{! n is defined on top of the previous definition }} + {{! for single and optional properties it adds 1 (regardless of whether the optional property exists) }} + {{! for repeated it adds 1 + the maximum index (which works for repeated optional as well) }} + and + n{{singular}} = n{{prev}} {{^is_repeated}}+ 1{{/is_repeated}}{{#is_repeated}}+ e.getNumberOf{{plural}}(){{/is_repeated}} + {{/synth}} + {{/property}} + {{/all_children}} and ( + none() + {{#all_children}} + {{#property}} + {{^synth}} + or + {{#is_repeated}} + result = e.get{{singular}}(index - n{{prev}}) + {{/is_repeated}} + {{^is_repeated}} + index = n{{prev}} and result = e.get{{singular}}() + {{/is_repeated}} + {{/synth}} + {{/property}} + {{/all_children}} + )) + {{/has_children}} + } + {{/final}} + {{/classes}} + + /** + * Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. + */ + pragma[nomagic] + Element getImmediateChild(Element e, int index) { + // why does this look more complicated than it should? + // * none() simplifies generation, as we can append `or ...` without a special case for the first item + none() + {{#classes}} + {{#final}} + or + result = getImmediateChildOf{{name}}(e, index) + {{/final}} + {{/classes}} + } } diff --git a/misc/codegen/templates/ql_parent.mustache b/misc/codegen/templates/ql_parent.mustache index 84bc0d79a0b7..91c5de98c47e 100644 --- a/misc/codegen/templates/ql_parent.mustache +++ b/misc/codegen/templates/ql_parent.mustache @@ -23,7 +23,12 @@ private module Impl { {{! for single and optional properties it adds 1 (regardless of whether the optional property exists) }} {{! for repeated it adds 1 + the maximum index (which works for repeated optional as well) }} and - n{{singular}} = n{{prev}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(i)) | i){{/is_repeated}} + {{#type_is_hideable}} + n{{singular}} = n{{prev}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.getImmediate{{singular}}(i)) | i){{/is_repeated}} + {{/type_is_hideable}} + {{^type_is_hideable}} + n{{singular}} = n{{prev}} {{^is_repeated}}+ 1{{/is_repeated}}{{#is_repeated}}+ e.getNumberOf{{plural}}(){{/is_repeated}} + {{/type_is_hideable}} {{/property}} {{/all_children}} and ( none() diff --git a/misc/codegen/templates/ql_synth_types.mustache b/misc/codegen/templates/ql_synth_types.mustache index c76654b8ea95..14a48f635e5f 100644 --- a/misc/codegen/templates/ql_synth_types.mustache +++ b/misc/codegen/templates/ql_synth_types.mustache @@ -32,9 +32,28 @@ module Synth { {{/root}} {{/non_final_classes}} + /** + * INTERNAL: Do not use. + * + * Gets the parent of synthetic element `e`. + */ + Raw::{{root}} getSynthParent(T{{root}} e) { + none() + {{#final_classes}} + {{#is_fresh_synth}} + {{#has_params}} + or + e = T{{name}}({{#params}}{{#first}}result{{/first}}{{^first}}, _{{/first}}{{/params}}) + {{/has_params}} + {{/is_fresh_synth}} + {{/final_classes}} + } + + {{#final_classes}} /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `T{{name}}`, if possible. */ T{{name}} convert{{name}}FromRaw(Raw::Element e) { diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 1f580178999e..5ed2894e273f 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -287,7 +287,6 @@ lib/codeql/rust/elements/internal/ImplConstructor.qll 24edccca59f70d812d1458b412 lib/codeql/rust/elements/internal/ImplTraitTypeReprConstructor.qll 1ed355e5e56f432b24b6f4778e4dc45c6e65095190cacb7a5015529e0c9d01f8 c8505185a042da4eb20a0cc32323194a0290c4bf821c7e0fce7351b194b10f31 lib/codeql/rust/elements/internal/IndexExprConstructor.qll 99bdc3d793c4dbd993860da60abe2b7c604345d645e86916462bc55a6939a5d1 3fe9d7da725956903707806aadbecac8d5b3874e8bed63c9bab54fff630e75dd lib/codeql/rust/elements/internal/InferTypeReprConstructor.qll bc5f16853401617fc9c5af8a1287a23c5921df1b615cfbe2d7c7a70145ecfcbd da93bd28ea2daade2cbb0a729be3fbf05f72bc02009565c7bb062e4f68fdb9e7 -lib/codeql/rust/elements/internal/ItemImpl.qll e3fb78d572ce1c3cc857d2671bd71ff4d7850321acfddc5f15533ff87accda79 fbabc2081e4b2773b04938d57bb51af908c80b7bc53c3127c74ab5d4fb9837bc lib/codeql/rust/elements/internal/ItemListConstructor.qll 08af3bd12536941c3dd4a43c81cc861be24325e242e2593c087a3ce632674291 2fa166159c409d2aaffa73a30babb40829a6de580bd40894d909ee6152801082 lib/codeql/rust/elements/internal/ItemListImpl.qll 195dbe93c334ad2bfc29db530bda9aaea88fc31696b2f230faae9e6c2ecb74a8 e498983a5b2f7a91e2fd336e85ac17e521a18c677784a0788d95bb283f3652e7 lib/codeql/rust/elements/internal/LabelConstructor.qll 1f814c94251e664bfa1b1a606aef995382e40e78d4f953350ec951ee0bc8bd34 3157fb8c7c6bd365a739f217ad73ba1e0b65ccd59b922e5ab034e3449915b36c @@ -568,7 +567,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126 -lib/codeql/rust/elements/internal/generated/ParentChild.qll 6e86fd9b6d5ec1b4aeeb5472cc6d2ebf3328bbaa8605cf52c9add56652cc47dc 3cf2a8e12ffb6631221c7b94fa112e8e3be96efba697996862685a87b2c9aff7 +lib/codeql/rust/elements/internal/generated/ParentChild.qll f04ca3d02170f7e532a480cc81748cf04f1b022d5e0e32ffcdf0f15c8f1961aa 999104d69a5435c9cab594e04b82ed26ae38b1b1d2ac1dbbb315a433c586f941 lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd @@ -583,7 +582,7 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 8d0ea4f6c7f8203340bf lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9 -lib/codeql/rust/elements/internal/generated/Raw.qll f50925f4925848cef73003adf01420566ca3efa16f491eadac62a30972ee9204 17d62252413618e1fa162c6c0b303ccfcac5f7f70cc170d739b20cc95f57035b +lib/codeql/rust/elements/internal/generated/Raw.qll 14758dc2e2a9af251f24e24516eab0fc95d334c1da06f418ea5da3c5521642c9 a8b6637f57293a85714cc8761f8fd1e23780d58f3873acaa3c77acd9cbfcf19f lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66 lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05 lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 5b0663a6d234572fb3e467e276d019415caa95ef006438cc59b7af4e1783161e 0e27c8a8f0e323c0e4d6db01fca821bf07c0864d293cdf96fa891b10820c1e4b @@ -608,7 +607,7 @@ lib/codeql/rust/elements/internal/generated/StructFieldList.qll 5da528a51a6a5db9 lib/codeql/rust/elements/internal/generated/StructPat.qll c76fa005c2fd0448a8803233e1e8818c4123301eb66ac5cf69d0b9eaafc61e98 6e0dffccdce24bca20e87d5ba0f0995c9a1ae8983283e71e7dbfcf6fffc67a58 lib/codeql/rust/elements/internal/generated/StructPatField.qll 5b5c7302dbc4a902ca8e69ff31875c867e295a16a626ba3cef29cd0aa248f179 4e192a0df79947f5cb0d47fdbbba7986137a6a40a1be92ae119873e2fad67edf lib/codeql/rust/elements/internal/generated/StructPatFieldList.qll 1a95a1bd9f64fb18e9571657cf2d02a8b13c747048a1f0f74baf31b91f0392ad fc274e414ff4ed54386046505920de92755ad0b4d39a7523cdffa4830bd53b37 -lib/codeql/rust/elements/internal/generated/Synth.qll 4c741d502d21d449c4e01010776f767c69b408c80ce7d10784b599463bcfd0e3 c76b8628663c126914ead897c779ce782294e9109125d61de958e0eee543abce +lib/codeql/rust/elements/internal/generated/Synth.qll a8ea364358a2bc3a9226d451c0867e89c29509a0f54dd88ed23c77045db2c85a a44de5e84a63cb5a1bfa66b0df33bf28c9f8b6628393d0f3b2f6215dabee47bd lib/codeql/rust/elements/internal/generated/SynthConstructors.qll f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 1a3c4f5f30659738641abdd28cb793dab3cfde484196b59656fc0a2767e53511 de2ebb210c7759ef7a6f7ee9f805e1cac879221287281775fc80ba34a5492edf diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index ff149fb36d36..bde61270e6aa 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -289,7 +289,6 @@ /lib/codeql/rust/elements/internal/ImplTraitTypeReprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/IndexExprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/InferTypeReprConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/ItemImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ItemListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ItemListImpl.qll linguist-generated /lib/codeql/rust/elements/internal/LabelConstructor.qll linguist-generated diff --git a/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll index 237ebfa6b413..69138190dba3 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll @@ -13,9 +13,9 @@ private import codeql.rust.controlflow.ControlFlowGraph */ module Impl { private import rust + private import codeql.rust.elements.internal.ElementImpl::Impl as ElementImpl private import codeql.rust.elements.internal.generated.ParentChild private import codeql.rust.controlflow.ControlFlowGraph - private import codeql.rust.elements.internal.MacroCallImpl::Impl as MacroCallImpl /** * Gets the immediate parent of a non-`AstNode` element `e`. @@ -71,21 +71,15 @@ module Impl { } /** Holds if this node is inside a macro expansion. */ - predicate isInMacroExpansion() { MacroCallImpl::isInMacroExpansion(_, this) } + predicate isInMacroExpansion() { ElementImpl::MacroExpansion::isInMacroExpansion(this) } /** * Holds if this node exists only as the result of a macro expansion. * * This is the same as `isInMacroExpansion()`, but excludes AST nodes corresponding - * to macro arguments. + * to macro arguments, including attribute macro targets. */ - pragma[nomagic] - predicate isFromMacroExpansion() { - exists(AstNode root | - MacroCallImpl::isInMacroExpansion(root, this) and - not this = root.(MacroCall).getATokenTreeNode() - ) - } + predicate isFromMacroExpansion() { ElementImpl::MacroExpansion::isFromMacroExpansion(this) } /** * Gets a control flow node for this AST node, if any. diff --git a/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll index 7a464a378d1e..5df20664f7df 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll @@ -11,7 +11,115 @@ private import codeql.rust.elements.internal.generated.Element * be referenced directly. */ module Impl { + private import rust + private import codeql.rust.elements.internal.generated.ParentChild + private import codeql.rust.elements.internal.generated.Synth + private import codeql.rust.elements.internal.generated.Raw + private import codeql.rust.elements.internal.LocationImpl + + /** + * Provides logic for classifying elements with respect to macro expansions. + */ + cached + module MacroExpansion { + /** + * Holds if `e` is superseded by an attribute macro expansion. That is, `e` is + * a transitive child of an item with an attribute macro expansion. + */ + private predicate supersededByAttributeMacroExpansionRaw(Raw::Item item, Raw::Element e) { + exists(item.getAttributeMacroExpansion()) and + e = Raw::getImmediateChild(item, _) and + not e = item.getAttributeMacroExpansion() and + // Don't consider attributes themselves to be superseded. E.g., in `#[a] fn + // f() {}` the macro expansion supersedes `fn f() {}` but not `#[a]`. + not e instanceof Raw::Attr + or + exists(Raw::Element parent | + e = Raw::getImmediateChild(parent, _) and + supersededByAttributeMacroExpansionRaw(item, parent) + ) + } + + private predicate isMacroExpansion(AstNode macro, AstNode expansion) { + expansion = macro.(MacroCall).getMacroCallExpansion() + or + expansion = macro.(Adt).getDeriveMacroExpansion(_) + or + expansion = macro.(Item).getAttributeMacroExpansion() + } + + /** + * Gets the immediately enclosing macro invocation for element `e`, if any. + * + * The result is either a `MacroCall`, and `Adt` with a derive macro expansion, or + * an `Item` with an attribute macro expansion. + */ + cached + AstNode getImmediatelyEnclosingMacroInvocation(Element e) { + isMacroExpansion(result, e) + or + exists(Element mid | + result = getImmediatelyEnclosingMacroInvocation(mid) and + mid = getImmediateParent(e) and + not isMacroExpansion(mid, e) + ) + } + + pragma[nomagic] + private predicate isAttributeMacroExpansionSourceLocation(Item i, Location l) { + exists(Raw::Locatable e, @location_default loc | + supersededByAttributeMacroExpansionRaw(Synth::convertElementToRaw(i), e) and + locatable_locations(e, loc) and + l = LocationImpl::TLocationDefault(loc) + ) + } + + /** Gets an AST node whose location is inside the token tree belonging to `mc`. */ + pragma[nomagic] + private AstNode getATokenTreeNode(MacroCall mc) { + mc = getImmediatelyEnclosingMacroInvocation(result) and + mc.getTokenTree().getLocation().contains(result.getLocation()) + } + + /** Holds if `n` is inside a macro expansion. */ + cached + predicate isInMacroExpansion(AstNode n) { exists(getImmediatelyEnclosingMacroInvocation(n)) } + + /** + * Holds if `n` exists only as the result of a macro expansion. + * + * This is the same as `isInMacroExpansion(n)`, but excludes AST nodes corresponding + * to macro arguments, including attribute macro targets. + * + * Note: This predicate is a heuristic based on location information and may not be + * accurate in all cases. + */ + cached + predicate isFromMacroExpansion(AstNode n) { + exists(AstNode macro | + macro = getImmediatelyEnclosingMacroInvocation(n) and + not n = getATokenTreeNode(macro) and + not isAttributeMacroExpansionSourceLocation(macro, n.getLocation()) + ) + or + isFromMacroExpansion(getImmediatelyEnclosingMacroInvocation(n)) + } + + cached + predicate isRelevantElement(Generated::Element e) { + exists(Raw::Element raw | + raw = Synth::convertElementToRaw(e) and + not supersededByAttributeMacroExpansionRaw(_, raw) + ) + or + // Synthetic elements are relevant when their parent is + Synth::convertFormatArgsExprToRaw(_) = Synth::getSynthParent(e) + } + } + class Element extends Generated::Element { + Element() { MacroExpansion::isRelevantElement(this) } + override string toStringImpl() { result = this.getAPrimaryQlClass() } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll index f211708bc812..46e554e4b420 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `Item`. * @@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.Item * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * An item such as a function, struct, enum, etc. * @@ -23,4 +23,10 @@ module Impl { * ``` */ class Item extends Generated::Item { } + + private class ItemWithAttributeMacroExpansion extends Item { + ItemWithAttributeMacroExpansion() { this.hasAttributeMacroExpansion() } + + override string toStringImpl() { result = "(item with attribute macro expansion)" } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll index fcb5289e0493..78a9e7f38eca 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll @@ -5,6 +5,7 @@ */ import codeql.Locations +private import codeql.rust.elements.internal.ElementImpl::Impl as ElementImpl private import codeql.rust.elements.internal.LocationImpl private import codeql.rust.elements.internal.generated.Locatable private import codeql.rust.elements.internal.generated.Synth @@ -50,21 +51,12 @@ module Impl { locatable_locations(Synth::convertLocatableToRaw(l), result) } - private MacroCall getImmediatelyEnclosingMacroCall(AstNode n) { - result = n.getParentNode() - or - exists(AstNode mid | - result = getImmediatelyEnclosingMacroCall(mid) and - n.getParentNode() = mid and - not mid instanceof MacroCall - ) - } - /** Gets the non-synthesized location of `l`, if any. */ LocationImpl::LocationDefault getLocationDefault(Locatable l) { result = LocationImpl::TLocationDefault(getDbLocation(l)) or not exists(getDbLocation(l)) and - result = getLocationDefault(getImmediatelyEnclosingMacroCall(l)) + result = + getLocationDefault(ElementImpl::MacroExpansion::getImmediatelyEnclosingMacroInvocation(l)) } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll index 17cc47d803f8..8e048517f63c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll @@ -14,17 +14,6 @@ module Impl { private import rust private import codeql.rust.internal.PathResolution - pragma[nomagic] - predicate isInMacroExpansion(AstNode root, AstNode n) { - n = root.(MacroCall).getMacroCallExpansion() - or - n = root.(Adt).getDeriveMacroExpansion(_) - or - n = root.(Item).getAttributeMacroExpansion() - or - isInMacroExpansion(root, n.getParentNode()) - } - // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A macro invocation. @@ -35,16 +24,7 @@ module Impl { * ``` */ class MacroCall extends Generated::MacroCall { - override string toStringImpl() { - if this.hasPath() then result = this.getPath().toAbbreviatedString() + "!..." else result = "" - } - - /** Gets an AST node whose location is inside the token tree belonging to this macro call. */ - pragma[nomagic] - AstNode getATokenTreeNode() { - isInMacroExpansion(this, result) and - this.getTokenTree().getLocation().contains(result.getLocation()) - } + override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "!..." } /** * Gets the macro definition that this macro call resolves to. diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 7b8d4d4e4627..233c29e01738 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -74,7 +74,7 @@ private module Impl { private Element getImmediateChildOfArgList(ArgList e, int index, string partialPredicateCall) { exists(int n, int nArg | n = 0 and - nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + nArg = n + e.getNumberOfArgs() and ( none() or @@ -126,8 +126,8 @@ private module Impl { ) { exists(int n, int nAssocItem, int nAttr | n = 0 and - nAssocItem = n + 1 + max(int i | i = -1 or exists(e.getAssocItem(i)) | i) and - nAttr = nAssocItem + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAssocItem = n + e.getNumberOfAssocItems() and + nAttr = nAssocItem + e.getNumberOfAttrs() and ( none() or @@ -157,8 +157,8 @@ private module Impl { ) { exists(int n, int nAttr, int nExternItem | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nExternItem = nAttr + 1 + max(int i | i = -1 or exists(e.getExternItem(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nExternItem = nAttr + e.getNumberOfExternItems() and ( none() or @@ -207,7 +207,7 @@ private module Impl { ) { exists(int n, int nGenericArg | n = 0 and - nGenericArg = n + 1 + max(int i | i = -1 or exists(e.getGenericArg(i)) | i) and + nGenericArg = n + e.getNumberOfGenericArgs() and ( none() or @@ -222,7 +222,7 @@ private module Impl { ) { exists(int n, int nGenericParam | n = 0 and - nGenericParam = n + 1 + max(int i | i = -1 or exists(e.getGenericParam(i)) | i) and + nGenericParam = n + e.getNumberOfGenericParams() and ( none() or @@ -235,8 +235,8 @@ private module Impl { private Element getImmediateChildOfItemList(ItemList e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nItem | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nItem = nAttr + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nItem = nAttr + e.getNumberOfItems() and ( none() or @@ -276,7 +276,7 @@ private module Impl { private Element getImmediateChildOfMacroItems(MacroItems e, int index, string partialPredicateCall) { exists(int n, int nItem | n = 0 and - nItem = n + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and + nItem = n + e.getNumberOfItems() and ( none() or @@ -289,7 +289,7 @@ private module Impl { private Element getImmediateChildOfMatchArm(MatchArm e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr, int nGuard, int nPat | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and nGuard = nExpr + 1 and nPat = nGuard + 1 and @@ -313,8 +313,8 @@ private module Impl { ) { exists(int n, int nArm, int nAttr | n = 0 and - nArm = n + 1 + max(int i | i = -1 or exists(e.getArm(i)) | i) and - nAttr = nArm + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nArm = n + e.getNumberOfArms() and + nAttr = nArm + e.getNumberOfAttrs() and ( none() or @@ -362,7 +362,7 @@ private module Impl { private Element getImmediateChildOfParamList(ParamList e, int index, string partialPredicateCall) { exists(int n, int nParam, int nSelfParam | n = 0 and - nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = n + e.getNumberOfParams() and nSelfParam = nParam + 1 and ( none() @@ -380,7 +380,7 @@ private module Impl { ) { exists(int n, int nTypeArg | n = 0 and - nTypeArg = n + 1 + max(int i | i = -1 or exists(e.getTypeArg(i)) | i) and + nTypeArg = n + e.getNumberOfTypeArgs() and ( none() or @@ -487,8 +487,8 @@ private module Impl { private Element getImmediateChildOfSourceFile(SourceFile e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nItem | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nItem = nAttr + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nItem = nAttr + e.getNumberOfItems() and ( none() or @@ -504,8 +504,8 @@ private module Impl { private Element getImmediateChildOfStmtList(StmtList e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nStatement, int nTailExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nStatement = nAttr + 1 + max(int i | i = -1 or exists(e.getStatement(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nStatement = nAttr + e.getNumberOfStatements() and nTailExpr = nStatement + 1 and ( none() @@ -526,7 +526,7 @@ private module Impl { ) { exists(int n, int nAttr, int nExpr, int nIdentifier | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and nIdentifier = nExpr + 1 and ( @@ -547,8 +547,8 @@ private module Impl { ) { exists(int n, int nAttr, int nField, int nSpread | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and nSpread = nField + 1 and ( none() @@ -569,7 +569,7 @@ private module Impl { ) { exists(int n, int nAttr, int nDefault, int nName, int nTypeRepr, int nVisibility | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nDefault = nAttr + 1 and nName = nDefault + 1 and nTypeRepr = nName + 1 and @@ -596,7 +596,7 @@ private module Impl { ) { exists(int n, int nAttr, int nIdentifier, int nPat | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nIdentifier = nAttr + 1 and nPat = nIdentifier + 1 and ( @@ -617,7 +617,7 @@ private module Impl { ) { exists(int n, int nField, int nRestPat | n = 0 and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = n + e.getNumberOfFields() and nRestPat = nField + 1 and ( none() @@ -637,7 +637,7 @@ private module Impl { private Element getImmediateChildOfTupleField(TupleField e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nTypeRepr, int nVisibility | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nTypeRepr = nAttr + 1 and nVisibility = nTypeRepr + 1 and ( @@ -681,7 +681,7 @@ private module Impl { ) { exists(int n, int nBound | n = 0 and - nBound = n + 1 + max(int i | i = -1 or exists(e.getBound(i)) | i) and + nBound = n + e.getNumberOfBounds() and ( none() or @@ -696,7 +696,7 @@ private module Impl { ) { exists(int n, int nUseBoundGenericArg | n = 0 and - nUseBoundGenericArg = n + 1 + max(int i | i = -1 or exists(e.getUseBoundGenericArg(i)) | i) and + nUseBoundGenericArg = n + e.getNumberOfUseBoundGenericArgs() and ( none() or @@ -729,7 +729,7 @@ private module Impl { ) { exists(int n, int nUseTree | n = 0 and - nUseTree = n + 1 + max(int i | i = -1 or exists(e.getUseTree(i)) | i) and + nUseTree = n + e.getNumberOfUseTrees() and ( none() or @@ -744,7 +744,7 @@ private module Impl { ) { exists(int n, int nVariant | n = 0 and - nVariant = n + 1 + max(int i | i = -1 or exists(e.getVariant(i)) | i) and + nVariant = n + e.getNumberOfVariants() and ( none() or @@ -771,7 +771,7 @@ private module Impl { ) { exists(int n, int nPredicate | n = 0 and - nPredicate = n + 1 + max(int i | i = -1 or exists(e.getPredicate(i)) | i) and + nPredicate = n + e.getNumberOfPredicates() and ( none() or @@ -809,8 +809,8 @@ private module Impl { ) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nExpr = nAttr + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + e.getNumberOfExprs() and ( none() or @@ -894,7 +894,7 @@ private module Impl { ) { exists(int n, int nAsmOption | n = 0 and - nAsmOption = n + 1 + max(int i | i = -1 or exists(e.getAsmOption(i)) | i) and + nAsmOption = n + e.getNumberOfAsmOptions() and ( none() or @@ -991,7 +991,7 @@ private module Impl { private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1007,7 +1007,7 @@ private module Impl { private Element getImmediateChildOfBecomeExpr(BecomeExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1023,7 +1023,7 @@ private module Impl { private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nLhs, int nRhs | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nLhs = nAttr + 1 and nRhs = nLhs + 1 and ( @@ -1054,7 +1054,7 @@ private module Impl { private Element getImmediateChildOfBreakExpr(BreakExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr, int nLifetime | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and nLifetime = nExpr + 1 and ( @@ -1073,7 +1073,7 @@ private module Impl { private Element getImmediateChildOfCastExpr(CastExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr, int nTypeRepr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and nTypeRepr = nExpr + 1 and ( @@ -1095,7 +1095,7 @@ private module Impl { exists(int n, int nParamList, int nAttr, int nClosureBody, int nForBinder, int nRetType | n = 0 and nParamList = n + 1 and - nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nParamList + e.getNumberOfAttrs() and nClosureBody = nAttr + 1 and nForBinder = nClosureBody + 1 and nRetType = nForBinder + 1 and @@ -1149,7 +1149,7 @@ private module Impl { private Element getImmediateChildOfConstParam(ConstParam e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nDefaultVal, int nName, int nTypeRepr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nDefaultVal = nAttr + 1 and nName = nDefaultVal + 1 and nTypeRepr = nName + 1 and @@ -1173,7 +1173,7 @@ private module Impl { ) { exists(int n, int nAttr, int nLifetime | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nLifetime = nAttr + 1 and ( none() @@ -1215,7 +1215,7 @@ private module Impl { private Element getImmediateChildOfFieldExpr(FieldExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nContainer, int nIdentifier | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nContainer = nAttr + 1 and nIdentifier = nContainer + 1 and ( @@ -1273,10 +1273,10 @@ private module Impl { ) { exists(int n, int nArg, int nAttr, int nTemplate, int nFormat | n = 0 and - nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and - nAttr = nArg + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nArg = n + e.getNumberOfArgs() and + nAttr = nArg + e.getNumberOfAttrs() and nTemplate = nAttr + 1 and - nFormat = nTemplate + 1 + max(int i | i = -1 or exists(e.getFormat(i)) | i) and + nFormat = nTemplate + e.getNumberOfFormats() and ( none() or @@ -1297,7 +1297,7 @@ private module Impl { private Element getImmediateChildOfIdentPat(IdentPat e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nName, int nPat | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nName = nAttr + 1 and nPat = nName + 1 and ( @@ -1316,7 +1316,7 @@ private module Impl { private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nCondition, int nElse, int nThen | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nCondition = nAttr + 1 and nElse = nCondition + 1 and nThen = nElse + 1 and @@ -1352,7 +1352,7 @@ private module Impl { private Element getImmediateChildOfIndexExpr(IndexExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nBase, int nIndex | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nBase = nAttr + 1 and nIndex = nBase + 1 and ( @@ -1377,7 +1377,7 @@ private module Impl { private Element getImmediateChildOfLetExpr(LetExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nScrutinee, int nPat | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nScrutinee = nAttr + 1 and nPat = nScrutinee + 1 and ( @@ -1396,7 +1396,7 @@ private module Impl { private Element getImmediateChildOfLetStmt(LetStmt e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nInitializer, int nLetElse, int nPat, int nTypeRepr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nInitializer = nAttr + 1 and nLetElse = nInitializer + 1 and nPat = nLetElse + 1 and @@ -1441,7 +1441,7 @@ private module Impl { ) { exists(int n, int nAttr, int nLifetime, int nTypeBoundList | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nLifetime = nAttr + 1 and nTypeBoundList = nLifetime + 1 and ( @@ -1464,7 +1464,7 @@ private module Impl { ) { exists(int n, int nAttr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and ( none() or @@ -1491,7 +1491,7 @@ private module Impl { ) { exists(int n, int nStatement, int nTailExpr | n = 0 and - nStatement = n + 1 + max(int i | i = -1 or exists(e.getStatement(i)) | i) and + nStatement = n + e.getNumberOfStatements() and nTailExpr = nStatement + 1 and ( none() @@ -1545,7 +1545,7 @@ private module Impl { private Element getImmediateChildOfMatchExpr(MatchExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nScrutinee, int nMatchArmList | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nScrutinee = nAttr + 1 and nMatchArmList = nScrutinee + 1 and ( @@ -1578,8 +1578,8 @@ private module Impl { ) { exists(int n, int nAttr, int nField, int nTypeRepr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and nTypeRepr = nField + 1 and ( none() @@ -1598,7 +1598,7 @@ private module Impl { private Element getImmediateChildOfOrPat(OrPat e, int index, string partialPredicateCall) { exists(int n, int nPat | n = 0 and - nPat = n + 1 + max(int i | i = -1 or exists(e.getPat(i)) | i) and + nPat = n + e.getNumberOfPats() and ( none() or @@ -1611,7 +1611,7 @@ private module Impl { private Element getImmediateChildOfParam(Param e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nTypeRepr, int nPat | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nTypeRepr = nAttr + 1 and nPat = nTypeRepr + 1 and ( @@ -1630,7 +1630,7 @@ private module Impl { private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1698,7 +1698,7 @@ private module Impl { private Element getImmediateChildOfPrefixExpr(PrefixExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1728,7 +1728,7 @@ private module Impl { private Element getImmediateChildOfRangeExpr(RangeExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nEnd, int nStart | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nEnd = nAttr + 1 and nStart = nEnd + 1 and ( @@ -1762,7 +1762,7 @@ private module Impl { private Element getImmediateChildOfRefExpr(RefExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1807,7 +1807,7 @@ private module Impl { private Element getImmediateChildOfRestPat(RestPat e, int index, string partialPredicateCall) { exists(int n, int nAttr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and ( none() or @@ -1820,7 +1820,7 @@ private module Impl { private Element getImmediateChildOfReturnExpr(ReturnExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1836,7 +1836,7 @@ private module Impl { private Element getImmediateChildOfSelfParam(SelfParam e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nTypeRepr, int nLifetime, int nName | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nTypeRepr = nAttr + 1 and nLifetime = nTypeRepr + 1 and nName = nLifetime + 1 and @@ -1858,7 +1858,7 @@ private module Impl { private Element getImmediateChildOfSlicePat(SlicePat e, int index, string partialPredicateCall) { exists(int n, int nPat | n = 0 and - nPat = n + 1 + max(int i | i = -1 or exists(e.getPat(i)) | i) and + nPat = n + e.getNumberOfPats() and ( none() or @@ -1904,7 +1904,7 @@ private module Impl { ) { exists(int n, int nField | n = 0 and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = n + e.getNumberOfFields() and ( none() or @@ -1934,7 +1934,7 @@ private module Impl { private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -1950,8 +1950,8 @@ private module Impl { private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nField | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and ( none() or @@ -1969,7 +1969,7 @@ private module Impl { ) { exists(int n, int nField | n = 0 and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = n + e.getNumberOfFields() and ( none() or @@ -1982,7 +1982,7 @@ private module Impl { private Element getImmediateChildOfTuplePat(TuplePat e, int index, string partialPredicateCall) { exists(int n, int nField | n = 0 and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = n + e.getNumberOfFields() and ( none() or @@ -1998,7 +1998,7 @@ private module Impl { exists(int n, int nPath, int nField | n = 0 and nPath = n + 1 and - nField = nPath + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = nPath + e.getNumberOfFields() and ( none() or @@ -2015,7 +2015,7 @@ private module Impl { ) { exists(int n, int nField | n = 0 and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nField = n + e.getNumberOfFields() and ( none() or @@ -2040,7 +2040,7 @@ private module Impl { private Element getImmediateChildOfTypeParam(TypeParam e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nDefaultType, int nName, int nTypeBoundList | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nDefaultType = nAttr + 1 and nName = nDefaultType + 1 and nTypeBoundList = nName + 1 and @@ -2064,7 +2064,7 @@ private module Impl { ) { exists(int n, int nAttr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and ( none() or @@ -2077,7 +2077,7 @@ private module Impl { private Element getImmediateChildOfVariant(Variant e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nDiscriminant, int nFieldList, int nName, int nVisibility | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nDiscriminant = nAttr + 1 and nFieldList = nDiscriminant + 1 and nName = nFieldList + 1 and @@ -2108,7 +2108,7 @@ private module Impl { private Element getImmediateChildOfYeetExpr(YeetExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -2124,7 +2124,7 @@ private module Impl { private Element getImmediateChildOfYieldExpr(YieldExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = n + e.getNumberOfAttrs() and nExpr = nAttr + 1 and ( none() @@ -2142,8 +2142,8 @@ private module Impl { ) { exists(int n, int nExpr, int nAttr | n = 0 and - nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and - nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nExpr = n + e.getNumberOfExprs() and + nAttr = nExpr + e.getNumberOfAttrs() and ( none() or @@ -2161,8 +2161,8 @@ private module Impl { ) { exists(int n, int nExpr, int nAttr, int nRepeatOperand, int nRepeatLength | n = 0 and - nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and - nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nExpr = n + e.getNumberOfExprs() and + nAttr = nExpr + e.getNumberOfAttrs() and nRepeatOperand = nAttr + 1 and nRepeatLength = nRepeatOperand + 1 and ( @@ -2187,9 +2187,9 @@ private module Impl { exists(int n, int nAttributeMacroExpansion, int nAsmPiece, int nAttr, int nTemplate | n = 0 and nAttributeMacroExpansion = n + 1 and - nAsmPiece = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAsmPiece(i)) | i) and - nAttr = nAsmPiece + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nTemplate = nAttr + 1 + max(int i | i = -1 or exists(e.getTemplate(i)) | i) and + nAsmPiece = nAttributeMacroExpansion + e.getNumberOfAsmPieces() and + nAttr = nAsmPiece + e.getNumberOfAttrs() and + nTemplate = nAttr + e.getNumberOfTemplates() and ( none() or @@ -2213,7 +2213,7 @@ private module Impl { exists(int n, int nLabel, int nAttr, int nStmtList | n = 0 and nLabel = n + 1 and - nAttr = nLabel + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nLabel + e.getNumberOfAttrs() and nStmtList = nAttr + 1 and ( none() @@ -2232,7 +2232,7 @@ private module Impl { exists(int n, int nArgList, int nAttr, int nFunction | n = 0 and nArgList = n + 1 and - nAttr = nArgList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nArgList + e.getNumberOfAttrs() and nFunction = nAttr + 1 and ( none() @@ -2254,7 +2254,7 @@ private module Impl { n = 0 and nAttributeMacroExpansion = n + 1 and nAbi = nAttributeMacroExpansion + 1 and - nAttr = nAbi + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAbi + e.getNumberOfAttrs() and nExternItemList = nAttr + 1 and ( none() @@ -2283,7 +2283,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nIdentifier = nAttr + 1 and nRename = nIdentifier + 1 and nVisibility = nRename + 1 and @@ -2320,7 +2320,7 @@ private module Impl { n = 0 and nAttributeMacroExpansion = n + 1 and nAssocItemList = nAttributeMacroExpansion + 1 and - nAttr = nAssocItemList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAssocItemList + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nSelfTy = nGenericParamList + 1 and nTrait = nSelfTy + 1 and @@ -2365,7 +2365,7 @@ private module Impl { n = 0 and nAttributeMacroExpansion = n + 1 and nArgs = nAttributeMacroExpansion + 1 and - nAttr = nArgs + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nArgs + e.getNumberOfAttrs() and nBody = nAttr + 1 and nName = nBody + 1 and nVisibility = nName + 1 and @@ -2398,7 +2398,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nName = nAttr + 1 and nTokenTree = nName + 1 and nVisibility = nTokenTree + 1 and @@ -2427,7 +2427,7 @@ private module Impl { exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | n = 0 and nArgList = n + 1 and - nAttr = nArgList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nArgList + e.getNumberOfAttrs() and nGenericArgList = nAttr + 1 and nIdentifier = nGenericArgList + 1 and nReceiver = nIdentifier + 1 and @@ -2458,7 +2458,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nItemList = nAttr + 1 and nName = nItemList + 1 and nVisibility = nName + 1 and @@ -2485,7 +2485,7 @@ private module Impl { exists(int n, int nPath, int nAttr | n = 0 and nPath = n + 1 and - nAttr = nPath + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nPath + e.getNumberOfAttrs() and ( none() or @@ -2505,7 +2505,7 @@ private module Impl { n = 0 and nAttributeMacroExpansion = n + 1 and nAssocItemList = nAttributeMacroExpansion + 1 and - nAttr = nAssocItemList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAssocItemList + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nTypeBoundList = nName + 1 and @@ -2551,7 +2551,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nTypeBoundList = nName + 1 and @@ -2590,7 +2590,7 @@ private module Impl { exists(int n, int nAttributeMacroExpansion, int nAttr, int nUseTree, int nVisibility | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nUseTree = nAttr + 1 and nVisibility = nUseTree + 1 and ( @@ -2617,7 +2617,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nBody = nAttr + 1 and nGenericParamList = nBody + 1 and nName = nGenericParamList + 1 and @@ -2660,10 +2660,8 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nDeriveMacroExpansion = - nAttributeMacroExpansion + 1 + - max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and - nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nVariantList = nName + 1 and @@ -2707,7 +2705,7 @@ private module Impl { n = 0 and nLabel = n + 1 and nLoopBody = nLabel + 1 and - nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nLoopBody + e.getNumberOfAttrs() and nIterable = nAttr + 1 and nPat = nIterable + 1 and ( @@ -2735,7 +2733,7 @@ private module Impl { n = 0 and nAttributeMacroExpansion = n + 1 and nParamList = nAttributeMacroExpansion + 1 and - nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nParamList + e.getNumberOfAttrs() and nAbi = nAttr + 1 and nFunctionBody = nAbi + 1 and nGenericParamList = nFunctionBody + 1 and @@ -2783,7 +2781,7 @@ private module Impl { n = 0 and nLabel = n + 1 and nLoopBody = nLabel + 1 and - nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nLoopBody + e.getNumberOfAttrs() and ( none() or @@ -2804,7 +2802,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nPath = nAttr + 1 and nTokenTree = nPath + 1 and nMacroCallExpansion = nTokenTree + 1 and @@ -2836,7 +2834,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nBody = nAttr + 1 and nName = nBody + 1 and nTypeRepr = nName + 1 and @@ -2869,10 +2867,8 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nDeriveMacroExpansion = - nAttributeMacroExpansion + 1 + - max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and - nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and nFieldList = nAttr + 1 and nGenericParamList = nFieldList + 1 and nName = nGenericParamList + 1 and @@ -2916,7 +2912,7 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nTypeRepr = nName + 1 and @@ -2963,10 +2959,8 @@ private module Impl { | n = 0 and nAttributeMacroExpansion = n + 1 and - nDeriveMacroExpansion = - nAttributeMacroExpansion + 1 + - max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and - nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nStructFieldList = nName + 1 and @@ -3012,7 +3006,7 @@ private module Impl { n = 0 and nLabel = n + 1 and nLoopBody = nLabel + 1 and - nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAttr = nLoopBody + e.getNumberOfAttrs() and nCondition = nAttr + 1 and ( none() diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index 21782ed7db43..aff81e9b9ab8 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -34,6 +34,8 @@ module Raw { int getDurationMs() { extractor_steps(this, _, result) } } + private Element getImmediateChildOfExtractorStep(ExtractorStep e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -56,6 +58,8 @@ module Raw { Crate getCrate() { named_crates(this, _, result) } } + private Element getImmediateChildOfNamedCrate(NamedCrate e, int index) { none() } + /** * INTERNAL: Do not use. * The base class marking everything that was not properly extracted for some reason, such as: @@ -91,12 +95,27 @@ module Raw { */ string getCfgOption(int index) { crate_cfg_options(this, index, result) } + /** + * Gets the number of cfg options of this crate. + */ + int getNumberOfCfgOptions() { result = count(int i | crate_cfg_options(this, i, _)) } + /** * Gets the `index`th named dependency of this crate (0-based). */ NamedCrate getNamedDependency(int index) { crate_named_dependencies(this, index, result) } + + /** + * Gets the number of named dependencies of this crate. + * INTERNAL: Do not use. + */ + int getNumberOfNamedDependencies() { + result = count(int i | crate_named_dependencies(this, i, _)) + } } + private Element getImmediateChildOfCrate(Crate e, int index) { none() } + /** * INTERNAL: Do not use. * The base class marking errors during parsing or resolution. @@ -105,6 +124,8 @@ module Raw { override string toString() { result = "Missing" } } + private Element getImmediateChildOfMissing(Missing e, int index) { none() } + /** * INTERNAL: Do not use. * The base class for unimplemented nodes. This is used to mark nodes that are not yet extracted. @@ -113,6 +134,8 @@ module Raw { override string toString() { result = "Unimplemented" } } + private Element getImmediateChildOfUnimplemented(Unimplemented e, int index) { none() } + /** * INTERNAL: Do not use. * An ABI specification for an extern function or block. @@ -132,6 +155,8 @@ module Raw { string getAbiString() { abi_abi_strings(this, result) } } + private Element getImmediateChildOfAbi(Abi e, int index) { none() } + /** * INTERNAL: Do not use. * Something that can be addressed by a path. @@ -157,6 +182,23 @@ module Raw { * Gets the `index`th argument of this argument list (0-based). */ Expr getArg(int index) { arg_list_args(this, index, result) } + + /** + * Gets the number of arguments of this argument list. + */ + int getNumberOfArgs() { result = count(int i | arg_list_args(this, i, _)) } + } + + private Element getImmediateChildOfArgList(ArgList e, int index) { + exists(int n, int nArg | + n = 0 and + nArg = n + e.getNumberOfArgs() and + ( + none() + or + result = e.getArg(index - n) + ) + ) } /** @@ -174,6 +216,8 @@ module Raw { override string toString() { result = "AsmDirSpec" } } + private Element getImmediateChildOfAsmDirSpec(AsmDirSpec e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -204,6 +248,21 @@ module Raw { Expr getOutExpr() { asm_operand_expr_out_exprs(this, result) } } + private Element getImmediateChildOfAsmOperandExpr(AsmOperandExpr e, int index) { + exists(int n, int nInExpr, int nOutExpr | + n = 0 and + nInExpr = n + 1 and + nOutExpr = nInExpr + 1 and + ( + none() + or + index = n and result = e.getInExpr() + or + index = nInExpr and result = e.getOutExpr() + ) + ) + } + /** * INTERNAL: Do not use. * An option in an inline assembly block. @@ -224,6 +283,8 @@ module Raw { predicate isRaw() { asm_option_is_raw(this) } } + private Element getImmediateChildOfAsmOption(AsmOption e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -249,6 +310,18 @@ module Raw { NameRef getIdentifier() { asm_reg_spec_identifiers(this, result) } } + private Element getImmediateChildOfAsmRegSpec(AsmRegSpec e, int index) { + exists(int n, int nIdentifier | + n = 0 and + nIdentifier = n + 1 and + ( + none() + or + index = n and result = e.getIdentifier() + ) + ) + } + /** * INTERNAL: Do not use. * A list of `AssocItem` elements, as appearing in a `Trait` or `Impl`. @@ -261,10 +334,35 @@ module Raw { */ AssocItem getAssocItem(int index) { assoc_item_list_assoc_items(this, index, result) } + /** + * Gets the number of assoc items of this assoc item list. + */ + int getNumberOfAssocItems() { result = count(int i | assoc_item_list_assoc_items(this, i, _)) } + /** * Gets the `index`th attr of this assoc item list (0-based). */ Attr getAttr(int index) { assoc_item_list_attrs(this, index, result) } + + /** + * Gets the number of attrs of this assoc item list. + */ + int getNumberOfAttrs() { result = count(int i | assoc_item_list_attrs(this, i, _)) } + } + + private Element getImmediateChildOfAssocItemList(AssocItemList e, int index) { + exists(int n, int nAssocItem, int nAttr | + n = 0 and + nAssocItem = n + e.getNumberOfAssocItems() and + nAttr = nAssocItem + e.getNumberOfAttrs() and + ( + none() + or + result = e.getAssocItem(index - n) + or + result = e.getAttr(index - nAssocItem) + ) + ) } /** @@ -287,6 +385,18 @@ module Raw { Meta getMeta() { attr_meta(this, result) } } + private Element getImmediateChildOfAttr(Attr e, int index) { + exists(int n, int nMeta | + n = 0 and + nMeta = n + 1 and + ( + none() + or + index = n and result = e.getMeta() + ) + ) + } + /** * INTERNAL: Do not use. * A callable. Either a `Function` or a `ClosureExpr`. @@ -301,6 +411,11 @@ module Raw { * Gets the `index`th attr of this callable (0-based). */ Attr getAttr(int index) { callable_attrs(this, index, result) } + + /** + * Gets the number of attrs of this callable. + */ + int getNumberOfAttrs() { result = count(int i | callable_attrs(this, i, _)) } } /** @@ -329,10 +444,37 @@ module Raw { */ Attr getAttr(int index) { extern_item_list_attrs(this, index, result) } + /** + * Gets the number of attrs of this extern item list. + */ + int getNumberOfAttrs() { result = count(int i | extern_item_list_attrs(this, i, _)) } + /** * Gets the `index`th extern item of this extern item list (0-based). */ ExternItem getExternItem(int index) { extern_item_list_extern_items(this, index, result) } + + /** + * Gets the number of extern items of this extern item list. + */ + int getNumberOfExternItems() { + result = count(int i | extern_item_list_extern_items(this, i, _)) + } + } + + private Element getImmediateChildOfExternItemList(ExternItemList e, int index) { + exists(int n, int nAttr, int nExternItem | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExternItem = nAttr + e.getNumberOfExternItems() and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getExternItem(index - nAttr) + ) + ) } /** @@ -373,6 +515,18 @@ module Raw { GenericParamList getGenericParamList() { for_binder_generic_param_lists(this, result) } } + private Element getImmediateChildOfForBinder(ForBinder e, int index) { + exists(int n, int nGenericParamList | + n = 0 and + nGenericParamList = n + 1 and + ( + none() + or + index = n and result = e.getGenericParamList() + ) + ) + } + /** * INTERNAL: Do not use. * A FormatArgsArg. For example the `"world"` in: @@ -394,6 +548,21 @@ module Raw { Name getName() { format_args_arg_names(this, result) } } + private Element getImmediateChildOfFormatArgsArg(FormatArgsArg e, int index) { + exists(int n, int nExpr, int nName | + n = 0 and + nExpr = n + 1 and + nName = nExpr + 1 and + ( + none() + or + index = n and result = e.getExpr() + or + index = nExpr and result = e.getName() + ) + ) + } + /** * INTERNAL: Do not use. * A generic argument in a generic argument list. @@ -420,6 +589,25 @@ module Raw { * Gets the `index`th generic argument of this generic argument list (0-based). */ GenericArg getGenericArg(int index) { generic_arg_list_generic_args(this, index, result) } + + /** + * Gets the number of generic arguments of this generic argument list. + */ + int getNumberOfGenericArgs() { + result = count(int i | generic_arg_list_generic_args(this, i, _)) + } + } + + private Element getImmediateChildOfGenericArgList(GenericArgList e, int index) { + exists(int n, int nGenericArg | + n = 0 and + nGenericArg = n + e.getNumberOfGenericArgs() and + ( + none() + or + result = e.getGenericArg(index - n) + ) + ) } /** @@ -453,6 +641,25 @@ module Raw { GenericParam getGenericParam(int index) { generic_param_list_generic_params(this, index, result) } + + /** + * Gets the number of generic parameters of this generic parameter list. + */ + int getNumberOfGenericParams() { + result = count(int i | generic_param_list_generic_params(this, i, _)) + } + } + + private Element getImmediateChildOfGenericParamList(GenericParamList e, int index) { + exists(int n, int nGenericParam | + n = 0 and + nGenericParam = n + e.getNumberOfGenericParams() and + ( + none() + or + result = e.getGenericParam(index - n) + ) + ) } /** @@ -475,10 +682,35 @@ module Raw { */ Attr getAttr(int index) { item_list_attrs(this, index, result) } + /** + * Gets the number of attrs of this item list. + */ + int getNumberOfAttrs() { result = count(int i | item_list_attrs(this, i, _)) } + /** * Gets the `index`th item of this item list (0-based). */ Item getItem(int index) { item_list_items(this, index, result) } + + /** + * Gets the number of items of this item list. + */ + int getNumberOfItems() { result = count(int i | item_list_items(this, i, _)) } + } + + private Element getImmediateChildOfItemList(ItemList e, int index) { + exists(int n, int nAttr, int nItem | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nItem = nAttr + e.getNumberOfItems() and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getItem(index - nAttr) + ) + ) } /** @@ -500,6 +732,18 @@ module Raw { Lifetime getLifetime() { label_lifetimes(this, result) } } + private Element getImmediateChildOfLabel(Label e, int index) { + exists(int n, int nLifetime | + n = 0 and + nLifetime = n + 1 and + ( + none() + or + index = n and result = e.getLifetime() + ) + ) + } + /** * INTERNAL: Do not use. * An else block in a let-else statement. @@ -521,6 +765,18 @@ module Raw { BlockExpr getBlockExpr() { let_else_block_exprs(this, result) } } + private Element getImmediateChildOfLetElse(LetElse e, int index) { + exists(int n, int nBlockExpr | + n = 0 and + nBlockExpr = n + 1 and + ( + none() + or + index = n and result = e.getBlockExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A sequence of items generated by a macro. For example: @@ -545,6 +801,23 @@ module Raw { * Gets the `index`th item of this macro items (0-based). */ Item getItem(int index) { macro_items_items(this, index, result) } + + /** + * Gets the number of items of this macro items. + */ + int getNumberOfItems() { result = count(int i | macro_items_items(this, i, _)) } + } + + private Element getImmediateChildOfMacroItems(MacroItems e, int index) { + exists(int n, int nItem | + n = 0 and + nItem = n + e.getNumberOfItems() and + ( + none() + or + result = e.getItem(index - n) + ) + ) } /** @@ -571,6 +844,11 @@ module Raw { */ Attr getAttr(int index) { match_arm_attrs(this, index, result) } + /** + * Gets the number of attrs of this match arm. + */ + int getNumberOfAttrs() { result = count(int i | match_arm_attrs(this, i, _)) } + /** * Gets the expression of this match arm, if it exists. */ @@ -587,6 +865,27 @@ module Raw { Pat getPat() { match_arm_pats(this, result) } } + private Element getImmediateChildOfMatchArm(MatchArm e, int index) { + exists(int n, int nAttr, int nExpr, int nGuard, int nPat | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + nGuard = nExpr + 1 and + nPat = nGuard + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + or + index = nExpr and result = e.getGuard() + or + index = nGuard and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A list of arms in a match expression. @@ -609,10 +908,35 @@ module Raw { */ MatchArm getArm(int index) { match_arm_list_arms(this, index, result) } + /** + * Gets the number of arms of this match arm list. + */ + int getNumberOfArms() { result = count(int i | match_arm_list_arms(this, i, _)) } + /** * Gets the `index`th attr of this match arm list (0-based). */ Attr getAttr(int index) { match_arm_list_attrs(this, index, result) } + + /** + * Gets the number of attrs of this match arm list. + */ + int getNumberOfAttrs() { result = count(int i | match_arm_list_attrs(this, i, _)) } + } + + private Element getImmediateChildOfMatchArmList(MatchArmList e, int index) { + exists(int n, int nArm, int nAttr | + n = 0 and + nArm = n + e.getNumberOfArms() and + nAttr = nArm + e.getNumberOfAttrs() and + ( + none() + or + result = e.getArm(index - n) + or + result = e.getAttr(index - nArm) + ) + ) } /** @@ -637,6 +961,18 @@ module Raw { Expr getCondition() { match_guard_conditions(this, result) } } + private Element getImmediateChildOfMatchGuard(MatchGuard e, int index) { + exists(int n, int nCondition | + n = 0 and + nCondition = n + 1 and + ( + none() + or + index = n and result = e.getCondition() + ) + ) + } + /** * INTERNAL: Do not use. * A meta item in an attribute. @@ -676,6 +1012,24 @@ module Raw { TokenTree getTokenTree() { meta_token_trees(this, result) } } + private Element getImmediateChildOfMeta(Meta e, int index) { + exists(int n, int nExpr, int nPath, int nTokenTree | + n = 0 and + nExpr = n + 1 and + nPath = nExpr + 1 and + nTokenTree = nPath + 1 and + ( + none() + or + index = n and result = e.getExpr() + or + index = nExpr and result = e.getPath() + or + index = nPath and result = e.getTokenTree() + ) + ) + } + /** * INTERNAL: Do not use. * An identifier name. @@ -695,6 +1049,8 @@ module Raw { string getText() { name_texts(this, result) } } + private Element getImmediateChildOfName(Name e, int index) { none() } + /** * INTERNAL: Do not use. * A normal parameter, `Param`, or a self parameter `SelfParam`. @@ -705,6 +1061,11 @@ module Raw { */ Attr getAttr(int index) { param_base_attrs(this, index, result) } + /** + * Gets the number of attrs of this parameter base. + */ + int getNumberOfAttrs() { result = count(int i | param_base_attrs(this, i, _)) } + /** * Gets the type representation of this parameter base, if it exists. */ @@ -729,12 +1090,32 @@ module Raw { */ Param getParam(int index) { param_list_params(this, index, result) } + /** + * Gets the number of parameters of this parameter list. + */ + int getNumberOfParams() { result = count(int i | param_list_params(this, i, _)) } + /** * Gets the self parameter of this parameter list, if it exists. */ SelfParam getSelfParam() { param_list_self_params(this, result) } } + private Element getImmediateChildOfParamList(ParamList e, int index) { + exists(int n, int nParam, int nSelfParam | + n = 0 and + nParam = n + e.getNumberOfParams() and + nSelfParam = nParam + 1 and + ( + none() + or + result = e.getParam(index - n) + or + index = nParam and result = e.getSelfParam() + ) + ) + } + /** * INTERNAL: Do not use. * A parenthesized argument list as used in function traits. @@ -757,6 +1138,25 @@ module Raw { * Gets the `index`th type argument of this parenthesized argument list (0-based). */ TypeArg getTypeArg(int index) { parenthesized_arg_list_type_args(this, index, result) } + + /** + * Gets the number of type arguments of this parenthesized argument list. + */ + int getNumberOfTypeArgs() { + result = count(int i | parenthesized_arg_list_type_args(this, i, _)) + } + } + + private Element getImmediateChildOfParenthesizedArgList(ParenthesizedArgList e, int index) { + exists(int n, int nTypeArg | + n = 0 and + nTypeArg = n + e.getNumberOfTypeArgs() and + ( + none() + or + result = e.getTypeArg(index - n) + ) + ) } /** @@ -787,6 +1187,21 @@ module Raw { PathSegment getSegment() { path_segments_(this, result) } } + private Element getImmediateChildOfPath(Path e, int index) { + exists(int n, int nQualifier, int nSegment | + n = 0 and + nQualifier = n + 1 and + nSegment = nQualifier + 1 and + ( + none() + or + index = n and result = e.getQualifier() + or + index = nQualifier and result = e.getSegment() + ) + ) + } + /** * INTERNAL: Do not use. * An AST element wrapping a path (`PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat`). @@ -849,6 +1264,39 @@ module Raw { PathTypeRepr getTraitTypeRepr() { path_segment_trait_type_reprs(this, result) } } + private Element getImmediateChildOfPathSegment(PathSegment e, int index) { + exists( + int n, int nGenericArgList, int nIdentifier, int nParenthesizedArgList, int nRetType, + int nReturnTypeSyntax, int nTypeRepr, int nTraitTypeRepr + | + n = 0 and + nGenericArgList = n + 1 and + nIdentifier = nGenericArgList + 1 and + nParenthesizedArgList = nIdentifier + 1 and + nRetType = nParenthesizedArgList + 1 and + nReturnTypeSyntax = nRetType + 1 and + nTypeRepr = nReturnTypeSyntax + 1 and + nTraitTypeRepr = nTypeRepr + 1 and + ( + none() + or + index = n and result = e.getGenericArgList() + or + index = nGenericArgList and result = e.getIdentifier() + or + index = nIdentifier and result = e.getParenthesizedArgList() + or + index = nParenthesizedArgList and result = e.getRetType() + or + index = nRetType and result = e.getReturnTypeSyntax() + or + index = nReturnTypeSyntax and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getTraitTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A rename in a use declaration. @@ -868,6 +1316,18 @@ module Raw { Name getName() { rename_names(this, result) } } + private Element getImmediateChildOfRename(Rename e, int index) { + exists(int n, int nName | + n = 0 and + nName = n + 1 and + ( + none() + or + index = n and result = e.getName() + ) + ) + } + /** * INTERNAL: Do not use. * A return type in a function signature. @@ -887,6 +1347,18 @@ module Raw { TypeRepr getTypeRepr() { ret_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfRetTypeRepr(RetTypeRepr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A return type notation `(..)` to reference or bound the type returned by a trait method @@ -911,6 +1383,8 @@ module Raw { override string toString() { result = "ReturnTypeSyntax" } } + private Element getImmediateChildOfReturnTypeSyntax(ReturnTypeSyntax e, int index) { none() } + /** * INTERNAL: Do not use. * A source file. @@ -929,10 +1403,35 @@ module Raw { */ Attr getAttr(int index) { source_file_attrs(this, index, result) } + /** + * Gets the number of attrs of this source file. + */ + int getNumberOfAttrs() { result = count(int i | source_file_attrs(this, i, _)) } + /** * Gets the `index`th item of this source file (0-based). */ Item getItem(int index) { source_file_items(this, index, result) } + + /** + * Gets the number of items of this source file. + */ + int getNumberOfItems() { result = count(int i | source_file_items(this, i, _)) } + } + + private Element getImmediateChildOfSourceFile(SourceFile e, int index) { + exists(int n, int nAttr, int nItem | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nItem = nAttr + e.getNumberOfItems() and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getItem(index - nAttr) + ) + ) } /** @@ -964,6 +1463,11 @@ module Raw { */ Attr getAttr(int index) { stmt_list_attrs(this, index, result) } + /** + * Gets the number of attrs of this statement list. + */ + int getNumberOfAttrs() { result = count(int i | stmt_list_attrs(this, i, _)) } + /** * Gets the `index`th statement of this statement list (0-based). * @@ -972,6 +1476,11 @@ module Raw { */ Stmt getStatement(int index) { stmt_list_statements(this, index, result) } + /** + * Gets the number of statements of this statement list. + */ + int getNumberOfStatements() { result = count(int i | stmt_list_statements(this, i, _)) } + /** * Gets the tail expression of this statement list, if it exists. * @@ -981,6 +1490,24 @@ module Raw { Expr getTailExpr() { stmt_list_tail_exprs(this, result) } } + private Element getImmediateChildOfStmtList(StmtList e, int index) { + exists(int n, int nAttr, int nStatement, int nTailExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nStatement = nAttr + e.getNumberOfStatements() and + nTailExpr = nStatement + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getStatement(index - nAttr) + or + index = nStatement and result = e.getTailExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A field in a struct expression. For example `a: 1` in: @@ -996,6 +1523,11 @@ module Raw { */ Attr getAttr(int index) { struct_expr_field_attrs(this, index, result) } + /** + * Gets the number of attrs of this struct expression field. + */ + int getNumberOfAttrs() { result = count(int i | struct_expr_field_attrs(this, i, _)) } + /** * Gets the expression of this struct expression field, if it exists. */ @@ -1007,6 +1539,24 @@ module Raw { NameRef getIdentifier() { struct_expr_field_identifiers(this, result) } } + private Element getImmediateChildOfStructExprField(StructExprField e, int index) { + exists(int n, int nAttr, int nExpr, int nIdentifier | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + nIdentifier = nExpr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + or + index = nExpr and result = e.getIdentifier() + ) + ) + } + /** * INTERNAL: Do not use. * A list of fields in a struct expression. @@ -1025,17 +1575,45 @@ module Raw { */ Attr getAttr(int index) { struct_expr_field_list_attrs(this, index, result) } + /** + * Gets the number of attrs of this struct expression field list. + */ + int getNumberOfAttrs() { result = count(int i | struct_expr_field_list_attrs(this, i, _)) } + /** * Gets the `index`th field of this struct expression field list (0-based). */ StructExprField getField(int index) { struct_expr_field_list_fields(this, index, result) } + /** + * Gets the number of fields of this struct expression field list. + */ + int getNumberOfFields() { result = count(int i | struct_expr_field_list_fields(this, i, _)) } + /** * Gets the spread of this struct expression field list, if it exists. */ Expr getSpread() { struct_expr_field_list_spreads(this, result) } } + private Element getImmediateChildOfStructExprFieldList(StructExprFieldList e, int index) { + exists(int n, int nAttr, int nField, int nSpread | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and + nSpread = nField + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getField(index - nAttr) + or + index = nField and result = e.getSpread() + ) + ) + } + /** * INTERNAL: Do not use. * A field in a struct declaration. @@ -1054,6 +1632,11 @@ module Raw { */ Attr getAttr(int index) { struct_field_attrs(this, index, result) } + /** + * Gets the number of attrs of this struct field. + */ + int getNumberOfAttrs() { result = count(int i | struct_field_attrs(this, i, _)) } + /** * Gets the default of this struct field, if it exists. */ @@ -1080,6 +1663,30 @@ module Raw { Visibility getVisibility() { struct_field_visibilities(this, result) } } + private Element getImmediateChildOfStructField(StructField e, int index) { + exists(int n, int nAttr, int nDefault, int nName, int nTypeRepr, int nVisibility | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nDefault = nAttr + 1 and + nName = nDefault + 1 and + nTypeRepr = nName + 1 and + nVisibility = nTypeRepr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getDefault() + or + index = nDefault and result = e.getName() + or + index = nName and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A field in a struct pattern. For example `a: 1` in: @@ -1095,6 +1702,11 @@ module Raw { */ Attr getAttr(int index) { struct_pat_field_attrs(this, index, result) } + /** + * Gets the number of attrs of this struct pattern field. + */ + int getNumberOfAttrs() { result = count(int i | struct_pat_field_attrs(this, i, _)) } + /** * Gets the identifier of this struct pattern field, if it exists. */ @@ -1106,6 +1718,24 @@ module Raw { Pat getPat() { struct_pat_field_pats(this, result) } } + private Element getImmediateChildOfStructPatField(StructPatField e, int index) { + exists(int n, int nAttr, int nIdentifier, int nPat | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nIdentifier = nAttr + 1 and + nPat = nIdentifier + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getIdentifier() + or + index = nIdentifier and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A list of fields in a struct pattern. @@ -1124,12 +1754,32 @@ module Raw { */ StructPatField getField(int index) { struct_pat_field_list_fields(this, index, result) } + /** + * Gets the number of fields of this struct pattern field list. + */ + int getNumberOfFields() { result = count(int i | struct_pat_field_list_fields(this, i, _)) } + /** * Gets the rest pattern of this struct pattern field list, if it exists. */ RestPat getRestPat() { struct_pat_field_list_rest_pats(this, result) } } + private Element getImmediateChildOfStructPatFieldList(StructPatFieldList e, int index) { + exists(int n, int nField, int nRestPat | + n = 0 and + nField = n + e.getNumberOfFields() and + nRestPat = nField + 1 and + ( + none() + or + result = e.getField(index - n) + or + index = nField and result = e.getRestPat() + ) + ) + } + /** * INTERNAL: Do not use. * The base class for all tokens. @@ -1154,6 +1804,8 @@ module Raw { override string toString() { result = "TokenTree" } } + private Element getImmediateChildOfTokenTree(TokenTree e, int index) { none() } + /** * INTERNAL: Do not use. * A field in a tuple struct or tuple enum variant. @@ -1172,6 +1824,11 @@ module Raw { */ Attr getAttr(int index) { tuple_field_attrs(this, index, result) } + /** + * Gets the number of attrs of this tuple field. + */ + int getNumberOfAttrs() { result = count(int i | tuple_field_attrs(this, i, _)) } + /** * Gets the type representation of this tuple field, if it exists. */ @@ -1183,6 +1840,24 @@ module Raw { Visibility getVisibility() { tuple_field_visibilities(this, result) } } + private Element getImmediateChildOfTupleField(TupleField e, int index) { + exists(int n, int nAttr, int nTypeRepr, int nVisibility | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nTypeRepr = nAttr + 1 and + nVisibility = nTypeRepr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A type bound in a trait or generic parameter. @@ -1229,6 +1904,27 @@ module Raw { UseBoundGenericArgs getUseBoundGenericArgs() { type_bound_use_bound_generic_args(this, result) } } + private Element getImmediateChildOfTypeBound(TypeBound e, int index) { + exists(int n, int nForBinder, int nLifetime, int nTypeRepr, int nUseBoundGenericArgs | + n = 0 and + nForBinder = n + 1 and + nLifetime = nForBinder + 1 and + nTypeRepr = nLifetime + 1 and + nUseBoundGenericArgs = nTypeRepr + 1 and + ( + none() + or + index = n and result = e.getForBinder() + or + index = nForBinder and result = e.getLifetime() + or + index = nLifetime and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getUseBoundGenericArgs() + ) + ) + } + /** * INTERNAL: Do not use. * A list of type bounds. @@ -1246,6 +1942,23 @@ module Raw { * Gets the `index`th bound of this type bound list (0-based). */ TypeBound getBound(int index) { type_bound_list_bounds(this, index, result) } + + /** + * Gets the number of bounds of this type bound list. + */ + int getNumberOfBounds() { result = count(int i | type_bound_list_bounds(this, i, _)) } + } + + private Element getImmediateChildOfTypeBoundList(TypeBoundList e, int index) { + exists(int n, int nBound | + n = 0 and + nBound = n + e.getNumberOfBounds() and + ( + none() + or + result = e.getBound(index - n) + ) + ) } /** @@ -1283,6 +1996,25 @@ module Raw { UseBoundGenericArg getUseBoundGenericArg(int index) { use_bound_generic_args_use_bound_generic_args(this, index, result) } + + /** + * Gets the number of use bound generic arguments of this use bound generic arguments. + */ + int getNumberOfUseBoundGenericArgs() { + result = count(int i | use_bound_generic_args_use_bound_generic_args(this, i, _)) + } + } + + private Element getImmediateChildOfUseBoundGenericArgs(UseBoundGenericArgs e, int index) { + exists(int n, int nUseBoundGenericArg | + n = 0 and + nUseBoundGenericArg = n + e.getNumberOfUseBoundGenericArgs() and + ( + none() + or + result = e.getUseBoundGenericArg(index - n) + ) + ) } /** @@ -1319,6 +2051,24 @@ module Raw { UseTreeList getUseTreeList() { use_tree_use_tree_lists(this, result) } } + private Element getImmediateChildOfUseTree(UseTree e, int index) { + exists(int n, int nPath, int nRename, int nUseTreeList | + n = 0 and + nPath = n + 1 and + nRename = nPath + 1 and + nUseTreeList = nRename + 1 and + ( + none() + or + index = n and result = e.getPath() + or + index = nPath and result = e.getRename() + or + index = nRename and result = e.getUseTreeList() + ) + ) + } + /** * INTERNAL: Do not use. * A list of use trees in a use declaration. @@ -1336,6 +2086,23 @@ module Raw { * Gets the `index`th use tree of this use tree list (0-based). */ UseTree getUseTree(int index) { use_tree_list_use_trees(this, index, result) } + + /** + * Gets the number of use trees of this use tree list. + */ + int getNumberOfUseTrees() { result = count(int i | use_tree_list_use_trees(this, i, _)) } + } + + private Element getImmediateChildOfUseTreeList(UseTreeList e, int index) { + exists(int n, int nUseTree | + n = 0 and + nUseTree = n + e.getNumberOfUseTrees() and + ( + none() + or + result = e.getUseTree(index - n) + ) + ) } /** @@ -1355,6 +2122,23 @@ module Raw { * Gets the `index`th variant of this variant list (0-based). */ Variant getVariant(int index) { variant_list_variants(this, index, result) } + + /** + * Gets the number of variants of this variant list. + */ + int getNumberOfVariants() { result = count(int i | variant_list_variants(this, i, _)) } + } + + private Element getImmediateChildOfVariantList(VariantList e, int index) { + exists(int n, int nVariant | + n = 0 and + nVariant = n + e.getNumberOfVariants() and + ( + none() + or + result = e.getVariant(index - n) + ) + ) } /** @@ -1376,6 +2160,18 @@ module Raw { Path getPath() { visibility_paths(this, result) } } + private Element getImmediateChildOfVisibility(Visibility e, int index) { + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and + ( + none() + or + index = n and result = e.getPath() + ) + ) + } + /** * INTERNAL: Do not use. * A where clause in a generic declaration. @@ -1393,6 +2189,23 @@ module Raw { * Gets the `index`th predicate of this where clause (0-based). */ WherePred getPredicate(int index) { where_clause_predicates(this, index, result) } + + /** + * Gets the number of predicates of this where clause. + */ + int getNumberOfPredicates() { result = count(int i | where_clause_predicates(this, i, _)) } + } + + private Element getImmediateChildOfWhereClause(WhereClause e, int index) { + exists(int n, int nPredicate | + n = 0 and + nPredicate = n + e.getNumberOfPredicates() and + ( + none() + or + result = e.getPredicate(index - n) + ) + ) } /** @@ -1431,6 +2244,27 @@ module Raw { TypeBoundList getTypeBoundList() { where_pred_type_bound_lists(this, result) } } + private Element getImmediateChildOfWherePred(WherePred e, int index) { + exists(int n, int nForBinder, int nLifetime, int nTypeRepr, int nTypeBoundList | + n = 0 and + nForBinder = n + 1 and + nLifetime = nForBinder + 1 and + nTypeRepr = nLifetime + 1 and + nTypeBoundList = nTypeRepr + 1 and + ( + none() + or + index = n and result = e.getForBinder() + or + index = nForBinder and result = e.getLifetime() + or + index = nLifetime and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1442,17 +2276,42 @@ module Raw { */ Attr getAttr(int index) { array_expr_internal_attrs(this, index, result) } + /** + * Gets the number of attrs of this array expression internal. + */ + int getNumberOfAttrs() { result = count(int i | array_expr_internal_attrs(this, i, _)) } + /** * Gets the `index`th expression of this array expression internal (0-based). */ Expr getExpr(int index) { array_expr_internal_exprs(this, index, result) } + /** + * Gets the number of expressions of this array expression internal. + */ + int getNumberOfExprs() { result = count(int i | array_expr_internal_exprs(this, i, _)) } + /** * Holds if this array expression internal is semicolon. */ predicate isSemicolon() { array_expr_internal_is_semicolon(this) } } + private Element getImmediateChildOfArrayExprInternal(ArrayExprInternal e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + e.getNumberOfExprs() and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getExpr(index - nAttr) + ) + ) + } + /** * INTERNAL: Do not use. * An array type representation. @@ -1477,6 +2336,21 @@ module Raw { TypeRepr getElementTypeRepr() { array_type_repr_element_type_reprs(this, result) } } + private Element getImmediateChildOfArrayTypeRepr(ArrayTypeRepr e, int index) { + exists(int n, int nConstArg, int nElementTypeRepr | + n = 0 and + nConstArg = n + 1 and + nElementTypeRepr = nConstArg + 1 and + ( + none() + or + index = n and result = e.getConstArg() + or + index = nConstArg and result = e.getElementTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A clobbered ABI in an inline assembly block. @@ -1492,6 +2366,8 @@ module Raw { override string toString() { result = "AsmClobberAbi" } } + private Element getImmediateChildOfAsmClobberAbi(AsmClobberAbi e, int index) { none() } + /** * INTERNAL: Do not use. * A constant operand in an inline assembly block. @@ -1517,6 +2393,18 @@ module Raw { predicate isConst() { asm_const_is_const(this) } } + private Element getImmediateChildOfAsmConst(AsmConst e, int index) { + exists(int n, int nExpr | + n = 0 and + nExpr = n + 1 and + ( + none() + or + index = n and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A label in an inline assembly block. @@ -1540,6 +2428,18 @@ module Raw { BlockExpr getBlockExpr() { asm_label_block_exprs(this, result) } } + private Element getImmediateChildOfAsmLabel(AsmLabel e, int index) { + exists(int n, int nBlockExpr | + n = 0 and + nBlockExpr = n + 1 and + ( + none() + or + index = n and result = e.getBlockExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A named operand in an inline assembly block. @@ -1565,6 +2465,21 @@ module Raw { Name getName() { asm_operand_named_names(this, result) } } + private Element getImmediateChildOfAsmOperandNamed(AsmOperandNamed e, int index) { + exists(int n, int nAsmOperand, int nName | + n = 0 and + nAsmOperand = n + 1 and + nName = nAsmOperand + 1 and + ( + none() + or + index = n and result = e.getAsmOperand() + or + index = nAsmOperand and result = e.getName() + ) + ) + } + /** * INTERNAL: Do not use. * A list of options in an inline assembly block. @@ -1583,6 +2498,23 @@ module Raw { * Gets the `index`th asm option of this asm options list (0-based). */ AsmOption getAsmOption(int index) { asm_options_list_asm_options(this, index, result) } + + /** + * Gets the number of asm options of this asm options list. + */ + int getNumberOfAsmOptions() { result = count(int i | asm_options_list_asm_options(this, i, _)) } + } + + private Element getImmediateChildOfAsmOptionsList(AsmOptionsList e, int index) { + exists(int n, int nAsmOption | + n = 0 and + nAsmOption = n + e.getNumberOfAsmOptions() and + ( + none() + or + result = e.getAsmOption(index - n) + ) + ) } /** @@ -1615,6 +2547,24 @@ module Raw { AsmRegSpec getAsmRegSpec() { asm_reg_operand_asm_reg_specs(this, result) } } + private Element getImmediateChildOfAsmRegOperand(AsmRegOperand e, int index) { + exists(int n, int nAsmDirSpec, int nAsmOperandExpr, int nAsmRegSpec | + n = 0 and + nAsmDirSpec = n + 1 and + nAsmOperandExpr = nAsmDirSpec + 1 and + nAsmRegSpec = nAsmOperandExpr + 1 and + ( + none() + or + index = n and result = e.getAsmDirSpec() + or + index = nAsmDirSpec and result = e.getAsmOperandExpr() + or + index = nAsmOperandExpr and result = e.getAsmRegSpec() + ) + ) + } + /** * INTERNAL: Do not use. * A symbol operand in an inline assembly block. @@ -1635,6 +2585,18 @@ module Raw { Path getPath() { asm_sym_paths(this, result) } } + private Element getImmediateChildOfAsmSym(AsmSym e, int index) { + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and + ( + none() + or + index = n and result = e.getPath() + ) + ) + } + /** * INTERNAL: Do not use. * An associated type argument in a path. @@ -1694,6 +2656,42 @@ module Raw { TypeBoundList getTypeBoundList() { assoc_type_arg_type_bound_lists(this, result) } } + private Element getImmediateChildOfAssocTypeArg(AssocTypeArg e, int index) { + exists( + int n, int nConstArg, int nGenericArgList, int nIdentifier, int nParamList, int nRetType, + int nReturnTypeSyntax, int nTypeRepr, int nTypeBoundList + | + n = 0 and + nConstArg = n + 1 and + nGenericArgList = nConstArg + 1 and + nIdentifier = nGenericArgList + 1 and + nParamList = nIdentifier + 1 and + nRetType = nParamList + 1 and + nReturnTypeSyntax = nRetType + 1 and + nTypeRepr = nReturnTypeSyntax + 1 and + nTypeBoundList = nTypeRepr + 1 and + ( + none() + or + index = n and result = e.getConstArg() + or + index = nConstArg and result = e.getGenericArgList() + or + index = nGenericArgList and result = e.getIdentifier() + or + index = nIdentifier and result = e.getParamList() + or + index = nParamList and result = e.getRetType() + or + index = nRetType and result = e.getReturnTypeSyntax() + or + index = nReturnTypeSyntax and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. * An `await` expression. For example: @@ -1712,12 +2710,32 @@ module Raw { */ Attr getAttr(int index) { await_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this await expression. + */ + int getNumberOfAttrs() { result = count(int i | await_expr_attrs(this, i, _)) } + /** * Gets the expression of this await expression, if it exists. */ Expr getExpr() { await_expr_exprs(this, result) } } + private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A `become` expression. For example: @@ -1739,12 +2757,32 @@ module Raw { */ Attr getAttr(int index) { become_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this become expression. + */ + int getNumberOfAttrs() { result = count(int i | become_expr_attrs(this, i, _)) } + /** * Gets the expression of this become expression, if it exists. */ Expr getExpr() { become_expr_exprs(this, result) } } + private Element getImmediateChildOfBecomeExpr(BecomeExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A binary operation expression. For example: @@ -1764,6 +2802,11 @@ module Raw { */ Attr getAttr(int index) { binary_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this binary expression. + */ + int getNumberOfAttrs() { result = count(int i | binary_expr_attrs(this, i, _)) } + /** * Gets the lhs of this binary expression, if it exists. */ @@ -1780,6 +2823,24 @@ module Raw { Expr getRhs() { binary_expr_rhs(this, result) } } + private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index) { + exists(int n, int nAttr, int nLhs, int nRhs | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nLhs = nAttr + 1 and + nRhs = nLhs + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getLhs() + or + index = nLhs and result = e.getRhs() + ) + ) + } + /** * INTERNAL: Do not use. * A box pattern. For example: @@ -1799,6 +2860,18 @@ module Raw { Pat getPat() { box_pat_pats(this, result) } } + private Element getImmediateChildOfBoxPat(BoxPat e, int index) { + exists(int n, int nPat | + n = 0 and + nPat = n + 1 and + ( + none() + or + index = n and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A break expression. For example: @@ -1833,6 +2906,11 @@ module Raw { */ Attr getAttr(int index) { break_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this break expression. + */ + int getNumberOfAttrs() { result = count(int i | break_expr_attrs(this, i, _)) } + /** * Gets the expression of this break expression, if it exists. */ @@ -1844,6 +2922,24 @@ module Raw { Lifetime getLifetime() { break_expr_lifetimes(this, result) } } + private Element getImmediateChildOfBreakExpr(BreakExpr e, int index) { + exists(int n, int nAttr, int nExpr, int nLifetime | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + nLifetime = nExpr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + or + index = nExpr and result = e.getLifetime() + ) + ) + } + /** * INTERNAL: Do not use. * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. @@ -1858,6 +2954,11 @@ module Raw { * Gets the `index`th attr of this call expression base (0-based). */ Attr getAttr(int index) { call_expr_base_attrs(this, index, result) } + + /** + * Gets the number of attrs of this call expression base. + */ + int getNumberOfAttrs() { result = count(int i | call_expr_base_attrs(this, i, _)) } } /** @@ -1875,6 +2976,11 @@ module Raw { */ Attr getAttr(int index) { cast_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this cast expression. + */ + int getNumberOfAttrs() { result = count(int i | cast_expr_attrs(this, i, _)) } + /** * Gets the expression of this cast expression, if it exists. */ @@ -1886,6 +2992,24 @@ module Raw { TypeRepr getTypeRepr() { cast_expr_type_reprs(this, result) } } + private Element getImmediateChildOfCastExpr(CastExpr e, int index) { + exists(int n, int nAttr, int nExpr, int nTypeRepr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + nTypeRepr = nExpr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + or + index = nExpr and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A closure expression. For example: @@ -1946,6 +3070,30 @@ module Raw { RetTypeRepr getRetType() { closure_expr_ret_types(this, result) } } + private Element getImmediateChildOfClosureExpr(ClosureExpr e, int index) { + exists(int n, int nParamList, int nAttr, int nClosureBody, int nForBinder, int nRetType | + n = 0 and + nParamList = n + 1 and + nAttr = nParamList + e.getNumberOfAttrs() and + nClosureBody = nAttr + 1 and + nForBinder = nClosureBody + 1 and + nRetType = nForBinder + 1 and + ( + none() + or + index = n and result = e.getParamList() + or + result = e.getAttr(index - nParamList) + or + index = nAttr and result = e.getClosureBody() + or + index = nClosureBody and result = e.getForBinder() + or + index = nForBinder and result = e.getRetType() + ) + ) + } + /** * INTERNAL: Do not use. * A comment. For example: @@ -1968,6 +3116,8 @@ module Raw { string getText() { comments(this, _, result) } } + private Element getImmediateChildOfComment(Comment e, int index) { none() } + /** * INTERNAL: Do not use. * A constant argument in a generic argument list. @@ -1987,6 +3137,18 @@ module Raw { Expr getExpr() { const_arg_exprs(this, result) } } + private Element getImmediateChildOfConstArg(ConstArg e, int index) { + exists(int n, int nExpr | + n = 0 and + nExpr = n + 1 and + ( + none() + or + index = n and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A const block pattern. For example: @@ -2011,6 +3173,18 @@ module Raw { predicate isConst() { const_block_pat_is_const(this) } } + private Element getImmediateChildOfConstBlockPat(ConstBlockPat e, int index) { + exists(int n, int nBlockExpr | + n = 0 and + nBlockExpr = n + 1 and + ( + none() + or + index = n and result = e.getBlockExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A constant parameter in a generic parameter list. @@ -2029,6 +3203,11 @@ module Raw { */ Attr getAttr(int index) { const_param_attrs(this, index, result) } + /** + * Gets the number of attrs of this const parameter. + */ + int getNumberOfAttrs() { result = count(int i | const_param_attrs(this, i, _)) } + /** * Gets the default val of this const parameter, if it exists. */ @@ -2050,6 +3229,27 @@ module Raw { TypeRepr getTypeRepr() { const_param_type_reprs(this, result) } } + private Element getImmediateChildOfConstParam(ConstParam e, int index) { + exists(int n, int nAttr, int nDefaultVal, int nName, int nTypeRepr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nDefaultVal = nAttr + 1 and + nName = nDefaultVal + 1 and + nTypeRepr = nName + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getDefaultVal() + or + index = nDefaultVal and result = e.getName() + or + index = nName and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A continue expression. For example: @@ -2076,12 +3276,32 @@ module Raw { */ Attr getAttr(int index) { continue_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this continue expression. + */ + int getNumberOfAttrs() { result = count(int i | continue_expr_attrs(this, i, _)) } + /** * Gets the lifetime of this continue expression, if it exists. */ Lifetime getLifetime() { continue_expr_lifetimes(this, result) } } + private Element getImmediateChildOfContinueExpr(ContinueExpr e, int index) { + exists(int n, int nAttr, int nLifetime | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nLifetime = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getLifetime() + ) + ) + } + /** * INTERNAL: Do not use. * A dynamic trait object type. @@ -2101,6 +3321,18 @@ module Raw { TypeBoundList getTypeBoundList() { dyn_trait_type_repr_type_bound_lists(this, result) } } + private Element getImmediateChildOfDynTraitTypeRepr(DynTraitTypeRepr e, int index) { + exists(int n, int nTypeBoundList | + n = 0 and + nTypeBoundList = n + 1 and + ( + none() + or + index = n and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. * An expression statement. For example: @@ -2119,6 +3351,18 @@ module Raw { Expr getExpr() { expr_stmt_exprs(this, result) } } + private Element getImmediateChildOfExprStmt(ExprStmt e, int index) { + exists(int n, int nExpr | + n = 0 and + nExpr = n + 1 and + ( + none() + or + index = n and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A field access expression. For example: @@ -2134,6 +3378,11 @@ module Raw { */ Attr getAttr(int index) { field_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this field expression. + */ + int getNumberOfAttrs() { result = count(int i | field_expr_attrs(this, i, _)) } + /** * Gets the container of this field expression, if it exists. */ @@ -2145,6 +3394,24 @@ module Raw { NameRef getIdentifier() { field_expr_identifiers(this, result) } } + private Element getImmediateChildOfFieldExpr(FieldExpr e, int index) { + exists(int n, int nAttr, int nContainer, int nIdentifier | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nContainer = nAttr + 1 and + nIdentifier = nContainer + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getContainer() + or + index = nContainer and result = e.getIdentifier() + ) + ) + } + /** * INTERNAL: Do not use. * A function pointer type. @@ -2189,6 +3456,24 @@ module Raw { RetTypeRepr getRetType() { fn_ptr_type_repr_ret_types(this, result) } } + private Element getImmediateChildOfFnPtrTypeRepr(FnPtrTypeRepr e, int index) { + exists(int n, int nAbi, int nParamList, int nRetType | + n = 0 and + nAbi = n + 1 and + nParamList = nAbi + 1 and + nRetType = nParamList + 1 and + ( + none() + or + index = n and result = e.getAbi() + or + index = nAbi and result = e.getParamList() + or + index = nParamList and result = e.getRetType() + ) + ) + } + /** * INTERNAL: Do not use. * A function pointer type with a `for` modifier. @@ -2213,6 +3498,21 @@ module Raw { TypeRepr getTypeRepr() { for_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfForTypeRepr(ForTypeRepr e, int index) { + exists(int n, int nForBinder, int nTypeRepr | + n = 0 and + nForBinder = n + 1 and + nTypeRepr = nForBinder + 1 and + ( + none() + or + index = n and result = e.getForBinder() + or + index = nForBinder and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A FormatArgsExpr. For example: @@ -2232,17 +3532,46 @@ module Raw { */ FormatArgsArg getArg(int index) { format_args_expr_args(this, index, result) } + /** + * Gets the number of arguments of this format arguments expression. + */ + int getNumberOfArgs() { result = count(int i | format_args_expr_args(this, i, _)) } + /** * Gets the `index`th attr of this format arguments expression (0-based). */ Attr getAttr(int index) { format_args_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this format arguments expression. + */ + int getNumberOfAttrs() { result = count(int i | format_args_expr_attrs(this, i, _)) } + /** * Gets the template of this format arguments expression, if it exists. */ Expr getTemplate() { format_args_expr_templates(this, result) } } + private Element getImmediateChildOfFormatArgsExpr(FormatArgsExpr e, int index) { + exists(int n, int nArg, int nAttr, int nTemplate, int nFormat | + n = 0 and + nArg = n + e.getNumberOfArgs() and + nAttr = nArg + e.getNumberOfAttrs() and + nTemplate = nAttr + 1 and + nFormat = nTemplate and + ( + none() + or + result = e.getArg(index - n) + or + result = e.getAttr(index - nArg) + or + index = nAttr and result = e.getTemplate() + ) + ) + } + /** * INTERNAL: Do not use. * A binding pattern. For example: @@ -2267,6 +3596,11 @@ module Raw { */ Attr getAttr(int index) { ident_pat_attrs(this, index, result) } + /** + * Gets the number of attrs of this ident pattern. + */ + int getNumberOfAttrs() { result = count(int i | ident_pat_attrs(this, i, _)) } + /** * Holds if this ident pattern is mut. */ @@ -2288,6 +3622,24 @@ module Raw { Pat getPat() { ident_pat_pats(this, result) } } + private Element getImmediateChildOfIdentPat(IdentPat e, int index) { + exists(int n, int nAttr, int nName, int nPat | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nName = nAttr + 1 and + nPat = nName + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getName() + or + index = nName and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * An `if` expression. For example: @@ -2312,6 +3664,11 @@ module Raw { */ Attr getAttr(int index) { if_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this if expression. + */ + int getNumberOfAttrs() { result = count(int i | if_expr_attrs(this, i, _)) } + /** * Gets the condition of this if expression, if it exists. */ @@ -2328,6 +3685,27 @@ module Raw { BlockExpr getThen() { if_expr_thens(this, result) } } + private Element getImmediateChildOfIfExpr(IfExpr e, int index) { + exists(int n, int nAttr, int nCondition, int nElse, int nThen | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nCondition = nAttr + 1 and + nElse = nCondition + 1 and + nThen = nElse + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getCondition() + or + index = nCondition and result = e.getElse() + or + index = nElse and result = e.getThen() + ) + ) + } + /** * INTERNAL: Do not use. * An `impl Trait` type. @@ -2347,6 +3725,18 @@ module Raw { TypeBoundList getTypeBoundList() { impl_trait_type_repr_type_bound_lists(this, result) } } + private Element getImmediateChildOfImplTraitTypeRepr(ImplTraitTypeRepr e, int index) { + exists(int n, int nTypeBoundList | + n = 0 and + nTypeBoundList = n + 1 and + ( + none() + or + index = n and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. * An index expression. For example: @@ -2363,6 +3753,11 @@ module Raw { */ Attr getAttr(int index) { index_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this index expression. + */ + int getNumberOfAttrs() { result = count(int i | index_expr_attrs(this, i, _)) } + /** * Gets the base of this index expression, if it exists. */ @@ -2374,6 +3769,24 @@ module Raw { Expr getIndex() { index_expr_indices(this, result) } } + private Element getImmediateChildOfIndexExpr(IndexExpr e, int index) { + exists(int n, int nAttr, int nBase, int nIndex | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nBase = nAttr + 1 and + nIndex = nBase + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getBase() + or + index = nBase and result = e.getIndex() + ) + ) + } + /** * INTERNAL: Do not use. * An inferred type (`_`). @@ -2388,6 +3801,8 @@ module Raw { override string toString() { result = "InferTypeRepr" } } + private Element getImmediateChildOfInferTypeRepr(InferTypeRepr e, int index) { none() } + /** * INTERNAL: Do not use. * An item such as a function, struct, enum, etc. @@ -2434,6 +3849,11 @@ module Raw { */ Attr getAttr(int index) { let_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this let expression. + */ + int getNumberOfAttrs() { result = count(int i | let_expr_attrs(this, i, _)) } + /** * Gets the scrutinee of this let expression, if it exists. */ @@ -2445,6 +3865,24 @@ module Raw { Pat getPat() { let_expr_pats(this, result) } } + private Element getImmediateChildOfLetExpr(LetExpr e, int index) { + exists(int n, int nAttr, int nScrutinee, int nPat | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nScrutinee = nAttr + 1 and + nPat = nScrutinee + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getScrutinee() + or + index = nScrutinee and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A let statement. For example: @@ -2467,6 +3905,11 @@ module Raw { */ Attr getAttr(int index) { let_stmt_attrs(this, index, result) } + /** + * Gets the number of attrs of this let statement. + */ + int getNumberOfAttrs() { result = count(int i | let_stmt_attrs(this, i, _)) } + /** * Gets the initializer of this let statement, if it exists. */ @@ -2488,6 +3931,30 @@ module Raw { TypeRepr getTypeRepr() { let_stmt_type_reprs(this, result) } } + private Element getImmediateChildOfLetStmt(LetStmt e, int index) { + exists(int n, int nAttr, int nInitializer, int nLetElse, int nPat, int nTypeRepr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nInitializer = nAttr + 1 and + nLetElse = nInitializer + 1 and + nPat = nLetElse + 1 and + nTypeRepr = nPat + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getInitializer() + or + index = nInitializer and result = e.getLetElse() + or + index = nLetElse and result = e.getPat() + or + index = nPat and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A lifetime annotation. @@ -2507,6 +3974,8 @@ module Raw { string getText() { lifetime_texts(this, result) } } + private Element getImmediateChildOfLifetime(Lifetime e, int index) { none() } + /** * INTERNAL: Do not use. * A lifetime argument in a generic argument list. @@ -2526,6 +3995,18 @@ module Raw { Lifetime getLifetime() { lifetime_arg_lifetimes(this, result) } } + private Element getImmediateChildOfLifetimeArg(LifetimeArg e, int index) { + exists(int n, int nLifetime | + n = 0 and + nLifetime = n + 1 and + ( + none() + or + index = n and result = e.getLifetime() + ) + ) + } + /** * INTERNAL: Do not use. * A lifetime parameter in a generic parameter list. @@ -2544,6 +4025,11 @@ module Raw { */ Attr getAttr(int index) { lifetime_param_attrs(this, index, result) } + /** + * Gets the number of attrs of this lifetime parameter. + */ + int getNumberOfAttrs() { result = count(int i | lifetime_param_attrs(this, i, _)) } + /** * Gets the lifetime of this lifetime parameter, if it exists. */ @@ -2555,6 +4041,24 @@ module Raw { TypeBoundList getTypeBoundList() { lifetime_param_type_bound_lists(this, result) } } + private Element getImmediateChildOfLifetimeParam(LifetimeParam e, int index) { + exists(int n, int nAttr, int nLifetime, int nTypeBoundList | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nLifetime = nAttr + 1 and + nTypeBoundList = nLifetime + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getLifetime() + or + index = nLifetime and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. * A literal expression. For example: @@ -2577,12 +4081,29 @@ module Raw { */ Attr getAttr(int index) { literal_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this literal expression. + */ + int getNumberOfAttrs() { result = count(int i | literal_expr_attrs(this, i, _)) } + /** * Gets the text value of this literal expression, if it exists. */ string getTextValue() { literal_expr_text_values(this, result) } } + private Element getImmediateChildOfLiteralExpr(LiteralExpr e, int index) { + exists(int n, int nAttr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + ( + none() + or + result = e.getAttr(index - n) + ) + ) + } + /** * INTERNAL: Do not use. * A literal pattern. For example: @@ -2602,6 +4123,18 @@ module Raw { LiteralExpr getLiteral() { literal_pat_literals(this, result) } } + private Element getImmediateChildOfLiteralPat(LiteralPat e, int index) { + exists(int n, int nLiteral | + n = 0 and + nLiteral = n + 1 and + ( + none() + or + index = n and result = e.getLiteral() + ) + ) + } + /** * INTERNAL: Do not use. * A sequence of statements generated by a `MacroCall`. For example: @@ -2625,12 +4158,32 @@ module Raw { */ Stmt getStatement(int index) { macro_block_expr_statements(this, index, result) } + /** + * Gets the number of statements of this macro block expression. + */ + int getNumberOfStatements() { result = count(int i | macro_block_expr_statements(this, i, _)) } + /** * Gets the tail expression of this macro block expression, if it exists. */ Expr getTailExpr() { macro_block_expr_tail_exprs(this, result) } } + private Element getImmediateChildOfMacroBlockExpr(MacroBlockExpr e, int index) { + exists(int n, int nStatement, int nTailExpr | + n = 0 and + nStatement = n + e.getNumberOfStatements() and + nTailExpr = nStatement + 1 and + ( + none() + or + result = e.getStatement(index - n) + or + index = nStatement and result = e.getTailExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A macro expression, representing the invocation of a macro that produces an expression. @@ -2649,6 +4202,18 @@ module Raw { MacroCall getMacroCall() { macro_expr_macro_calls(this, result) } } + private Element getImmediateChildOfMacroExpr(MacroExpr e, int index) { + exists(int n, int nMacroCall | + n = 0 and + nMacroCall = n + 1 and + ( + none() + or + index = n and result = e.getMacroCall() + ) + ) + } + /** * INTERNAL: Do not use. * A macro pattern, representing the invocation of a macro that produces a pattern. @@ -2676,6 +4241,18 @@ module Raw { MacroCall getMacroCall() { macro_pat_macro_calls(this, result) } } + private Element getImmediateChildOfMacroPat(MacroPat e, int index) { + exists(int n, int nMacroCall | + n = 0 and + nMacroCall = n + 1 and + ( + none() + or + index = n and result = e.getMacroCall() + ) + ) + } + /** * INTERNAL: Do not use. * A type produced by a macro. @@ -2698,6 +4275,18 @@ module Raw { MacroCall getMacroCall() { macro_type_repr_macro_calls(this, result) } } + private Element getImmediateChildOfMacroTypeRepr(MacroTypeRepr e, int index) { + exists(int n, int nMacroCall | + n = 0 and + nMacroCall = n + 1 and + ( + none() + or + index = n and result = e.getMacroCall() + ) + ) + } + /** * INTERNAL: Do not use. * A match expression. For example: @@ -2722,6 +4311,11 @@ module Raw { */ Attr getAttr(int index) { match_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this match expression. + */ + int getNumberOfAttrs() { result = count(int i | match_expr_attrs(this, i, _)) } + /** * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ @@ -2733,6 +4327,24 @@ module Raw { MatchArmList getMatchArmList() { match_expr_match_arm_lists(this, result) } } + private Element getImmediateChildOfMatchExpr(MatchExpr e, int index) { + exists(int n, int nAttr, int nScrutinee, int nMatchArmList | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nScrutinee = nAttr + 1 and + nMatchArmList = nScrutinee + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getScrutinee() + or + index = nScrutinee and result = e.getMatchArmList() + ) + ) + } + /** * INTERNAL: Do not use. * A reference to a name. @@ -2752,6 +4364,8 @@ module Raw { string getText() { name_ref_texts(this, result) } } + private Element getImmediateChildOfNameRef(NameRef e, int index) { none() } + /** * INTERNAL: Do not use. * The never type `!`. @@ -2766,6 +4380,8 @@ module Raw { override string toString() { result = "NeverTypeRepr" } } + private Element getImmediateChildOfNeverTypeRepr(NeverTypeRepr e, int index) { none() } + /** * INTERNAL: Do not use. * An `offset_of` expression. For example: @@ -2781,17 +4397,45 @@ module Raw { */ Attr getAttr(int index) { offset_of_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this offset of expression. + */ + int getNumberOfAttrs() { result = count(int i | offset_of_expr_attrs(this, i, _)) } + /** * Gets the `index`th field of this offset of expression (0-based). */ NameRef getField(int index) { offset_of_expr_fields(this, index, result) } + /** + * Gets the number of fields of this offset of expression. + */ + int getNumberOfFields() { result = count(int i | offset_of_expr_fields(this, i, _)) } + /** * Gets the type representation of this offset of expression, if it exists. */ TypeRepr getTypeRepr() { offset_of_expr_type_reprs(this, result) } } + private Element getImmediateChildOfOffsetOfExpr(OffsetOfExpr e, int index) { + exists(int n, int nAttr, int nField, int nTypeRepr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and + nTypeRepr = nField + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getField(index - nAttr) + or + index = nField and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * An or pattern. For example: @@ -2807,7 +4451,24 @@ module Raw { /** * Gets the `index`th pattern of this or pattern (0-based). */ - Pat getPat(int index) { or_pat_pats(this, index, result) } + Pat getPat(int index) { or_pat_pats(this, index, result) } + + /** + * Gets the number of patterns of this or pattern. + */ + int getNumberOfPats() { result = count(int i | or_pat_pats(this, i, _)) } + } + + private Element getImmediateChildOfOrPat(OrPat e, int index) { + exists(int n, int nPat | + n = 0 and + nPat = n + e.getNumberOfPats() and + ( + none() + or + result = e.getPat(index - n) + ) + ) } /** @@ -2828,6 +4489,24 @@ module Raw { Pat getPat() { param_pats(this, result) } } + private Element getImmediateChildOfParam(Param e, int index) { + exists(int n, int nAttr, int nTypeRepr, int nPat | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nTypeRepr = nAttr + 1 and + nPat = nTypeRepr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A parenthesized expression. @@ -2845,12 +4524,32 @@ module Raw { */ Attr getAttr(int index) { paren_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this paren expression. + */ + int getNumberOfAttrs() { result = count(int i | paren_expr_attrs(this, i, _)) } + /** * Gets the expression of this paren expression, if it exists. */ Expr getExpr() { paren_expr_exprs(this, result) } } + private Element getImmediateChildOfParenExpr(ParenExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A parenthesized pattern. @@ -2870,6 +4569,18 @@ module Raw { Pat getPat() { paren_pat_pats(this, result) } } + private Element getImmediateChildOfParenPat(ParenPat e, int index) { + exists(int n, int nPat | + n = 0 and + nPat = n + 1 and + ( + none() + or + index = n and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A parenthesized type. @@ -2889,6 +4600,18 @@ module Raw { TypeRepr getTypeRepr() { paren_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfParenTypeRepr(ParenTypeRepr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A path expression or a variable access in a formatting template. See `PathExpr` and `FormatTemplateVariableAccess` for further details. @@ -2909,6 +4632,18 @@ module Raw { override string toString() { result = "PathPat" } } + private Element getImmediateChildOfPathPat(PathPat e, int index) { + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and + ( + none() + or + index = n and result = e.getPath() + ) + ) + } + /** * INTERNAL: Do not use. * A path referring to a type. For example: @@ -2926,6 +4661,18 @@ module Raw { Path getPath() { path_type_repr_paths(this, result) } } + private Element getImmediateChildOfPathTypeRepr(PathTypeRepr e, int index) { + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and + ( + none() + or + index = n and result = e.getPath() + ) + ) + } + /** * INTERNAL: Do not use. * A unary operation expression. For example: @@ -2943,6 +4690,11 @@ module Raw { */ Attr getAttr(int index) { prefix_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this prefix expression. + */ + int getNumberOfAttrs() { result = count(int i | prefix_expr_attrs(this, i, _)) } + /** * Gets the expression of this prefix expression, if it exists. */ @@ -2954,6 +4706,21 @@ module Raw { string getOperatorName() { prefix_expr_operator_names(this, result) } } + private Element getImmediateChildOfPrefixExpr(PrefixExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A pointer type. @@ -2984,6 +4751,18 @@ module Raw { TypeRepr getTypeRepr() { ptr_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfPtrTypeRepr(PtrTypeRepr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A range expression. For example: @@ -3004,6 +4783,11 @@ module Raw { */ Attr getAttr(int index) { range_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this range expression. + */ + int getNumberOfAttrs() { result = count(int i | range_expr_attrs(this, i, _)) } + /** * Gets the end of this range expression, if it exists. */ @@ -3020,6 +4804,24 @@ module Raw { Expr getStart() { range_expr_starts(this, result) } } + private Element getImmediateChildOfRangeExpr(RangeExpr e, int index) { + exists(int n, int nAttr, int nEnd, int nStart | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nEnd = nAttr + 1 and + nStart = nEnd + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getEnd() + or + index = nEnd and result = e.getStart() + ) + ) + } + /** * INTERNAL: Do not use. * A range pattern. For example: @@ -3050,6 +4852,21 @@ module Raw { Pat getStart() { range_pat_starts(this, result) } } + private Element getImmediateChildOfRangePat(RangePat e, int index) { + exists(int n, int nEnd, int nStart | + n = 0 and + nEnd = n + 1 and + nStart = nEnd + 1 and + ( + none() + or + index = n and result = e.getEnd() + or + index = nEnd and result = e.getStart() + ) + ) + } + /** * INTERNAL: Do not use. * A reference expression. For example: @@ -3068,6 +4885,11 @@ module Raw { */ Attr getAttr(int index) { ref_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this reference expression. + */ + int getNumberOfAttrs() { result = count(int i | ref_expr_attrs(this, i, _)) } + /** * Gets the expression of this reference expression, if it exists. */ @@ -3089,6 +4911,21 @@ module Raw { predicate isRaw() { ref_expr_is_raw(this) } } + private Element getImmediateChildOfRefExpr(RefExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A reference pattern. For example: @@ -3113,6 +4950,18 @@ module Raw { Pat getPat() { ref_pat_pats(this, result) } } + private Element getImmediateChildOfRefPat(RefPat e, int index) { + exists(int n, int nPat | + n = 0 and + nPat = n + 1 and + ( + none() + or + index = n and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A reference type. @@ -3143,6 +4992,21 @@ module Raw { TypeRepr getTypeRepr() { ref_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfRefTypeRepr(RefTypeRepr e, int index) { + exists(int n, int nLifetime, int nTypeRepr | + n = 0 and + nLifetime = n + 1 and + nTypeRepr = nLifetime + 1 and + ( + none() + or + index = n and result = e.getLifetime() + or + index = nLifetime and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A rest pattern (`..`) in a tuple, slice, or struct pattern. @@ -3160,6 +5024,23 @@ module Raw { * Gets the `index`th attr of this rest pattern (0-based). */ Attr getAttr(int index) { rest_pat_attrs(this, index, result) } + + /** + * Gets the number of attrs of this rest pattern. + */ + int getNumberOfAttrs() { result = count(int i | rest_pat_attrs(this, i, _)) } + } + + private Element getImmediateChildOfRestPat(RestPat e, int index) { + exists(int n, int nAttr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + ( + none() + or + result = e.getAttr(index - n) + ) + ) } /** @@ -3184,12 +5065,32 @@ module Raw { */ Attr getAttr(int index) { return_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this return expression. + */ + int getNumberOfAttrs() { result = count(int i | return_expr_attrs(this, i, _)) } + /** * Gets the expression of this return expression, if it exists. */ Expr getExpr() { return_expr_exprs(this, result) } } + private Element getImmediateChildOfReturnExpr(ReturnExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A `self` parameter. For example `self` in: @@ -3228,6 +5129,27 @@ module Raw { Name getName() { self_param_names(this, result) } } + private Element getImmediateChildOfSelfParam(SelfParam e, int index) { + exists(int n, int nAttr, int nTypeRepr, int nLifetime, int nName | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nTypeRepr = nAttr + 1 and + nLifetime = nTypeRepr + 1 and + nName = nLifetime + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getLifetime() + or + index = nLifetime and result = e.getName() + ) + ) + } + /** * INTERNAL: Do not use. * A slice pattern. For example: @@ -3246,6 +5168,23 @@ module Raw { * Gets the `index`th pattern of this slice pattern (0-based). */ Pat getPat(int index) { slice_pat_pats(this, index, result) } + + /** + * Gets the number of patterns of this slice pattern. + */ + int getNumberOfPats() { result = count(int i | slice_pat_pats(this, i, _)) } + } + + private Element getImmediateChildOfSlicePat(SlicePat e, int index) { + exists(int n, int nPat | + n = 0 and + nPat = n + e.getNumberOfPats() and + ( + none() + or + result = e.getPat(index - n) + ) + ) } /** @@ -3267,6 +5206,18 @@ module Raw { TypeRepr getTypeRepr() { slice_type_repr_type_reprs(this, result) } } + private Element getImmediateChildOfSliceTypeRepr(SliceTypeRepr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A struct expression. For example: @@ -3288,6 +5239,21 @@ module Raw { } } + private Element getImmediateChildOfStructExpr(StructExpr e, int index) { + exists(int n, int nPath, int nStructExprFieldList | + n = 0 and + nPath = n + 1 and + nStructExprFieldList = nPath + 1 and + ( + none() + or + index = n and result = e.getPath() + or + index = nPath and result = e.getStructExprFieldList() + ) + ) + } + /** * INTERNAL: Do not use. * A list of fields in a struct declaration. @@ -3305,6 +5271,23 @@ module Raw { * Gets the `index`th field of this struct field list (0-based). */ StructField getField(int index) { struct_field_list_fields(this, index, result) } + + /** + * Gets the number of fields of this struct field list. + */ + int getNumberOfFields() { result = count(int i | struct_field_list_fields(this, i, _)) } + } + + private Element getImmediateChildOfStructFieldList(StructFieldList e, int index) { + exists(int n, int nField | + n = 0 and + nField = n + e.getNumberOfFields() and + ( + none() + or + result = e.getField(index - n) + ) + ) } /** @@ -3326,6 +5309,21 @@ module Raw { StructPatFieldList getStructPatFieldList() { struct_pat_struct_pat_field_lists(this, result) } } + private Element getImmediateChildOfStructPat(StructPat e, int index) { + exists(int n, int nPath, int nStructPatFieldList | + n = 0 and + nPath = n + 1 and + nStructPatFieldList = nPath + 1 and + ( + none() + or + index = n and result = e.getPath() + or + index = nPath and result = e.getStructPatFieldList() + ) + ) + } + /** * INTERNAL: Do not use. * A try expression using the `?` operator. @@ -3344,12 +5342,32 @@ module Raw { */ Attr getAttr(int index) { try_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this try expression. + */ + int getNumberOfAttrs() { result = count(int i | try_expr_attrs(this, i, _)) } + /** * Gets the expression of this try expression, if it exists. */ Expr getExpr() { try_expr_exprs(this, result) } } + private Element getImmediateChildOfTryExpr(TryExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A tuple expression. For example: @@ -3367,10 +5385,35 @@ module Raw { */ Attr getAttr(int index) { tuple_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this tuple expression. + */ + int getNumberOfAttrs() { result = count(int i | tuple_expr_attrs(this, i, _)) } + /** * Gets the `index`th field of this tuple expression (0-based). */ Expr getField(int index) { tuple_expr_fields(this, index, result) } + + /** + * Gets the number of fields of this tuple expression. + */ + int getNumberOfFields() { result = count(int i | tuple_expr_fields(this, i, _)) } + } + + private Element getImmediateChildOfTupleExpr(TupleExpr e, int index) { + exists(int n, int nAttr, int nField | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nField = nAttr + e.getNumberOfFields() and + ( + none() + or + result = e.getAttr(index - n) + or + result = e.getField(index - nAttr) + ) + ) } /** @@ -3390,6 +5433,23 @@ module Raw { * Gets the `index`th field of this tuple field list (0-based). */ TupleField getField(int index) { tuple_field_list_fields(this, index, result) } + + /** + * Gets the number of fields of this tuple field list. + */ + int getNumberOfFields() { result = count(int i | tuple_field_list_fields(this, i, _)) } + } + + private Element getImmediateChildOfTupleFieldList(TupleFieldList e, int index) { + exists(int n, int nField | + n = 0 and + nField = n + e.getNumberOfFields() and + ( + none() + or + result = e.getField(index - n) + ) + ) } /** @@ -3407,6 +5467,23 @@ module Raw { * Gets the `index`th field of this tuple pattern (0-based). */ Pat getField(int index) { tuple_pat_fields(this, index, result) } + + /** + * Gets the number of fields of this tuple pattern. + */ + int getNumberOfFields() { result = count(int i | tuple_pat_fields(this, i, _)) } + } + + private Element getImmediateChildOfTuplePat(TuplePat e, int index) { + exists(int n, int nField | + n = 0 and + nField = n + e.getNumberOfFields() and + ( + none() + or + result = e.getField(index - n) + ) + ) } /** @@ -3427,6 +5504,26 @@ module Raw { * Gets the `index`th field of this tuple struct pattern (0-based). */ Pat getField(int index) { tuple_struct_pat_fields(this, index, result) } + + /** + * Gets the number of fields of this tuple struct pattern. + */ + int getNumberOfFields() { result = count(int i | tuple_struct_pat_fields(this, i, _)) } + } + + private Element getImmediateChildOfTupleStructPat(TupleStructPat e, int index) { + exists(int n, int nPath, int nField | + n = 0 and + nPath = n + 1 and + nField = nPath + e.getNumberOfFields() and + ( + none() + or + index = n and result = e.getPath() + or + result = e.getField(index - nPath) + ) + ) } /** @@ -3446,6 +5543,23 @@ module Raw { * Gets the `index`th field of this tuple type representation (0-based). */ TypeRepr getField(int index) { tuple_type_repr_fields(this, index, result) } + + /** + * Gets the number of fields of this tuple type representation. + */ + int getNumberOfFields() { result = count(int i | tuple_type_repr_fields(this, i, _)) } + } + + private Element getImmediateChildOfTupleTypeRepr(TupleTypeRepr e, int index) { + exists(int n, int nField | + n = 0 and + nField = n + e.getNumberOfFields() and + ( + none() + or + result = e.getField(index - n) + ) + ) } /** @@ -3467,6 +5581,18 @@ module Raw { TypeRepr getTypeRepr() { type_arg_type_reprs(this, result) } } + private Element getImmediateChildOfTypeArg(TypeArg e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. * A type parameter in a generic parameter list. @@ -3485,6 +5611,11 @@ module Raw { */ Attr getAttr(int index) { type_param_attrs(this, index, result) } + /** + * Gets the number of attrs of this type parameter. + */ + int getNumberOfAttrs() { result = count(int i | type_param_attrs(this, i, _)) } + /** * Gets the default type of this type parameter, if it exists. */ @@ -3501,6 +5632,27 @@ module Raw { TypeBoundList getTypeBoundList() { type_param_type_bound_lists(this, result) } } + private Element getImmediateChildOfTypeParam(TypeParam e, int index) { + exists(int n, int nAttr, int nDefaultType, int nName, int nTypeBoundList | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nDefaultType = nAttr + 1 and + nName = nDefaultType + 1 and + nTypeBoundList = nName + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getDefaultType() + or + index = nDefaultType and result = e.getName() + or + index = nName and result = e.getTypeBoundList() + ) + ) + } + /** * INTERNAL: Do not use. * An underscore expression. For example: @@ -3515,6 +5667,23 @@ module Raw { * Gets the `index`th attr of this underscore expression (0-based). */ Attr getAttr(int index) { underscore_expr_attrs(this, index, result) } + + /** + * Gets the number of attrs of this underscore expression. + */ + int getNumberOfAttrs() { result = count(int i | underscore_expr_attrs(this, i, _)) } + } + + private Element getImmediateChildOfUnderscoreExpr(UnderscoreExpr e, int index) { + exists(int n, int nAttr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + ( + none() + or + result = e.getAttr(index - n) + ) + ) } /** @@ -3535,6 +5704,11 @@ module Raw { */ Attr getAttr(int index) { variant_attrs(this, index, result) } + /** + * Gets the number of attrs of this variant. + */ + int getNumberOfAttrs() { result = count(int i | variant_attrs(this, i, _)) } + /** * Gets the discriminant of this variant, if it exists. */ @@ -3556,6 +5730,30 @@ module Raw { Visibility getVisibility() { variant_visibilities(this, result) } } + private Element getImmediateChildOfVariant(Variant e, int index) { + exists(int n, int nAttr, int nDiscriminant, int nFieldList, int nName, int nVisibility | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nDiscriminant = nAttr + 1 and + nFieldList = nDiscriminant + 1 and + nName = nFieldList + 1 and + nVisibility = nName + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getDiscriminant() + or + index = nDiscriminant and result = e.getFieldList() + or + index = nFieldList and result = e.getName() + or + index = nName and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A wildcard pattern. For example: @@ -3567,6 +5765,8 @@ module Raw { override string toString() { result = "WildcardPat" } } + private Element getImmediateChildOfWildcardPat(WildcardPat e, int index) { none() } + /** * INTERNAL: Do not use. * A `yeet` expression. For example: @@ -3584,12 +5784,32 @@ module Raw { */ Attr getAttr(int index) { yeet_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this yeet expression. + */ + int getNumberOfAttrs() { result = count(int i | yeet_expr_attrs(this, i, _)) } + /** * Gets the expression of this yeet expression, if it exists. */ Expr getExpr() { yeet_expr_exprs(this, result) } } + private Element getImmediateChildOfYeetExpr(YeetExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A `yield` expression. For example: @@ -3608,12 +5828,32 @@ module Raw { */ Attr getAttr(int index) { yield_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this yield expression. + */ + int getNumberOfAttrs() { result = count(int i | yield_expr_attrs(this, i, _)) } + /** * Gets the expression of this yield expression, if it exists. */ Expr getExpr() { yield_expr_exprs(this, result) } } + private Element getImmediateChildOfYieldExpr(YieldExpr e, int index) { + exists(int n, int nAttr, int nExpr | + n = 0 and + nAttr = n + e.getNumberOfAttrs() and + nExpr = nAttr + 1 and + ( + none() + or + result = e.getAttr(index - n) + or + index = nAttr and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`. @@ -3625,6 +5865,13 @@ module Raw { MacroItems getDeriveMacroExpansion(int index) { adt_derive_macro_expansions(this, index, result) } + + /** + * Gets the number of derive macro expansions of this adt. + */ + int getNumberOfDeriveMacroExpansions() { + result = count(int i | adt_derive_macro_expansions(this, i, _)) + } } /** @@ -3645,15 +5892,51 @@ module Raw { */ AsmPiece getAsmPiece(int index) { asm_expr_asm_pieces(this, index, result) } + /** + * Gets the number of asm pieces of this asm expression. + */ + int getNumberOfAsmPieces() { result = count(int i | asm_expr_asm_pieces(this, i, _)) } + /** * Gets the `index`th attr of this asm expression (0-based). */ Attr getAttr(int index) { asm_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this asm expression. + */ + int getNumberOfAttrs() { result = count(int i | asm_expr_attrs(this, i, _)) } + /** * Gets the `index`th template of this asm expression (0-based). */ Expr getTemplate(int index) { asm_expr_templates(this, index, result) } + + /** + * Gets the number of templates of this asm expression. + */ + int getNumberOfTemplates() { result = count(int i | asm_expr_templates(this, i, _)) } + } + + private Element getImmediateChildOfAsmExpr(AsmExpr e, int index) { + exists(int n, int nAttributeMacroExpansion, int nAsmPiece, int nAttr, int nTemplate | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAsmPiece = nAttributeMacroExpansion + e.getNumberOfAsmPieces() and + nAttr = nAsmPiece + e.getNumberOfAttrs() and + nTemplate = nAttr + e.getNumberOfTemplates() and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAsmPiece(index - nAttributeMacroExpansion) + or + result = e.getAttr(index - nAsmPiece) + or + result = e.getTemplate(index - nAttr) + ) + ) } /** @@ -3691,6 +5974,11 @@ module Raw { */ Attr getAttr(int index) { block_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this block expression. + */ + int getNumberOfAttrs() { result = count(int i | block_expr_attrs(this, i, _)) } + /** * Holds if this block expression is async. */ @@ -3727,6 +6015,24 @@ module Raw { StmtList getStmtList() { block_expr_stmt_lists(this, result) } } + private Element getImmediateChildOfBlockExpr(BlockExpr e, int index) { + exists(int n, int nLabel, int nAttr, int nStmtList | + n = 0 and + nLabel = n + 1 and + nAttr = nLabel + e.getNumberOfAttrs() and + nStmtList = nAttr + 1 and + ( + none() + or + index = n and result = e.getLabel() + or + result = e.getAttr(index - nLabel) + or + index = nAttr and result = e.getStmtList() + ) + ) + } + /** * INTERNAL: Do not use. * A function call expression. For example: @@ -3746,6 +6052,24 @@ module Raw { Expr getFunction() { call_expr_functions(this, result) } } + private Element getImmediateChildOfCallExpr(CallExpr e, int index) { + exists(int n, int nArgList, int nAttr, int nFunction | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nFunction = nAttr + 1 and + ( + none() + or + index = n and result = e.getArgList() + or + result = e.getAttr(index - nArgList) + or + index = nAttr and result = e.getFunction() + ) + ) + } + /** * INTERNAL: Do not use. * An extern block containing foreign function declarations. @@ -3770,6 +6094,11 @@ module Raw { */ Attr getAttr(int index) { extern_block_attrs(this, index, result) } + /** + * Gets the number of attrs of this extern block. + */ + int getNumberOfAttrs() { result = count(int i | extern_block_attrs(this, i, _)) } + /** * Gets the extern item list of this extern block, if it exists. */ @@ -3781,6 +6110,27 @@ module Raw { predicate isUnsafe() { extern_block_is_unsafe(this) } } + private Element getImmediateChildOfExternBlock(ExternBlock e, int index) { + exists(int n, int nAttributeMacroExpansion, int nAbi, int nAttr, int nExternItemList | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAbi = nAttributeMacroExpansion + 1 and + nAttr = nAbi + e.getNumberOfAttrs() and + nExternItemList = nAttr + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + index = nAttributeMacroExpansion and result = e.getAbi() + or + result = e.getAttr(index - nAbi) + or + index = nAttr and result = e.getExternItemList() + ) + ) + } + /** * INTERNAL: Do not use. * An extern crate declaration. @@ -3798,6 +6148,11 @@ module Raw { */ Attr getAttr(int index) { extern_crate_attrs(this, index, result) } + /** + * Gets the number of attrs of this extern crate. + */ + int getNumberOfAttrs() { result = count(int i | extern_crate_attrs(this, i, _)) } + /** * Gets the identifier of this extern crate, if it exists. */ @@ -3814,6 +6169,32 @@ module Raw { Visibility getVisibility() { extern_crate_visibilities(this, result) } } + private Element getImmediateChildOfExternCrate(ExternCrate e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nIdentifier, int nRename, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nIdentifier = nAttr + 1 and + nRename = nIdentifier + 1 and + nVisibility = nRename + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getIdentifier() + or + index = nIdentifier and result = e.getRename() + or + index = nRename and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * An item inside an extern block. @@ -3852,6 +6233,11 @@ module Raw { */ Attr getAttr(int index) { impl_attrs(this, index, result) } + /** + * Gets the number of attrs of this impl. + */ + int getNumberOfAttrs() { result = count(int i | impl_attrs(this, i, _)) } + /** * Gets the generic parameter list of this impl, if it exists. */ @@ -3893,6 +6279,42 @@ module Raw { WhereClause getWhereClause() { impl_where_clauses(this, result) } } + private Element getImmediateChildOfImpl(Impl e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList, + int nSelfTy, int nTrait, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAssocItemList = nAttributeMacroExpansion + 1 and + nAttr = nAssocItemList + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nSelfTy = nGenericParamList + 1 and + nTrait = nSelfTy + 1 and + nVisibility = nTrait + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + index = nAttributeMacroExpansion and result = e.getAssocItemList() + or + result = e.getAttr(index - nAssocItemList) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getSelfTy() + or + index = nSelfTy and result = e.getTrait() + or + index = nTrait and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * The base class for expressions that loop (`LoopExpr`, `ForExpr` or `WhileExpr`). @@ -3928,6 +6350,11 @@ module Raw { */ Attr getAttr(int index) { macro_def_attrs(this, index, result) } + /** + * Gets the number of attrs of this macro def. + */ + int getNumberOfAttrs() { result = count(int i | macro_def_attrs(this, i, _)) } + /** * Gets the body of this macro def, if it exists. */ @@ -3944,6 +6371,36 @@ module Raw { Visibility getVisibility() { macro_def_visibilities(this, result) } } + private Element getImmediateChildOfMacroDef(MacroDef e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nArgs, int nAttr, int nBody, int nName, + int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nArgs = nAttributeMacroExpansion + 1 and + nAttr = nArgs + e.getNumberOfAttrs() and + nBody = nAttr + 1 and + nName = nBody + 1 and + nVisibility = nName + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + index = nAttributeMacroExpansion and result = e.getArgs() + or + result = e.getAttr(index - nArgs) + or + index = nAttr and result = e.getBody() + or + index = nBody and result = e.getName() + or + index = nName and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A macro definition using the `macro_rules!` syntax. @@ -3963,6 +6420,11 @@ module Raw { */ Attr getAttr(int index) { macro_rules_attrs(this, index, result) } + /** + * Gets the number of attrs of this macro rules. + */ + int getNumberOfAttrs() { result = count(int i | macro_rules_attrs(this, i, _)) } + /** * Gets the name of this macro rules, if it exists. */ @@ -3979,6 +6441,32 @@ module Raw { Visibility getVisibility() { macro_rules_visibilities(this, result) } } + private Element getImmediateChildOfMacroRules(MacroRules e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nName, int nTokenTree, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nName = nAttr + 1 and + nTokenTree = nName + 1 and + nVisibility = nTokenTree + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getName() + or + index = nName and result = e.getTokenTree() + or + index = nTokenTree and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A method call expression. For example: @@ -4006,6 +6494,30 @@ module Raw { Expr getReceiver() { method_call_expr_receivers(this, result) } } + private Element getImmediateChildOfMethodCallExpr(MethodCallExpr e, int index) { + exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nGenericArgList = nAttr + 1 and + nIdentifier = nGenericArgList + 1 and + nReceiver = nIdentifier + 1 and + ( + none() + or + index = n and result = e.getArgList() + or + result = e.getAttr(index - nArgList) + or + index = nAttr and result = e.getGenericArgList() + or + index = nGenericArgList and result = e.getIdentifier() + or + index = nIdentifier and result = e.getReceiver() + ) + ) + } + /** * INTERNAL: Do not use. * A module declaration. For example: @@ -4026,6 +6538,11 @@ module Raw { */ Attr getAttr(int index) { module_attrs(this, index, result) } + /** + * Gets the number of attrs of this module. + */ + int getNumberOfAttrs() { result = count(int i | module_attrs(this, i, _)) } + /** * Gets the item list of this module, if it exists. */ @@ -4042,6 +6559,32 @@ module Raw { Visibility getVisibility() { module_visibilities(this, result) } } + private Element getImmediateChildOfModule(Module e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nItemList, int nName, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nItemList = nAttr + 1 and + nName = nItemList + 1 and + nVisibility = nName + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getItemList() + or + index = nItemList and result = e.getName() + or + index = nName and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A path expression. For example: @@ -4059,6 +6602,26 @@ module Raw { * Gets the `index`th attr of this path expression (0-based). */ Attr getAttr(int index) { path_expr_attrs(this, index, result) } + + /** + * Gets the number of attrs of this path expression. + */ + int getNumberOfAttrs() { result = count(int i | path_expr_attrs(this, i, _)) } + } + + private Element getImmediateChildOfPathExpr(PathExpr e, int index) { + exists(int n, int nPath, int nAttr | + n = 0 and + nPath = n + 1 and + nAttr = nPath + e.getNumberOfAttrs() and + ( + none() + or + index = n and result = e.getPath() + or + result = e.getAttr(index - nPath) + ) + ) } /** @@ -4087,6 +6650,11 @@ module Raw { */ Attr getAttr(int index) { trait_attrs(this, index, result) } + /** + * Gets the number of attrs of this trait. + */ + int getNumberOfAttrs() { result = count(int i | trait_attrs(this, i, _)) } + /** * Gets the generic parameter list of this trait, if it exists. */ @@ -4123,6 +6691,42 @@ module Raw { WhereClause getWhereClause() { trait_where_clauses(this, result) } } + private Element getImmediateChildOfTrait(Trait e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList, + int nName, int nTypeBoundList, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAssocItemList = nAttributeMacroExpansion + 1 and + nAttr = nAssocItemList + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nName = nGenericParamList + 1 and + nTypeBoundList = nName + 1 and + nVisibility = nTypeBoundList + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + index = nAttributeMacroExpansion and result = e.getAssocItemList() + or + result = e.getAttr(index - nAssocItemList) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getTypeBoundList() + or + index = nTypeBoundList and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A trait alias. @@ -4140,6 +6744,11 @@ module Raw { */ Attr getAttr(int index) { trait_alias_attrs(this, index, result) } + /** + * Gets the number of attrs of this trait alias. + */ + int getNumberOfAttrs() { result = count(int i | trait_alias_attrs(this, i, _)) } + /** * Gets the generic parameter list of this trait alias, if it exists. */ @@ -4166,6 +6775,39 @@ module Raw { WhereClause getWhereClause() { trait_alias_where_clauses(this, result) } } + private Element getImmediateChildOfTraitAlias(TraitAlias e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nGenericParamList, int nName, + int nTypeBoundList, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nName = nGenericParamList + 1 and + nTypeBoundList = nName + 1 and + nVisibility = nTypeBoundList + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getTypeBoundList() + or + index = nTypeBoundList and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A `use` statement. For example: @@ -4181,6 +6823,11 @@ module Raw { */ Attr getAttr(int index) { use_attrs(this, index, result) } + /** + * Gets the number of attrs of this use. + */ + int getNumberOfAttrs() { result = count(int i | use_attrs(this, i, _)) } + /** * Gets the use tree of this use, if it exists. */ @@ -4192,6 +6839,27 @@ module Raw { Visibility getVisibility() { use_visibilities(this, result) } } + private Element getImmediateChildOfUse(Use e, int index) { + exists(int n, int nAttributeMacroExpansion, int nAttr, int nUseTree, int nVisibility | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nUseTree = nAttr + 1 and + nVisibility = nUseTree + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getUseTree() + or + index = nUseTree and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A constant item declaration. @@ -4209,6 +6877,11 @@ module Raw { */ Attr getAttr(int index) { const_attrs(this, index, result) } + /** + * Gets the number of attrs of this const. + */ + int getNumberOfAttrs() { result = count(int i | const_attrs(this, i, _)) } + /** * Gets the body of this const, if it exists. */ @@ -4258,6 +6931,42 @@ module Raw { predicate hasImplementation() { const_has_implementation(this) } } + private Element getImmediateChildOfConst(Const e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nBody, int nGenericParamList, int nName, + int nTypeRepr, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nBody = nAttr + 1 and + nGenericParamList = nBody + 1 and + nName = nGenericParamList + 1 and + nTypeRepr = nName + 1 and + nVisibility = nTypeRepr + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getBody() + or + index = nBody and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * An enum declaration. @@ -4275,6 +6984,11 @@ module Raw { */ Attr getAttr(int index) { enum_attrs(this, index, result) } + /** + * Gets the number of attrs of this enum. + */ + int getNumberOfAttrs() { result = count(int i | enum_attrs(this, i, _)) } + /** * Gets the generic parameter list of this enum, if it exists. */ @@ -4301,6 +7015,42 @@ module Raw { WhereClause getWhereClause() { enum_where_clauses(this, result) } } + private Element getImmediateChildOfEnum(Enum e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, + int nGenericParamList, int nName, int nVariantList, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nName = nGenericParamList + 1 and + nVariantList = nName + 1 and + nVisibility = nVariantList + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) + or + result = e.getAttr(index - nDeriveMacroExpansion) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getVariantList() + or + index = nVariantList and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A for loop expression. @@ -4320,6 +7070,11 @@ module Raw { */ Attr getAttr(int index) { for_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this for expression. + */ + int getNumberOfAttrs() { result = count(int i | for_expr_attrs(this, i, _)) } + /** * Gets the iterable of this for expression, if it exists. */ @@ -4331,6 +7086,30 @@ module Raw { Pat getPat() { for_expr_pats(this, result) } } + private Element getImmediateChildOfForExpr(ForExpr e, int index) { + exists(int n, int nLabel, int nLoopBody, int nAttr, int nIterable, int nPat | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + e.getNumberOfAttrs() and + nIterable = nAttr + 1 and + nPat = nIterable + 1 and + ( + none() + or + index = n and result = e.getLabel() + or + index = nLabel and result = e.getLoopBody() + or + result = e.getAttr(index - nLoopBody) + or + index = nAttr and result = e.getIterable() + or + index = nIterable and result = e.getPat() + ) + ) + } + /** * INTERNAL: Do not use. * A function declaration. For example @@ -4416,6 +7195,48 @@ module Raw { predicate hasImplementation() { function_has_implementation(this) } } + private Element getImmediateChildOfFunction(Function e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nParamList, int nAttr, int nAbi, int nFunctionBody, + int nGenericParamList, int nName, int nRetType, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nParamList = nAttributeMacroExpansion + 1 and + nAttr = nParamList + e.getNumberOfAttrs() and + nAbi = nAttr + 1 and + nFunctionBody = nAbi + 1 and + nGenericParamList = nFunctionBody + 1 and + nName = nGenericParamList + 1 and + nRetType = nName + 1 and + nVisibility = nRetType + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + index = nAttributeMacroExpansion and result = e.getParamList() + or + result = e.getAttr(index - nParamList) + or + index = nAttr and result = e.getAbi() + or + index = nAbi and result = e.getFunctionBody() + or + index = nFunctionBody and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getRetType() + or + index = nRetType and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A loop expression. For example: @@ -4448,6 +7269,29 @@ module Raw { * Gets the `index`th attr of this loop expression (0-based). */ Attr getAttr(int index) { loop_expr_attrs(this, index, result) } + + /** + * Gets the number of attrs of this loop expression. + */ + int getNumberOfAttrs() { result = count(int i | loop_expr_attrs(this, i, _)) } + } + + private Element getImmediateChildOfLoopExpr(LoopExpr e, int index) { + exists(int n, int nLabel, int nLoopBody, int nAttr | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + e.getNumberOfAttrs() and + ( + none() + or + index = n and result = e.getLabel() + or + index = nLabel and result = e.getLoopBody() + or + result = e.getAttr(index - nLoopBody) + ) + ) } /** @@ -4467,6 +7311,11 @@ module Raw { */ Attr getAttr(int index) { macro_call_attrs(this, index, result) } + /** + * Gets the number of attrs of this macro call. + */ + int getNumberOfAttrs() { result = count(int i | macro_call_attrs(this, i, _)) } + /** * Gets the path of this macro call, if it exists. */ @@ -4483,6 +7332,33 @@ module Raw { AstNode getMacroCallExpansion() { macro_call_macro_call_expansions(this, result) } } + private Element getImmediateChildOfMacroCall(MacroCall e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nPath, int nTokenTree, + int nMacroCallExpansion + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nPath = nAttr + 1 and + nTokenTree = nPath + 1 and + nMacroCallExpansion = nTokenTree + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getPath() + or + index = nPath and result = e.getTokenTree() + or + index = nTokenTree and result = e.getMacroCallExpansion() + ) + ) + } + /** * INTERNAL: Do not use. * A static item declaration. @@ -4500,6 +7376,11 @@ module Raw { */ Attr getAttr(int index) { static_attrs(this, index, result) } + /** + * Gets the number of attrs of this static. + */ + int getNumberOfAttrs() { result = count(int i | static_attrs(this, i, _)) } + /** * Gets the body of this static, if it exists. */ @@ -4536,6 +7417,36 @@ module Raw { Visibility getVisibility() { static_visibilities(this, result) } } + private Element getImmediateChildOfStatic(Static e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nBody, int nName, int nTypeRepr, + int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nBody = nAttr + 1 and + nName = nBody + 1 and + nTypeRepr = nName + 1 and + nVisibility = nTypeRepr + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getBody() + or + index = nBody and result = e.getName() + or + index = nName and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getVisibility() + ) + ) + } + /** * INTERNAL: Do not use. * A Struct. For example: @@ -4554,6 +7465,11 @@ module Raw { */ Attr getAttr(int index) { struct_attrs(this, index, result) } + /** + * Gets the number of attrs of this struct. + */ + int getNumberOfAttrs() { result = count(int i | struct_attrs(this, i, _)) } + /** * Gets the field list of this struct, if it exists. */ @@ -4580,6 +7496,42 @@ module Raw { WhereClause getWhereClause() { struct_where_clauses(this, result) } } + private Element getImmediateChildOfStruct(Struct e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, int nFieldList, + int nGenericParamList, int nName, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and + nFieldList = nAttr + 1 and + nGenericParamList = nFieldList + 1 and + nName = nGenericParamList + 1 and + nVisibility = nName + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) + or + result = e.getAttr(index - nDeriveMacroExpansion) + or + index = nAttr and result = e.getFieldList() + or + index = nFieldList and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A type alias. For example: @@ -4600,6 +7552,11 @@ module Raw { */ Attr getAttr(int index) { type_alias_attrs(this, index, result) } + /** + * Gets the number of attrs of this type alias. + */ + int getNumberOfAttrs() { result = count(int i | type_alias_attrs(this, i, _)) } + /** * Gets the generic parameter list of this type alias, if it exists. */ @@ -4636,6 +7593,42 @@ module Raw { WhereClause getWhereClause() { type_alias_where_clauses(this, result) } } + private Element getImmediateChildOfTypeAlias(TypeAlias e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nGenericParamList, int nName, + int nTypeRepr, int nTypeBoundList, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nName = nGenericParamList + 1 and + nTypeRepr = nName + 1 and + nTypeBoundList = nTypeRepr + 1 and + nVisibility = nTypeBoundList + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getAttr(index - nAttributeMacroExpansion) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getTypeRepr() + or + index = nTypeRepr and result = e.getTypeBoundList() + or + index = nTypeBoundList and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A union declaration. @@ -4653,6 +7646,11 @@ module Raw { */ Attr getAttr(int index) { union_attrs(this, index, result) } + /** + * Gets the number of attrs of this union. + */ + int getNumberOfAttrs() { result = count(int i | union_attrs(this, i, _)) } + /** * Gets the generic parameter list of this union, if it exists. */ @@ -4679,6 +7677,42 @@ module Raw { WhereClause getWhereClause() { union_where_clauses(this, result) } } + private Element getImmediateChildOfUnion(Union e, int index) { + exists( + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, + int nGenericParamList, int nName, int nStructFieldList, int nVisibility, int nWhereClause + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = nAttributeMacroExpansion + e.getNumberOfDeriveMacroExpansions() and + nAttr = nDeriveMacroExpansion + e.getNumberOfAttrs() and + nGenericParamList = nAttr + 1 and + nName = nGenericParamList + 1 and + nStructFieldList = nName + 1 and + nVisibility = nStructFieldList + 1 and + nWhereClause = nVisibility + 1 and + ( + none() + or + index = n and result = e.getAttributeMacroExpansion() + or + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) + or + result = e.getAttr(index - nDeriveMacroExpansion) + or + index = nAttr and result = e.getGenericParamList() + or + index = nGenericParamList and result = e.getName() + or + index = nName and result = e.getStructFieldList() + or + index = nStructFieldList and result = e.getVisibility() + or + index = nVisibility and result = e.getWhereClause() + ) + ) + } + /** * INTERNAL: Do not use. * A while loop expression. @@ -4698,9 +7732,365 @@ module Raw { */ Attr getAttr(int index) { while_expr_attrs(this, index, result) } + /** + * Gets the number of attrs of this while expression. + */ + int getNumberOfAttrs() { result = count(int i | while_expr_attrs(this, i, _)) } + /** * Gets the condition of this while expression, if it exists. */ Expr getCondition() { while_expr_conditions(this, result) } } + + private Element getImmediateChildOfWhileExpr(WhileExpr e, int index) { + exists(int n, int nLabel, int nLoopBody, int nAttr, int nCondition | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + e.getNumberOfAttrs() and + nCondition = nAttr + 1 and + ( + none() + or + index = n and result = e.getLabel() + or + index = nLabel and result = e.getLoopBody() + or + result = e.getAttr(index - nLoopBody) + or + index = nAttr and result = e.getCondition() + ) + ) + } + + /** + * Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. + */ + pragma[nomagic] + Element getImmediateChild(Element e, int index) { + // why does this look more complicated than it should? + // * none() simplifies generation, as we can append `or ...` without a special case for the first item + none() + or + result = getImmediateChildOfExtractorStep(e, index) + or + result = getImmediateChildOfNamedCrate(e, index) + or + result = getImmediateChildOfCrate(e, index) + or + result = getImmediateChildOfMissing(e, index) + or + result = getImmediateChildOfUnimplemented(e, index) + or + result = getImmediateChildOfAbi(e, index) + or + result = getImmediateChildOfArgList(e, index) + or + result = getImmediateChildOfAsmDirSpec(e, index) + or + result = getImmediateChildOfAsmOperandExpr(e, index) + or + result = getImmediateChildOfAsmOption(e, index) + or + result = getImmediateChildOfAsmRegSpec(e, index) + or + result = getImmediateChildOfAssocItemList(e, index) + or + result = getImmediateChildOfAttr(e, index) + or + result = getImmediateChildOfExternItemList(e, index) + or + result = getImmediateChildOfForBinder(e, index) + or + result = getImmediateChildOfFormatArgsArg(e, index) + or + result = getImmediateChildOfGenericArgList(e, index) + or + result = getImmediateChildOfGenericParamList(e, index) + or + result = getImmediateChildOfItemList(e, index) + or + result = getImmediateChildOfLabel(e, index) + or + result = getImmediateChildOfLetElse(e, index) + or + result = getImmediateChildOfMacroItems(e, index) + or + result = getImmediateChildOfMatchArm(e, index) + or + result = getImmediateChildOfMatchArmList(e, index) + or + result = getImmediateChildOfMatchGuard(e, index) + or + result = getImmediateChildOfMeta(e, index) + or + result = getImmediateChildOfName(e, index) + or + result = getImmediateChildOfParamList(e, index) + or + result = getImmediateChildOfParenthesizedArgList(e, index) + or + result = getImmediateChildOfPath(e, index) + or + result = getImmediateChildOfPathSegment(e, index) + or + result = getImmediateChildOfRename(e, index) + or + result = getImmediateChildOfRetTypeRepr(e, index) + or + result = getImmediateChildOfReturnTypeSyntax(e, index) + or + result = getImmediateChildOfSourceFile(e, index) + or + result = getImmediateChildOfStmtList(e, index) + or + result = getImmediateChildOfStructExprField(e, index) + or + result = getImmediateChildOfStructExprFieldList(e, index) + or + result = getImmediateChildOfStructField(e, index) + or + result = getImmediateChildOfStructPatField(e, index) + or + result = getImmediateChildOfStructPatFieldList(e, index) + or + result = getImmediateChildOfTokenTree(e, index) + or + result = getImmediateChildOfTupleField(e, index) + or + result = getImmediateChildOfTypeBound(e, index) + or + result = getImmediateChildOfTypeBoundList(e, index) + or + result = getImmediateChildOfUseBoundGenericArgs(e, index) + or + result = getImmediateChildOfUseTree(e, index) + or + result = getImmediateChildOfUseTreeList(e, index) + or + result = getImmediateChildOfVariantList(e, index) + or + result = getImmediateChildOfVisibility(e, index) + or + result = getImmediateChildOfWhereClause(e, index) + or + result = getImmediateChildOfWherePred(e, index) + or + result = getImmediateChildOfArrayExprInternal(e, index) + or + result = getImmediateChildOfArrayTypeRepr(e, index) + or + result = getImmediateChildOfAsmClobberAbi(e, index) + or + result = getImmediateChildOfAsmConst(e, index) + or + result = getImmediateChildOfAsmLabel(e, index) + or + result = getImmediateChildOfAsmOperandNamed(e, index) + or + result = getImmediateChildOfAsmOptionsList(e, index) + or + result = getImmediateChildOfAsmRegOperand(e, index) + or + result = getImmediateChildOfAsmSym(e, index) + or + result = getImmediateChildOfAssocTypeArg(e, index) + or + result = getImmediateChildOfAwaitExpr(e, index) + or + result = getImmediateChildOfBecomeExpr(e, index) + or + result = getImmediateChildOfBinaryExpr(e, index) + or + result = getImmediateChildOfBoxPat(e, index) + or + result = getImmediateChildOfBreakExpr(e, index) + or + result = getImmediateChildOfCastExpr(e, index) + or + result = getImmediateChildOfClosureExpr(e, index) + or + result = getImmediateChildOfComment(e, index) + or + result = getImmediateChildOfConstArg(e, index) + or + result = getImmediateChildOfConstBlockPat(e, index) + or + result = getImmediateChildOfConstParam(e, index) + or + result = getImmediateChildOfContinueExpr(e, index) + or + result = getImmediateChildOfDynTraitTypeRepr(e, index) + or + result = getImmediateChildOfExprStmt(e, index) + or + result = getImmediateChildOfFieldExpr(e, index) + or + result = getImmediateChildOfFnPtrTypeRepr(e, index) + or + result = getImmediateChildOfForTypeRepr(e, index) + or + result = getImmediateChildOfFormatArgsExpr(e, index) + or + result = getImmediateChildOfIdentPat(e, index) + or + result = getImmediateChildOfIfExpr(e, index) + or + result = getImmediateChildOfImplTraitTypeRepr(e, index) + or + result = getImmediateChildOfIndexExpr(e, index) + or + result = getImmediateChildOfInferTypeRepr(e, index) + or + result = getImmediateChildOfLetExpr(e, index) + or + result = getImmediateChildOfLetStmt(e, index) + or + result = getImmediateChildOfLifetime(e, index) + or + result = getImmediateChildOfLifetimeArg(e, index) + or + result = getImmediateChildOfLifetimeParam(e, index) + or + result = getImmediateChildOfLiteralExpr(e, index) + or + result = getImmediateChildOfLiteralPat(e, index) + or + result = getImmediateChildOfMacroBlockExpr(e, index) + or + result = getImmediateChildOfMacroExpr(e, index) + or + result = getImmediateChildOfMacroPat(e, index) + or + result = getImmediateChildOfMacroTypeRepr(e, index) + or + result = getImmediateChildOfMatchExpr(e, index) + or + result = getImmediateChildOfNameRef(e, index) + or + result = getImmediateChildOfNeverTypeRepr(e, index) + or + result = getImmediateChildOfOffsetOfExpr(e, index) + or + result = getImmediateChildOfOrPat(e, index) + or + result = getImmediateChildOfParam(e, index) + or + result = getImmediateChildOfParenExpr(e, index) + or + result = getImmediateChildOfParenPat(e, index) + or + result = getImmediateChildOfParenTypeRepr(e, index) + or + result = getImmediateChildOfPathPat(e, index) + or + result = getImmediateChildOfPathTypeRepr(e, index) + or + result = getImmediateChildOfPrefixExpr(e, index) + or + result = getImmediateChildOfPtrTypeRepr(e, index) + or + result = getImmediateChildOfRangeExpr(e, index) + or + result = getImmediateChildOfRangePat(e, index) + or + result = getImmediateChildOfRefExpr(e, index) + or + result = getImmediateChildOfRefPat(e, index) + or + result = getImmediateChildOfRefTypeRepr(e, index) + or + result = getImmediateChildOfRestPat(e, index) + or + result = getImmediateChildOfReturnExpr(e, index) + or + result = getImmediateChildOfSelfParam(e, index) + or + result = getImmediateChildOfSlicePat(e, index) + or + result = getImmediateChildOfSliceTypeRepr(e, index) + or + result = getImmediateChildOfStructExpr(e, index) + or + result = getImmediateChildOfStructFieldList(e, index) + or + result = getImmediateChildOfStructPat(e, index) + or + result = getImmediateChildOfTryExpr(e, index) + or + result = getImmediateChildOfTupleExpr(e, index) + or + result = getImmediateChildOfTupleFieldList(e, index) + or + result = getImmediateChildOfTuplePat(e, index) + or + result = getImmediateChildOfTupleStructPat(e, index) + or + result = getImmediateChildOfTupleTypeRepr(e, index) + or + result = getImmediateChildOfTypeArg(e, index) + or + result = getImmediateChildOfTypeParam(e, index) + or + result = getImmediateChildOfUnderscoreExpr(e, index) + or + result = getImmediateChildOfVariant(e, index) + or + result = getImmediateChildOfWildcardPat(e, index) + or + result = getImmediateChildOfYeetExpr(e, index) + or + result = getImmediateChildOfYieldExpr(e, index) + or + result = getImmediateChildOfAsmExpr(e, index) + or + result = getImmediateChildOfBlockExpr(e, index) + or + result = getImmediateChildOfCallExpr(e, index) + or + result = getImmediateChildOfExternBlock(e, index) + or + result = getImmediateChildOfExternCrate(e, index) + or + result = getImmediateChildOfImpl(e, index) + or + result = getImmediateChildOfMacroDef(e, index) + or + result = getImmediateChildOfMacroRules(e, index) + or + result = getImmediateChildOfMethodCallExpr(e, index) + or + result = getImmediateChildOfModule(e, index) + or + result = getImmediateChildOfPathExpr(e, index) + or + result = getImmediateChildOfTrait(e, index) + or + result = getImmediateChildOfTraitAlias(e, index) + or + result = getImmediateChildOfUse(e, index) + or + result = getImmediateChildOfConst(e, index) + or + result = getImmediateChildOfEnum(e, index) + or + result = getImmediateChildOfForExpr(e, index) + or + result = getImmediateChildOfFunction(e, index) + or + result = getImmediateChildOfLoopExpr(e, index) + or + result = getImmediateChildOfMacroCall(e, index) + or + result = getImmediateChildOfStatic(e, index) + or + result = getImmediateChildOfStruct(e, index) + or + result = getImmediateChildOfTypeAlias(e, index) + or + result = getImmediateChildOfUnion(e, index) + or + result = getImmediateChildOfWhileExpr(e, index) + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll index 9ed7961f63ce..74b4a14460a0 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -845,18 +845,36 @@ module Synth { /** * INTERNAL: Do not use. + * + * Gets the parent of synthetic element `e`. + */ + Raw::Element getSynthParent(TElement e) { + none() + or + e = TFormat(result, _, _, _) + or + e = TFormatArgument(result, _, _, _, _, _) + or + e = TFormatTemplateVariableAccess(result, _, _) + } + + /** + * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAbi`, if possible. */ TAbi convertAbiFromRaw(Raw::Element e) { result = TAbi(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArgList`, if possible. */ TArgList convertArgListFromRaw(Raw::Element e) { result = TArgList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayExprInternal`, if possible. */ TArrayExprInternal convertArrayExprInternalFromRaw(Raw::Element e) { @@ -865,306 +883,357 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayListExpr`, if possible. */ TArrayListExpr convertArrayListExprFromRaw(Raw::Element e) { result = TArrayListExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayRepeatExpr`, if possible. */ TArrayRepeatExpr convertArrayRepeatExprFromRaw(Raw::Element e) { result = TArrayRepeatExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayTypeRepr`, if possible. */ TArrayTypeRepr convertArrayTypeReprFromRaw(Raw::Element e) { result = TArrayTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmClobberAbi`, if possible. */ TAsmClobberAbi convertAsmClobberAbiFromRaw(Raw::Element e) { result = TAsmClobberAbi(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmConst`, if possible. */ TAsmConst convertAsmConstFromRaw(Raw::Element e) { result = TAsmConst(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmDirSpec`, if possible. */ TAsmDirSpec convertAsmDirSpecFromRaw(Raw::Element e) { result = TAsmDirSpec(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmExpr`, if possible. */ TAsmExpr convertAsmExprFromRaw(Raw::Element e) { result = TAsmExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmLabel`, if possible. */ TAsmLabel convertAsmLabelFromRaw(Raw::Element e) { result = TAsmLabel(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmOperandExpr`, if possible. */ TAsmOperandExpr convertAsmOperandExprFromRaw(Raw::Element e) { result = TAsmOperandExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmOperandNamed`, if possible. */ TAsmOperandNamed convertAsmOperandNamedFromRaw(Raw::Element e) { result = TAsmOperandNamed(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmOption`, if possible. */ TAsmOption convertAsmOptionFromRaw(Raw::Element e) { result = TAsmOption(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmOptionsList`, if possible. */ TAsmOptionsList convertAsmOptionsListFromRaw(Raw::Element e) { result = TAsmOptionsList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmRegOperand`, if possible. */ TAsmRegOperand convertAsmRegOperandFromRaw(Raw::Element e) { result = TAsmRegOperand(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmRegSpec`, if possible. */ TAsmRegSpec convertAsmRegSpecFromRaw(Raw::Element e) { result = TAsmRegSpec(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAsmSym`, if possible. */ TAsmSym convertAsmSymFromRaw(Raw::Element e) { result = TAsmSym(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAssocItemList`, if possible. */ TAssocItemList convertAssocItemListFromRaw(Raw::Element e) { result = TAssocItemList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAssocTypeArg`, if possible. */ TAssocTypeArg convertAssocTypeArgFromRaw(Raw::Element e) { result = TAssocTypeArg(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAttr`, if possible. */ TAttr convertAttrFromRaw(Raw::Element e) { result = TAttr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAwaitExpr`, if possible. */ TAwaitExpr convertAwaitExprFromRaw(Raw::Element e) { result = TAwaitExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBecomeExpr`, if possible. */ TBecomeExpr convertBecomeExprFromRaw(Raw::Element e) { result = TBecomeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBinaryExpr`, if possible. */ TBinaryExpr convertBinaryExprFromRaw(Raw::Element e) { result = TBinaryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBlockExpr`, if possible. */ TBlockExpr convertBlockExprFromRaw(Raw::Element e) { result = TBlockExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBoxPat`, if possible. */ TBoxPat convertBoxPatFromRaw(Raw::Element e) { result = TBoxPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBreakExpr`, if possible. */ TBreakExpr convertBreakExprFromRaw(Raw::Element e) { result = TBreakExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCallExpr`, if possible. */ TCallExpr convertCallExprFromRaw(Raw::Element e) { result = TCallExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCastExpr`, if possible. */ TCastExpr convertCastExprFromRaw(Raw::Element e) { result = TCastExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TClosureExpr`, if possible. */ TClosureExpr convertClosureExprFromRaw(Raw::Element e) { result = TClosureExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TComment`, if possible. */ TComment convertCommentFromRaw(Raw::Element e) { result = TComment(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConst`, if possible. */ TConst convertConstFromRaw(Raw::Element e) { result = TConst(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConstArg`, if possible. */ TConstArg convertConstArgFromRaw(Raw::Element e) { result = TConstArg(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConstBlockPat`, if possible. */ TConstBlockPat convertConstBlockPatFromRaw(Raw::Element e) { result = TConstBlockPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConstParam`, if possible. */ TConstParam convertConstParamFromRaw(Raw::Element e) { result = TConstParam(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TContinueExpr`, if possible. */ TContinueExpr convertContinueExprFromRaw(Raw::Element e) { result = TContinueExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCrate`, if possible. */ TCrate convertCrateFromRaw(Raw::Element e) { result = TCrate(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDynTraitTypeRepr`, if possible. */ TDynTraitTypeRepr convertDynTraitTypeReprFromRaw(Raw::Element e) { result = TDynTraitTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnum`, if possible. */ TEnum convertEnumFromRaw(Raw::Element e) { result = TEnum(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExprStmt`, if possible. */ TExprStmt convertExprStmtFromRaw(Raw::Element e) { result = TExprStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExternBlock`, if possible. */ TExternBlock convertExternBlockFromRaw(Raw::Element e) { result = TExternBlock(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExternCrate`, if possible. */ TExternCrate convertExternCrateFromRaw(Raw::Element e) { result = TExternCrate(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExternItemList`, if possible. */ TExternItemList convertExternItemListFromRaw(Raw::Element e) { result = TExternItemList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExtractorStep`, if possible. */ TExtractorStep convertExtractorStepFromRaw(Raw::Element e) { result = TExtractorStep(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFieldExpr`, if possible. */ TFieldExpr convertFieldExprFromRaw(Raw::Element e) { result = TFieldExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFnPtrTypeRepr`, if possible. */ TFnPtrTypeRepr convertFnPtrTypeReprFromRaw(Raw::Element e) { result = TFnPtrTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForBinder`, if possible. */ TForBinder convertForBinderFromRaw(Raw::Element e) { result = TForBinder(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForExpr`, if possible. */ TForExpr convertForExprFromRaw(Raw::Element e) { result = TForExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForTypeRepr`, if possible. */ TForTypeRepr convertForTypeReprFromRaw(Raw::Element e) { result = TForTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFormat`, if possible. */ TFormat convertFormatFromRaw(Raw::Element e) { none() } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFormatArgsArg`, if possible. */ TFormatArgsArg convertFormatArgsArgFromRaw(Raw::Element e) { result = TFormatArgsArg(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFormatArgsExpr`, if possible. */ TFormatArgsExpr convertFormatArgsExprFromRaw(Raw::Element e) { result = TFormatArgsExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFormatArgument`, if possible. */ TFormatArgument convertFormatArgumentFromRaw(Raw::Element e) { none() } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFormatTemplateVariableAccess`, if possible. */ TFormatTemplateVariableAccess convertFormatTemplateVariableAccessFromRaw(Raw::Element e) { @@ -1173,42 +1242,49 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFunction`, if possible. */ TFunction convertFunctionFromRaw(Raw::Element e) { result = TFunction(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGenericArgList`, if possible. */ TGenericArgList convertGenericArgListFromRaw(Raw::Element e) { result = TGenericArgList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGenericParamList`, if possible. */ TGenericParamList convertGenericParamListFromRaw(Raw::Element e) { result = TGenericParamList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIdentPat`, if possible. */ TIdentPat convertIdentPatFromRaw(Raw::Element e) { result = TIdentPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIfExpr`, if possible. */ TIfExpr convertIfExprFromRaw(Raw::Element e) { result = TIfExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TImpl`, if possible. */ TImpl convertImplFromRaw(Raw::Element e) { result = TImpl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TImplTraitTypeRepr`, if possible. */ TImplTraitTypeRepr convertImplTraitTypeReprFromRaw(Raw::Element e) { @@ -1217,246 +1293,287 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIndexExpr`, if possible. */ TIndexExpr convertIndexExprFromRaw(Raw::Element e) { result = TIndexExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInferTypeRepr`, if possible. */ TInferTypeRepr convertInferTypeReprFromRaw(Raw::Element e) { result = TInferTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TItemList`, if possible. */ TItemList convertItemListFromRaw(Raw::Element e) { result = TItemList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLabel`, if possible. */ TLabel convertLabelFromRaw(Raw::Element e) { result = TLabel(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLetElse`, if possible. */ TLetElse convertLetElseFromRaw(Raw::Element e) { result = TLetElse(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLetExpr`, if possible. */ TLetExpr convertLetExprFromRaw(Raw::Element e) { result = TLetExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLetStmt`, if possible. */ TLetStmt convertLetStmtFromRaw(Raw::Element e) { result = TLetStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLifetime`, if possible. */ TLifetime convertLifetimeFromRaw(Raw::Element e) { result = TLifetime(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLifetimeArg`, if possible. */ TLifetimeArg convertLifetimeArgFromRaw(Raw::Element e) { result = TLifetimeArg(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLifetimeParam`, if possible. */ TLifetimeParam convertLifetimeParamFromRaw(Raw::Element e) { result = TLifetimeParam(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLiteralExpr`, if possible. */ TLiteralExpr convertLiteralExprFromRaw(Raw::Element e) { result = TLiteralExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLiteralPat`, if possible. */ TLiteralPat convertLiteralPatFromRaw(Raw::Element e) { result = TLiteralPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLoopExpr`, if possible. */ TLoopExpr convertLoopExprFromRaw(Raw::Element e) { result = TLoopExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroBlockExpr`, if possible. */ TMacroBlockExpr convertMacroBlockExprFromRaw(Raw::Element e) { result = TMacroBlockExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroCall`, if possible. */ TMacroCall convertMacroCallFromRaw(Raw::Element e) { result = TMacroCall(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroDef`, if possible. */ TMacroDef convertMacroDefFromRaw(Raw::Element e) { result = TMacroDef(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroExpr`, if possible. */ TMacroExpr convertMacroExprFromRaw(Raw::Element e) { result = TMacroExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroItems`, if possible. */ TMacroItems convertMacroItemsFromRaw(Raw::Element e) { result = TMacroItems(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroPat`, if possible. */ TMacroPat convertMacroPatFromRaw(Raw::Element e) { result = TMacroPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroRules`, if possible. */ TMacroRules convertMacroRulesFromRaw(Raw::Element e) { result = TMacroRules(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroTypeRepr`, if possible. */ TMacroTypeRepr convertMacroTypeReprFromRaw(Raw::Element e) { result = TMacroTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMatchArm`, if possible. */ TMatchArm convertMatchArmFromRaw(Raw::Element e) { result = TMatchArm(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMatchArmList`, if possible. */ TMatchArmList convertMatchArmListFromRaw(Raw::Element e) { result = TMatchArmList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMatchExpr`, if possible. */ TMatchExpr convertMatchExprFromRaw(Raw::Element e) { result = TMatchExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMatchGuard`, if possible. */ TMatchGuard convertMatchGuardFromRaw(Raw::Element e) { result = TMatchGuard(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMeta`, if possible. */ TMeta convertMetaFromRaw(Raw::Element e) { result = TMeta(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMethodCallExpr`, if possible. */ TMethodCallExpr convertMethodCallExprFromRaw(Raw::Element e) { result = TMethodCallExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMissing`, if possible. */ TMissing convertMissingFromRaw(Raw::Element e) { result = TMissing(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TModule`, if possible. */ TModule convertModuleFromRaw(Raw::Element e) { result = TModule(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TName`, if possible. */ TName convertNameFromRaw(Raw::Element e) { result = TName(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNameRef`, if possible. */ TNameRef convertNameRefFromRaw(Raw::Element e) { result = TNameRef(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNamedCrate`, if possible. */ TNamedCrate convertNamedCrateFromRaw(Raw::Element e) { result = TNamedCrate(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNeverTypeRepr`, if possible. */ TNeverTypeRepr convertNeverTypeReprFromRaw(Raw::Element e) { result = TNeverTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOffsetOfExpr`, if possible. */ TOffsetOfExpr convertOffsetOfExprFromRaw(Raw::Element e) { result = TOffsetOfExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOrPat`, if possible. */ TOrPat convertOrPatFromRaw(Raw::Element e) { result = TOrPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParam`, if possible. */ TParam convertParamFromRaw(Raw::Element e) { result = TParam(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParamList`, if possible. */ TParamList convertParamListFromRaw(Raw::Element e) { result = TParamList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenExpr`, if possible. */ TParenExpr convertParenExprFromRaw(Raw::Element e) { result = TParenExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenPat`, if possible. */ TParenPat convertParenPatFromRaw(Raw::Element e) { result = TParenPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenTypeRepr`, if possible. */ TParenTypeRepr convertParenTypeReprFromRaw(Raw::Element e) { result = TParenTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenthesizedArgList`, if possible. */ TParenthesizedArgList convertParenthesizedArgListFromRaw(Raw::Element e) { @@ -1465,162 +1582,189 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPath`, if possible. */ TPath convertPathFromRaw(Raw::Element e) { result = TPath(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPathExpr`, if possible. */ TPathExpr convertPathExprFromRaw(Raw::Element e) { result = TPathExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPathPat`, if possible. */ TPathPat convertPathPatFromRaw(Raw::Element e) { result = TPathPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPathSegment`, if possible. */ TPathSegment convertPathSegmentFromRaw(Raw::Element e) { result = TPathSegment(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPathTypeRepr`, if possible. */ TPathTypeRepr convertPathTypeReprFromRaw(Raw::Element e) { result = TPathTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPrefixExpr`, if possible. */ TPrefixExpr convertPrefixExprFromRaw(Raw::Element e) { result = TPrefixExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPtrTypeRepr`, if possible. */ TPtrTypeRepr convertPtrTypeReprFromRaw(Raw::Element e) { result = TPtrTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRangeExpr`, if possible. */ TRangeExpr convertRangeExprFromRaw(Raw::Element e) { result = TRangeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRangePat`, if possible. */ TRangePat convertRangePatFromRaw(Raw::Element e) { result = TRangePat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRefExpr`, if possible. */ TRefExpr convertRefExprFromRaw(Raw::Element e) { result = TRefExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRefPat`, if possible. */ TRefPat convertRefPatFromRaw(Raw::Element e) { result = TRefPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRefTypeRepr`, if possible. */ TRefTypeRepr convertRefTypeReprFromRaw(Raw::Element e) { result = TRefTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRename`, if possible. */ TRename convertRenameFromRaw(Raw::Element e) { result = TRename(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRestPat`, if possible. */ TRestPat convertRestPatFromRaw(Raw::Element e) { result = TRestPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRetTypeRepr`, if possible. */ TRetTypeRepr convertRetTypeReprFromRaw(Raw::Element e) { result = TRetTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TReturnExpr`, if possible. */ TReturnExpr convertReturnExprFromRaw(Raw::Element e) { result = TReturnExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TReturnTypeSyntax`, if possible. */ TReturnTypeSyntax convertReturnTypeSyntaxFromRaw(Raw::Element e) { result = TReturnTypeSyntax(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSelfParam`, if possible. */ TSelfParam convertSelfParamFromRaw(Raw::Element e) { result = TSelfParam(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSlicePat`, if possible. */ TSlicePat convertSlicePatFromRaw(Raw::Element e) { result = TSlicePat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSliceTypeRepr`, if possible. */ TSliceTypeRepr convertSliceTypeReprFromRaw(Raw::Element e) { result = TSliceTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSourceFile`, if possible. */ TSourceFile convertSourceFileFromRaw(Raw::Element e) { result = TSourceFile(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStatic`, if possible. */ TStatic convertStaticFromRaw(Raw::Element e) { result = TStatic(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStmtList`, if possible. */ TStmtList convertStmtListFromRaw(Raw::Element e) { result = TStmtList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStruct`, if possible. */ TStruct convertStructFromRaw(Raw::Element e) { result = TStruct(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructExpr`, if possible. */ TStructExpr convertStructExprFromRaw(Raw::Element e) { result = TStructExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructExprField`, if possible. */ TStructExprField convertStructExprFieldFromRaw(Raw::Element e) { result = TStructExprField(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructExprFieldList`, if possible. */ TStructExprFieldList convertStructExprFieldListFromRaw(Raw::Element e) { @@ -1629,30 +1773,35 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructField`, if possible. */ TStructField convertStructFieldFromRaw(Raw::Element e) { result = TStructField(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructFieldList`, if possible. */ TStructFieldList convertStructFieldListFromRaw(Raw::Element e) { result = TStructFieldList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructPat`, if possible. */ TStructPat convertStructPatFromRaw(Raw::Element e) { result = TStructPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructPatField`, if possible. */ TStructPatField convertStructPatFieldFromRaw(Raw::Element e) { result = TStructPatField(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructPatFieldList`, if possible. */ TStructPatFieldList convertStructPatFieldListFromRaw(Raw::Element e) { @@ -1661,120 +1810,140 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTokenTree`, if possible. */ TTokenTree convertTokenTreeFromRaw(Raw::Element e) { result = TTokenTree(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTrait`, if possible. */ TTrait convertTraitFromRaw(Raw::Element e) { result = TTrait(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTraitAlias`, if possible. */ TTraitAlias convertTraitAliasFromRaw(Raw::Element e) { result = TTraitAlias(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTryExpr`, if possible. */ TTryExpr convertTryExprFromRaw(Raw::Element e) { result = TTryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleExpr`, if possible. */ TTupleExpr convertTupleExprFromRaw(Raw::Element e) { result = TTupleExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleField`, if possible. */ TTupleField convertTupleFieldFromRaw(Raw::Element e) { result = TTupleField(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleFieldList`, if possible. */ TTupleFieldList convertTupleFieldListFromRaw(Raw::Element e) { result = TTupleFieldList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTuplePat`, if possible. */ TTuplePat convertTuplePatFromRaw(Raw::Element e) { result = TTuplePat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleStructPat`, if possible. */ TTupleStructPat convertTupleStructPatFromRaw(Raw::Element e) { result = TTupleStructPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleTypeRepr`, if possible. */ TTupleTypeRepr convertTupleTypeReprFromRaw(Raw::Element e) { result = TTupleTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeAlias`, if possible. */ TTypeAlias convertTypeAliasFromRaw(Raw::Element e) { result = TTypeAlias(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeArg`, if possible. */ TTypeArg convertTypeArgFromRaw(Raw::Element e) { result = TTypeArg(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeBound`, if possible. */ TTypeBound convertTypeBoundFromRaw(Raw::Element e) { result = TTypeBound(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeBoundList`, if possible. */ TTypeBoundList convertTypeBoundListFromRaw(Raw::Element e) { result = TTypeBoundList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeParam`, if possible. */ TTypeParam convertTypeParamFromRaw(Raw::Element e) { result = TTypeParam(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnderscoreExpr`, if possible. */ TUnderscoreExpr convertUnderscoreExprFromRaw(Raw::Element e) { result = TUnderscoreExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnimplemented`, if possible. */ TUnimplemented convertUnimplementedFromRaw(Raw::Element e) { result = TUnimplemented(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnion`, if possible. */ TUnion convertUnionFromRaw(Raw::Element e) { result = TUnion(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUse`, if possible. */ TUse convertUseFromRaw(Raw::Element e) { result = TUse(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUseBoundGenericArgs`, if possible. */ TUseBoundGenericArgs convertUseBoundGenericArgsFromRaw(Raw::Element e) { @@ -1783,66 +1952,77 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUseTree`, if possible. */ TUseTree convertUseTreeFromRaw(Raw::Element e) { result = TUseTree(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUseTreeList`, if possible. */ TUseTreeList convertUseTreeListFromRaw(Raw::Element e) { result = TUseTreeList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TVariant`, if possible. */ TVariant convertVariantFromRaw(Raw::Element e) { result = TVariant(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TVariantList`, if possible. */ TVariantList convertVariantListFromRaw(Raw::Element e) { result = TVariantList(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TVisibility`, if possible. */ TVisibility convertVisibilityFromRaw(Raw::Element e) { result = TVisibility(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWhereClause`, if possible. */ TWhereClause convertWhereClauseFromRaw(Raw::Element e) { result = TWhereClause(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWherePred`, if possible. */ TWherePred convertWherePredFromRaw(Raw::Element e) { result = TWherePred(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWhileExpr`, if possible. */ TWhileExpr convertWhileExprFromRaw(Raw::Element e) { result = TWhileExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWildcardPat`, if possible. */ TWildcardPat convertWildcardPatFromRaw(Raw::Element e) { result = TWildcardPat(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TYeetExpr`, if possible. */ TYeetExpr convertYeetExprFromRaw(Raw::Element e) { result = TYeetExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TYieldExpr`, if possible. */ TYieldExpr convertYieldExprFromRaw(Raw::Element e) { result = TYieldExpr(e) } diff --git a/rust/ql/lib/codeql/rust/internal/PathResolution.qll b/rust/ql/lib/codeql/rust/internal/PathResolution.qll index fc49b7ca5e82..2bf316f78bc0 100644 --- a/rust/ql/lib/codeql/rust/internal/PathResolution.qll +++ b/rust/ql/lib/codeql/rust/internal/PathResolution.qll @@ -90,24 +90,6 @@ private module UseOption = Option; private class UseOption = UseOption::Option; -/** - * Holds if `n` is superseded by an attribute macro expansion. That is, `n` is - * an item or a transitive child of an item with an attribute macro expansion. - */ -predicate supersededByAttributeMacroExpansion(AstNode n) { - n.(Item).hasAttributeMacroExpansion() - or - exists(AstNode parent | - n.getParentNode() = parent and - supersededByAttributeMacroExpansion(parent) and - // Don't exclude expansions themselves as they supercede other nodes. - not n = parent.(Item).getAttributeMacroExpansion() and - // Don't consider attributes themselves to be superseded. E.g., in `#[a] fn - // f() {}` the macro expansion supercedes `fn f() {}` but not `#[a]`. - not n instanceof Attr - ) -} - /** * An item that may be referred to by a path, and which is a node in * the _item graph_. @@ -186,10 +168,7 @@ predicate supersededByAttributeMacroExpansion(AstNode n) { * - https://doc.rust-lang.org/reference/names/namespaces.html */ abstract class ItemNode extends Locatable { - ItemNode() { - // Exclude items that are superseded by the expansion of an attribute macro. - not supersededByAttributeMacroExpansion(this) - } + ItemNode() { not this.(Item).hasAttributeMacroExpansion() } /** Gets the (original) name of this item. */ abstract string getName(); diff --git a/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll b/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll index f7606b941ace..d8b2703203dc 100644 --- a/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll +++ b/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll @@ -10,9 +10,8 @@ private import utils.test.InlineExpectationsTest private module ResolveTest implements TestSig { string getARelevantTag() { result = "item" } - private predicate itemAt(ItemNode i, string filepath, int line, boolean inMacro) { - i.getLocation().hasLocationInfo(filepath, _, _, line, _) and - if i.(AstNode).isInMacroExpansion() then inMacro = true else inMacro = false + private predicate itemAt(ItemNode i, string filepath, int line) { + i.getLocation().hasLocationInfo(filepath, _, _, line, _) } private predicate commmentAt(string text, string filepath, int line) { @@ -25,7 +24,7 @@ private module ResolveTest implements TestSig { } private predicate item(ItemNode i, string value) { - exists(string filepath, int line, boolean inMacro | itemAt(i, filepath, line, inMacro) | + exists(string filepath, int line | itemAt(i, filepath, line) | if i instanceof SourceFile then value = i.getFile().getBaseName() else ( diff --git a/rust/ql/src/queries/unusedentities/UnreachableCode.ql b/rust/ql/src/queries/unusedentities/UnreachableCode.ql index 15a45c6f4b58..bb9092fb5703 100644 --- a/rust/ql/src/queries/unusedentities/UnreachableCode.ql +++ b/rust/ql/src/queries/unusedentities/UnreachableCode.ql @@ -33,7 +33,7 @@ predicate hiddenNode(AstNode n) { n instanceof ControlFlowGraphImpl::PostOrderTree and // location is counter-intuitive not n instanceof MacroExpr or - n.isInMacroExpansion() + n.isFromMacroExpansion() } /** diff --git a/rust/ql/src/queries/unusedentities/UnusedValue.ql b/rust/ql/src/queries/unusedentities/UnusedValue.ql index 14204a2273b7..07e80b00b45a 100644 --- a/rust/ql/src/queries/unusedentities/UnusedValue.ql +++ b/rust/ql/src/queries/unusedentities/UnusedValue.ql @@ -18,7 +18,7 @@ from AstNode write, Ssa::Variable v where variableWrite(_, write, v) and not v instanceof DiscardVariable and - not write.isInMacroExpansion() and + not write.isFromMacroExpansion() and not isAllowableUnused(v) and // SSA definitions are only created for live writes not write = any(Ssa::WriteDefinition def).getWriteAccess().getAstNode() and diff --git a/rust/ql/src/queries/unusedentities/UnusedVariable.qll b/rust/ql/src/queries/unusedentities/UnusedVariable.qll index ad75415634c6..c0684636e77b 100644 --- a/rust/ql/src/queries/unusedentities/UnusedVariable.qll +++ b/rust/ql/src/queries/unusedentities/UnusedVariable.qll @@ -36,7 +36,7 @@ class IncompleteCallable extends Callable { */ predicate isAllowableUnused(Variable v) { // in a macro expansion - v.getPat().isInMacroExpansion() + v.getPat().isInMacroExpansion() // TODO: replace with `isFromMacroExpansion()` when false positives have been removed or // declared in an incomplete callable v.getEnclosingCfgScope() instanceof IncompleteCallable diff --git a/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected b/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected index ffff0f53e7e5..1a0ded6950d3 100644 --- a/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected +++ b/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected @@ -174,7 +174,7 @@ macro_expansion.rs: # 1| getPath(): [Path] MyTrait # 1| getSegment(): [PathSegment] MyTrait # 1| getIdentifier(): [NameRef] MyTrait -# 3| getItem(1): [Function] fn foo +# 3| getItem(1): [Function] (item with attribute macro expansion) # 4| getAttributeMacroExpansion(): [MacroItems] MacroItems # 4| getItem(0): [Function] fn foo # 4| getParamList(): [ParamList] ParamList @@ -190,7 +190,7 @@ macro_expansion.rs: # 5| getIdentifier(): [NameRef] concat # 5| getTokenTree(): [TokenTree] TokenTree # 5| getMacroCallExpansion(): [StringLiteralExpr] "Hello world!" -# 7| getStatement(1): [Function] fn inner +# 7| getStatement(1): [Function] (item with attribute macro expansion) # 8| getAttributeMacroExpansion(): [MacroItems] MacroItems # 8| getItem(0): [Function] fn inner_0 # 8| getParamList(): [ParamList] ParamList @@ -202,16 +202,12 @@ macro_expansion.rs: # 8| getFunctionBody(): [BlockExpr] { ... } # 8| getStmtList(): [StmtList] StmtList # 8| getName(): [Name] inner_1 -# 8| getParamList(): [ParamList] ParamList # 7| getAttr(0): [Attr] Attr # 7| getMeta(): [Meta] Meta # 7| getPath(): [Path] repeat # 7| getSegment(): [PathSegment] repeat # 7| getIdentifier(): [NameRef] repeat # 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner # 10| getStatement(2): [ExprStmt] ExprStmt # 10| getExpr(): [CallExpr] inner_0(...) # 10| getArgList(): [ArgList] ArgList @@ -242,7 +238,7 @@ macro_expansion.rs: # 5| getIdentifier(): [NameRef] concat # 5| getTokenTree(): [TokenTree] TokenTree # 5| getMacroCallExpansion(): [StringLiteralExpr] "Hello world!" -# 7| getStatement(1): [Function] fn inner +# 7| getStatement(1): [Function] (item with attribute macro expansion) # 8| getAttributeMacroExpansion(): [MacroItems] MacroItems # 8| getItem(0): [Function] fn inner_0 # 8| getParamList(): [ParamList] ParamList @@ -254,16 +250,12 @@ macro_expansion.rs: # 8| getFunctionBody(): [BlockExpr] { ... } # 8| getStmtList(): [StmtList] StmtList # 8| getName(): [Name] inner_1 -# 8| getParamList(): [ParamList] ParamList # 7| getAttr(0): [Attr] Attr # 7| getMeta(): [Meta] Meta # 7| getPath(): [Path] repeat # 7| getSegment(): [PathSegment] repeat # 7| getIdentifier(): [NameRef] repeat # 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner # 10| getStatement(2): [ExprStmt] ExprStmt # 10| getExpr(): [CallExpr] inner_0(...) # 10| getArgList(): [ArgList] ArgList @@ -280,53 +272,14 @@ macro_expansion.rs: # 11| getIdentifier(): [NameRef] inner_1 # 4| getName(): [Name] foo_new # 4| getVisibility(): [Visibility] Visibility -# 4| getParamList(): [ParamList] ParamList # 3| getAttr(0): [Attr] Attr # 3| getMeta(): [Meta] Meta # 3| getPath(): [Path] add_one # 3| getSegment(): [PathSegment] add_one # 3| getIdentifier(): [NameRef] add_one -# 4| getFunctionBody(): [BlockExpr] { ... } -# 4| getStmtList(): [StmtList] StmtList -# 5| getStatement(0): [ExprStmt] ExprStmt -# 5| getExpr(): [AssignmentExpr] ... = ... -# 5| getLhs(): [UnderscoreExpr] _ -# 5| getRhs(): [MacroExpr] MacroExpr -# 5| getMacroCall(): [MacroCall] concat!... -# 5| getPath(): [Path] concat -# 5| getSegment(): [PathSegment] concat -# 5| getIdentifier(): [NameRef] concat -# 5| getTokenTree(): [TokenTree] TokenTree -# 7| getStatement(1): [Function] fn inner -# 8| getParamList(): [ParamList] ParamList -# 7| getAttr(0): [Attr] Attr -# 7| getMeta(): [Meta] Meta -# 7| getPath(): [Path] repeat -# 7| getSegment(): [PathSegment] repeat -# 7| getIdentifier(): [NameRef] repeat -# 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner -# 10| getStatement(2): [ExprStmt] ExprStmt -# 10| getExpr(): [CallExpr] inner_0(...) -# 10| getArgList(): [ArgList] ArgList -# 10| getFunction(): [PathExpr] inner_0 -# 10| getPath(): [Path] inner_0 -# 10| getSegment(): [PathSegment] inner_0 -# 10| getIdentifier(): [NameRef] inner_0 -# 11| getStatement(3): [ExprStmt] ExprStmt -# 11| getExpr(): [CallExpr] inner_1(...) -# 11| getArgList(): [ArgList] ArgList -# 11| getFunction(): [PathExpr] inner_1 -# 11| getPath(): [Path] inner_1 -# 11| getSegment(): [PathSegment] inner_1 -# 11| getIdentifier(): [NameRef] inner_1 -# 4| getName(): [Name] foo -# 4| getVisibility(): [Visibility] Visibility -# 14| getItem(2): [Function] fn bar +# 14| getItem(2): [Function] (item with attribute macro expansion) # 15| getAttributeMacroExpansion(): [MacroItems] MacroItems -# 15| getItem(0): [Function] fn bar_0 +# 15| getItem(0): [Function] (item with attribute macro expansion) # 16| getAttributeMacroExpansion(): [MacroItems] MacroItems # 16| getItem(0): [Function] fn bar_0 # 16| getParamList(): [ParamList] ParamList @@ -340,17 +293,12 @@ macro_expansion.rs: # 16| getStmtList(): [StmtList] StmtList # 16| getName(): [Name] bar_0_new # 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 15| getAttr(0): [Attr] Attr # 15| getMeta(): [Meta] Meta # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar_0 -# 16| getVisibility(): [Visibility] Visibility -# 15| getItem(1): [Function] fn bar_1 +# 15| getItem(1): [Function] (item with attribute macro expansion) # 16| getAttributeMacroExpansion(): [MacroItems] MacroItems # 16| getItem(0): [Function] fn bar_1 # 16| getParamList(): [ParamList] ParamList @@ -364,17 +312,11 @@ macro_expansion.rs: # 16| getStmtList(): [StmtList] StmtList # 16| getName(): [Name] bar_1_new # 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 15| getAttr(0): [Attr] Attr # 15| getMeta(): [Meta] Meta # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar_1 -# 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 14| getAttr(0): [Attr] Attr # 14| getMeta(): [Meta] Meta # 14| getPath(): [Path] repeat @@ -386,22 +328,13 @@ macro_expansion.rs: # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar -# 16| getVisibility(): [Visibility] Visibility -# 18| getItem(3): [Function] fn baz +# 18| getItem(3): [Function] (item with attribute macro expansion) # 18| getAttributeMacroExpansion(): [MacroItems] MacroItems -# 19| getParamList(): [ParamList] ParamList # 18| getAttr(0): [Attr] Attr # 18| getMeta(): [Meta] Meta # 18| getPath(): [Path] erase # 18| getSegment(): [PathSegment] erase # 18| getIdentifier(): [NameRef] erase -# 19| getFunctionBody(): [BlockExpr] { ... } -# 19| getStmtList(): [StmtList] StmtList -# 19| getName(): [Name] baz -# 19| getVisibility(): [Visibility] Visibility # 22| getItem(4): [MacroRules] MacroRules # 22| getName(): [Name] hello # 22| getTokenTree(): [TokenTree] TokenTree @@ -410,7 +343,7 @@ macro_expansion.rs: # 28| getVisibility(): [Visibility] Visibility # 30| getItem(6): [Impl] impl S { ... } # 30| getAssocItemList(): [AssocItemList] AssocItemList -# 31| getAssocItem(0): [Function] fn bzz +# 31| getAssocItem(0): [Function] (item with attribute macro expansion) # 32| getAttributeMacroExpansion(): [MacroItems] MacroItems # 32| getItem(0): [Function] fn bzz_0 # 32| getParamList(): [ParamList] ParamList @@ -556,24 +489,12 @@ macro_expansion.rs: # 31| getIdentifier(): [NameRef] _print # 32| getName(): [Name] bzz_2 # 32| getVisibility(): [Visibility] Visibility -# 32| getParamList(): [ParamList] ParamList # 31| getAttr(0): [Attr] Attr # 31| getMeta(): [Meta] Meta # 31| getPath(): [Path] repeat # 31| getSegment(): [PathSegment] repeat # 31| getIdentifier(): [NameRef] repeat # 31| getTokenTree(): [TokenTree] TokenTree -# 32| getFunctionBody(): [BlockExpr] { ... } -# 32| getStmtList(): [StmtList] StmtList -# 33| getStatement(0): [ExprStmt] ExprStmt -# 33| getExpr(): [MacroExpr] MacroExpr -# 33| getMacroCall(): [MacroCall] hello!... -# 33| getPath(): [Path] hello -# 33| getSegment(): [PathSegment] hello -# 33| getIdentifier(): [NameRef] hello -# 33| getTokenTree(): [TokenTree] TokenTree -# 32| getName(): [Name] bzz -# 32| getVisibility(): [Visibility] Visibility # 30| getSelfTy(): [PathTypeRepr] S # 30| getPath(): [Path] S # 30| getSegment(): [PathSegment] S diff --git a/rust/ql/test/extractor-tests/macro-expansion/test.expected b/rust/ql/test/extractor-tests/macro-expansion/test.expected index 930a0f443bd8..5abff30113bc 100644 --- a/rust/ql/test/extractor-tests/macro-expansion/test.expected +++ b/rust/ql/test/extractor-tests/macro-expansion/test.expected @@ -1,19 +1,19 @@ attribute_macros -| macro_expansion.rs:3:1:12:1 | fn foo | 0 | macro_expansion.rs:4:1:12:1 | fn foo | -| macro_expansion.rs:3:1:12:1 | fn foo | 1 | macro_expansion.rs:4:1:12:1 | fn foo_new | -| macro_expansion.rs:7:5:8:17 | fn inner | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | -| macro_expansion.rs:7:5:8:17 | fn inner | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | -| macro_expansion.rs:7:5:8:17 | fn inner | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | -| macro_expansion.rs:7:5:8:17 | fn inner | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | -| macro_expansion.rs:14:1:16:15 | fn bar | 0 | macro_expansion.rs:15:1:16:15 | fn bar_0 | -| macro_expansion.rs:14:1:16:15 | fn bar | 1 | macro_expansion.rs:15:1:16:15 | fn bar_1 | -| macro_expansion.rs:15:1:16:15 | fn bar_0 | 0 | macro_expansion.rs:16:1:16:15 | fn bar_0 | -| macro_expansion.rs:15:1:16:15 | fn bar_0 | 1 | macro_expansion.rs:16:1:16:15 | fn bar_0_new | -| macro_expansion.rs:15:1:16:15 | fn bar_1 | 0 | macro_expansion.rs:16:1:16:15 | fn bar_1 | -| macro_expansion.rs:15:1:16:15 | fn bar_1 | 1 | macro_expansion.rs:16:1:16:15 | fn bar_1_new | -| macro_expansion.rs:31:5:34:5 | fn bzz | 0 | macro_expansion.rs:32:5:34:5 | fn bzz_0 | -| macro_expansion.rs:31:5:34:5 | fn bzz | 1 | macro_expansion.rs:32:5:34:5 | fn bzz_1 | -| macro_expansion.rs:31:5:34:5 | fn bzz | 2 | macro_expansion.rs:32:5:34:5 | fn bzz_2 | +| macro_expansion.rs:3:1:12:1 | (item with attribute macro expansion) | 0 | macro_expansion.rs:4:1:12:1 | fn foo | +| macro_expansion.rs:3:1:12:1 | (item with attribute macro expansion) | 1 | macro_expansion.rs:4:1:12:1 | fn foo_new | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | +| macro_expansion.rs:14:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | +| macro_expansion.rs:14:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:16:1:16:15 | fn bar_0 | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:16:1:16:15 | fn bar_1 | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:16:1:16:15 | fn bar_0_new | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:16:1:16:15 | fn bar_1_new | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 0 | macro_expansion.rs:32:5:34:5 | fn bzz_0 | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 1 | macro_expansion.rs:32:5:34:5 | fn bzz_1 | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 2 | macro_expansion.rs:32:5:34:5 | fn bzz_2 | derive_macros | macro_expansion.rs:83:1:86:1 | struct MyDerive | 0 | 0 | macro_expansion.rs:84:8:85:9 | impl ...::Debug for MyDerive::<...> { ... } | | macro_expansion.rs:88:1:92:1 | enum MyDeriveEnum | 0 | 0 | macro_expansion.rs:89:6:91:12 | impl ...::PartialEq for MyDeriveEnum::<...> { ... } | @@ -46,8 +46,6 @@ macro_calls | macro_expansion.rs:79:12:79:20 | my_int!... | macro_expansion.rs:79:12:79:18 | i32 | unexpanded_macro_calls | included/included.rs:2:9:2:39 | concat!... | -| macro_expansion.rs:5:9:5:35 | concat!... | -| macro_expansion.rs:33:9:33:16 | hello!... | | macro_expansion.rs:56:9:56:31 | concat!... | | macro_expansion.rs:63:9:63:32 | include_str!... | warnings diff --git a/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected b/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected index b88537912102..30dbc24103b9 100644 --- a/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected +++ b/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected @@ -5,7 +5,7 @@ lib.rs: # 1| getVisibility(): [Visibility] Visibility macro_in_library.rs: # 1| [SourceFile] SourceFile -# 1| getItem(0): [MacroCall] +# 1| getItem(0): [MacroCall] (item with attribute macro expansion) # 2| getAttributeMacroExpansion(): [MacroItems] MacroItems # 2| getItem(0): [Function] fn foo # 2| getParamList(): [ParamList] ParamList diff --git a/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected index 352992bf4f2d..ca5c386b720c 100644 --- a/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected @@ -7,4 +7,3 @@ multipleCallTargets | test.rs:447:30:447:67 | pinned.poll_read(...) | | test.rs:470:26:470:54 | pinned.poll_fill_buf(...) | | test.rs:519:50:519:66 | ...::from(...) | -| test.rs:519:50:519:66 | ...::from(...) | diff --git a/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected b/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected index 190628f93d7d..bfe1ce0e56bc 100644 --- a/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected +++ b/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected @@ -15,4 +15,3 @@ | test.rs:332:22:332:50 | ...::new | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:373:19:373:36 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:519:16:519:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). | -| test.rs:519:16:519:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). | diff --git a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected index e128916f8473..24a0cf78aec0 100644 --- a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected +++ b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected @@ -12,20 +12,12 @@ models | 11 | Summary: ::as_str; Argument[self]; ReturnValue; value | edges | test.rs:11:31:11:31 | a | test.rs:13:14:13:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:13:14:13:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:11:31:11:31 | a | test.rs:14:14:14:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:14:14:14:14 | a | provenance | | | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | provenance | | | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | provenance | | | test.rs:13:14:13:14 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | -| test.rs:13:14:13:14 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:14:14:14:14 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:14:14:14:14 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | provenance | | | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | provenance | | | test.rs:98:9:98:31 | ...: ...::Path::<...> | test.rs:100:17:100:33 | path.into_inner() | provenance | MaD:9 | | test.rs:98:9:98:31 | ...: ...::Path::<...> | test.rs:100:17:100:33 | path.into_inner() [tuple.0] | provenance | MaD:6 | @@ -87,37 +79,21 @@ edges | test.rs:139:41:139:42 | to | test.rs:98:9:98:31 | ...: ...::Path::<...> | provenance | Src:MaD:5 | | test.rs:140:45:140:46 | to | test.rs:109:9:109:41 | ...: ...::Path::<...> | provenance | Src:MaD:5 | | test.rs:242:33:242:35 | map | test.rs:242:38:242:46 | ...: String | provenance | Src:MaD:2 | -| test.rs:242:33:242:35 | map | test.rs:242:38:242:46 | ...: String | provenance | Src:MaD:2 | | test.rs:242:38:242:46 | ...: String | test.rs:244:18:244:18 | a | provenance | | -| test.rs:242:38:242:46 | ...: String | test.rs:244:18:244:18 | a | provenance | | -| test.rs:250:46:250:49 | then | test.rs:251:25:251:33 | ...: String | provenance | Src:MaD:3 | | test.rs:250:46:250:49 | then | test.rs:251:25:251:33 | ...: String | provenance | Src:MaD:3 | | test.rs:251:25:251:33 | ...: String | test.rs:252:22:252:22 | a | provenance | | -| test.rs:251:25:251:33 | ...: String | test.rs:252:22:252:22 | a | provenance | | -| test.rs:259:50:259:57 | and_then | test.rs:260:26:260:32 | ...: u64 | provenance | Src:MaD:1 | | test.rs:259:50:259:57 | and_then | test.rs:260:26:260:32 | ...: u64 | provenance | Src:MaD:1 | | test.rs:260:26:260:32 | ...: u64 | test.rs:263:22:263:23 | id | provenance | | -| test.rs:260:26:260:32 | ...: u64 | test.rs:263:22:263:23 | id | provenance | | | test.rs:272:75:272:77 | map | test.rs:273:15:273:23 | ...: String | provenance | Src:MaD:2 | -| test.rs:272:75:272:77 | map | test.rs:273:15:273:23 | ...: String | provenance | Src:MaD:2 | -| test.rs:273:15:273:23 | ...: String | test.rs:275:22:275:22 | a | provenance | | | test.rs:273:15:273:23 | ...: String | test.rs:275:22:275:22 | a | provenance | | nodes | test.rs:11:31:11:31 | a | semmle.label | a | -| test.rs:11:31:11:31 | a | semmle.label | a | | test.rs:13:14:13:14 | a | semmle.label | a | -| test.rs:13:14:13:14 | a | semmle.label | a | -| test.rs:13:14:13:23 | a.as_str() | semmle.label | a.as_str() | | test.rs:13:14:13:23 | a.as_str() | semmle.label | a.as_str() | | test.rs:14:14:14:14 | a | semmle.label | a | -| test.rs:14:14:14:14 | a | semmle.label | a | | test.rs:14:14:14:25 | a.as_bytes() | semmle.label | a.as_bytes() | -| test.rs:14:14:14:25 | a.as_bytes() | semmle.label | a.as_bytes() | -| test.rs:15:14:15:14 | a | semmle.label | a | | test.rs:15:14:15:14 | a | semmle.label | a | | test.rs:68:15:68:15 | a | semmle.label | a | -| test.rs:68:15:68:15 | a | semmle.label | a | -| test.rs:70:14:70:14 | a | semmle.label | a | | test.rs:70:14:70:14 | a | semmle.label | a | | test.rs:98:9:98:31 | ...: ...::Path::<...> | semmle.label | ...: ...::Path::<...> | | test.rs:100:13:100:13 | a | semmle.label | a | @@ -162,39 +138,23 @@ nodes | test.rs:139:41:139:42 | to | semmle.label | to | | test.rs:140:45:140:46 | to | semmle.label | to | | test.rs:242:33:242:35 | map | semmle.label | map | -| test.rs:242:33:242:35 | map | semmle.label | map | | test.rs:242:38:242:46 | ...: String | semmle.label | ...: String | -| test.rs:242:38:242:46 | ...: String | semmle.label | ...: String | -| test.rs:244:18:244:18 | a | semmle.label | a | | test.rs:244:18:244:18 | a | semmle.label | a | | test.rs:250:46:250:49 | then | semmle.label | then | -| test.rs:250:46:250:49 | then | semmle.label | then | | test.rs:251:25:251:33 | ...: String | semmle.label | ...: String | -| test.rs:251:25:251:33 | ...: String | semmle.label | ...: String | -| test.rs:252:22:252:22 | a | semmle.label | a | | test.rs:252:22:252:22 | a | semmle.label | a | | test.rs:259:50:259:57 | and_then | semmle.label | and_then | -| test.rs:259:50:259:57 | and_then | semmle.label | and_then | | test.rs:260:26:260:32 | ...: u64 | semmle.label | ...: u64 | -| test.rs:260:26:260:32 | ...: u64 | semmle.label | ...: u64 | -| test.rs:263:22:263:23 | id | semmle.label | id | | test.rs:263:22:263:23 | id | semmle.label | id | | test.rs:272:75:272:77 | map | semmle.label | map | -| test.rs:272:75:272:77 | map | semmle.label | map | -| test.rs:273:15:273:23 | ...: String | semmle.label | ...: String | | test.rs:273:15:273:23 | ...: String | semmle.label | ...: String | | test.rs:275:22:275:22 | a | semmle.label | a | -| test.rs:275:22:275:22 | a | semmle.label | a | subpaths testFailures #select | test.rs:13:14:13:23 | a.as_str() | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:13:14:13:23 | a.as_str() | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:14:14:14:25 | a.as_bytes() | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | $@ | test.rs:11:31:11:31 | a | a | | test.rs:14:14:14:25 | a.as_bytes() | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | $@ | test.rs:11:31:11:31 | a | a | | test.rs:15:14:15:14 | a | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:15:14:15:14 | a | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:70:14:70:14 | a | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | $@ | test.rs:68:15:68:15 | a | a | | test.rs:70:14:70:14 | a | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | $@ | test.rs:68:15:68:15 | a | a | | test.rs:101:14:101:23 | a.as_str() | test.rs:139:41:139:42 | to | test.rs:101:14:101:23 | a.as_str() | $@ | test.rs:139:41:139:42 | to | to | | test.rs:102:14:102:25 | a.as_bytes() | test.rs:139:41:139:42 | to | test.rs:102:14:102:25 | a.as_bytes() | $@ | test.rs:139:41:139:42 | to | to | @@ -203,10 +163,6 @@ testFailures | test.rs:114:14:114:14 | b | test.rs:140:45:140:46 | to | test.rs:114:14:114:14 | b | $@ | test.rs:140:45:140:46 | to | to | | test.rs:132:14:132:14 | a | test.rs:127:5:127:20 | to | test.rs:132:14:132:14 | a | $@ | test.rs:127:5:127:20 | to | to | | test.rs:244:18:244:18 | a | test.rs:242:33:242:35 | map | test.rs:244:18:244:18 | a | $@ | test.rs:242:33:242:35 | map | map | -| test.rs:244:18:244:18 | a | test.rs:242:33:242:35 | map | test.rs:244:18:244:18 | a | $@ | test.rs:242:33:242:35 | map | map | -| test.rs:252:22:252:22 | a | test.rs:250:46:250:49 | then | test.rs:252:22:252:22 | a | $@ | test.rs:250:46:250:49 | then | then | | test.rs:252:22:252:22 | a | test.rs:250:46:250:49 | then | test.rs:252:22:252:22 | a | $@ | test.rs:250:46:250:49 | then | then | | test.rs:263:22:263:23 | id | test.rs:259:50:259:57 | and_then | test.rs:263:22:263:23 | id | $@ | test.rs:259:50:259:57 | and_then | and_then | -| test.rs:263:22:263:23 | id | test.rs:259:50:259:57 | and_then | test.rs:263:22:263:23 | id | $@ | test.rs:259:50:259:57 | and_then | and_then | -| test.rs:275:22:275:22 | a | test.rs:272:75:272:77 | map | test.rs:275:22:275:22 | a | $@ | test.rs:272:75:272:77 | map | map | | test.rs:275:22:275:22 | a | test.rs:272:75:272:77 | map | test.rs:275:22:275:22 | a | $@ | test.rs:272:75:272:77 | map | map | diff --git a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected index 549f9c4ab762..20a20ce3f9b1 100644 --- a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected +++ b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected @@ -1,12 +1,7 @@ | test.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:22:14:22:19 | TuplePat | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:22:14:22:19 | TuplePat | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:48:14:48:30 | MyStruct {...} | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:48:14:48:30 | MyStruct {...} | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:58:14:58:15 | ms | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:58:14:58:15 | ms | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:68:15:68:15 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:68:15:68:15 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:127:5:127:20 | to | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:127:5:127:20 | to | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -48,20 +43,6 @@ | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -70,15 +51,6 @@ | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -87,15 +59,6 @@ | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | diff --git a/rust/ql/test/library-tests/variables/variables.ql b/rust/ql/test/library-tests/variables/variables.ql index dbde4f56e858..9997b29c7d0e 100644 --- a/rust/ql/test/library-tests/variables/variables.ql +++ b/rust/ql/test/library-tests/variables/variables.ql @@ -35,7 +35,7 @@ module VariableAccessTest implements TestSig { private predicate declAt(Variable v, string filepath, int line, boolean inMacro) { variable(v) and v.getLocation().hasLocationInfo(filepath, _, _, line, _) and - if v.getPat().isInMacroExpansion() then inMacro = true else inMacro = false + if v.getPat().isFromMacroExpansion() then inMacro = true else inMacro = false } private predicate commmentAt(string text, string filepath, int line) { diff --git a/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected index b1c7e787dee5..538ecf9c2e35 100644 --- a/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected @@ -1,3 +1,2 @@ multipleCallTargets | test.rs:117:9:117:21 | ptr.is_null() | -| test.rs:117:9:117:21 | ptr.is_null() | diff --git a/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected index 5caae105914c..821f75cee26d 100644 --- a/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected @@ -1,3 +1,2 @@ multipleCallTargets | request_forgery_tests.rs:30:36:30:52 | user_url.as_str() | -| request_forgery_tests.rs:30:36:30:52 | user_url.as_str() | diff --git a/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected b/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected index aa5003a0e9d3..0f931ed3a0f8 100644 --- a/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected +++ b/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected @@ -1,29 +1,20 @@ #select | request_forgery_tests.rs:8:24:8:35 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:24:8:35 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:8:24:8:35 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:24:8:35 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:17:25:17:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:17:25:17:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:21:25:21:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:21:25:21:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:25:25:25:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:25:25:25:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:31:29:31:40 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:29:31:40 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:31:29:31:40 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:29:31:40 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:37:37:37:48 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:37:37:48 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:37:37:37:48 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:37:37:48 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:68:28:68:39 | ...::get | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:68:28:68:39 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:65:33:65:40 | and_then | user-provided value | | request_forgery_tests.rs:68:28:68:39 | ...::get | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:68:28:68:39 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:65:33:65:40 | and_then | user-provided value | edges | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:38:8:45 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:38:8:45 | user_url | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:16:27:16:49 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:20:27:20:57 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:24:27:24:70 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:43:31:50 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:43:31:50 | user_url | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:51:37:58 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:51:37:58 | user_url | provenance | | -| request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | request_forgery_tests.rs:8:24:8:35 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | request_forgery_tests.rs:8:24:8:35 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:8:38:8:45 | user_url | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:8:38:8:45 | user_url | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | provenance | | | request_forgery_tests.rs:16:13:16:15 | url | request_forgery_tests.rs:17:39:17:41 | url | provenance | | | request_forgery_tests.rs:16:27:16:49 | ...::format(...) | request_forgery_tests.rs:16:27:16:49 | { ... } | provenance | | | request_forgery_tests.rs:16:27:16:49 | ...::must_use(...) | request_forgery_tests.rs:16:13:16:15 | url | provenance | | @@ -46,21 +37,13 @@ edges | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | request_forgery_tests.rs:25:25:25:36 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:25:39:25:41 | url | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | provenance | | | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | request_forgery_tests.rs:31:29:31:40 | ...::get | provenance | MaD:1 Sink:MaD:1 | -| request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | request_forgery_tests.rs:31:29:31:40 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:31:43:31:50 | user_url | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:31:43:31:50 | user_url | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | request_forgery_tests.rs:37:37:37:48 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | request_forgery_tests.rs:37:37:37:48 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:37:51:37:58 | user_url | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:37:51:37:58 | user_url | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:65:49:65:57 | ...: String | provenance | Src:MaD:2 | | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:65:49:65:57 | ...: String | provenance | Src:MaD:2 | | request_forgery_tests.rs:65:49:65:57 | ...: String | request_forgery_tests.rs:68:42:68:42 | a | provenance | | -| request_forgery_tests.rs:65:49:65:57 | ...: String | request_forgery_tests.rs:68:42:68:42 | a | provenance | | -| request_forgery_tests.rs:68:41:68:42 | &a [&ref] | request_forgery_tests.rs:68:28:68:39 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | request_forgery_tests.rs:68:28:68:39 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:68:42:68:42 | a | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | provenance | | -| request_forgery_tests.rs:68:42:68:42 | a | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | provenance | | models | 1 | Sink: reqwest::get; Argument[0]; request-url | | 2 | Source: <_ as warp::filter::Filter>::and_then; Argument[0].Parameter[0..7]; remote | @@ -68,13 +51,9 @@ models | 4 | Summary: core::hint::must_use; Argument[0]; ReturnValue; value | nodes | request_forgery_tests.rs:5:29:5:36 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:5:29:5:36 | user_url | semmle.label | user_url | | request_forgery_tests.rs:8:24:8:35 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:8:24:8:35 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:8:38:8:45 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:8:38:8:45 | user_url | semmle.label | user_url | | request_forgery_tests.rs:16:13:16:15 | url | semmle.label | url | | request_forgery_tests.rs:16:27:16:49 | ...::format(...) | semmle.label | ...::format(...) | | request_forgery_tests.rs:16:27:16:49 | ...::must_use(...) | semmle.label | ...::must_use(...) | @@ -100,25 +79,14 @@ nodes | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | semmle.label | &url [&ref] | | request_forgery_tests.rs:25:39:25:41 | url | semmle.label | url | | request_forgery_tests.rs:31:29:31:40 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:31:29:31:40 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | semmle.label | &user_url [&ref] | -| request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | semmle.label | &user_url [&ref] | -| request_forgery_tests.rs:31:43:31:50 | user_url | semmle.label | user_url | | request_forgery_tests.rs:31:43:31:50 | user_url | semmle.label | user_url | | request_forgery_tests.rs:37:37:37:48 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:37:37:37:48 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:37:51:37:58 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:37:51:37:58 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:65:33:65:40 | and_then | semmle.label | and_then | | request_forgery_tests.rs:65:33:65:40 | and_then | semmle.label | and_then | | request_forgery_tests.rs:65:49:65:57 | ...: String | semmle.label | ...: String | -| request_forgery_tests.rs:65:49:65:57 | ...: String | semmle.label | ...: String | -| request_forgery_tests.rs:68:28:68:39 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:68:28:68:39 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | semmle.label | &a [&ref] | -| request_forgery_tests.rs:68:41:68:42 | &a [&ref] | semmle.label | &a [&ref] | -| request_forgery_tests.rs:68:42:68:42 | a | semmle.label | a | | request_forgery_tests.rs:68:42:68:42 | a | semmle.label | a | subpaths diff --git a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected index c5f0f59966cb..c52863616626 100644 --- a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected +++ b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected @@ -15,8 +15,10 @@ | main.rs:322:12:322:12 | j | Variable $@ is assigned a value that is never used. | main.rs:322:12:322:12 | j | j | | main.rs:382:9:382:9 | x | Variable $@ is assigned a value that is never used. | main.rs:382:9:382:9 | x | x | | main.rs:390:17:390:17 | x | Variable $@ is assigned a value that is never used. | main.rs:390:17:390:17 | x | x | -| main.rs:536:9:536:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:536:9:536:20 | var_in_macro | var_in_macro | -| main.rs:545:9:545:9 | c | Variable $@ is assigned a value that is never used. | main.rs:545:9:545:9 | c | c | +| main.rs:491:16:491:16 | a | Variable $@ is assigned a value that is never used. | main.rs:489:9:489:9 | a | a | +| main.rs:516:41:516:41 | x | Variable $@ is assigned a value that is never used. | main.rs:515:9:515:9 | x | x | +| main.rs:530:9:530:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:530:9:530:20 | var_in_macro | var_in_macro | +| main.rs:539:9:539:9 | c | Variable $@ is assigned a value that is never used. | main.rs:539:9:539:9 | c | c | | more.rs:44:9:44:14 | a_ptr4 | Variable $@ is assigned a value that is never used. | more.rs:44:9:44:14 | a_ptr4 | a_ptr4 | | more.rs:59:9:59:13 | d_ptr | Variable $@ is assigned a value that is never used. | more.rs:59:9:59:13 | d_ptr | d_ptr | | more.rs:65:13:65:17 | f_ptr | Variable $@ is assigned a value that is never used. | more.rs:65:13:65:17 | f_ptr | f_ptr | diff --git a/rust/ql/test/query-tests/unusedentities/main.rs b/rust/ql/test/query-tests/unusedentities/main.rs index 01b7cc14bc8c..a08a05a83bde 100644 --- a/rust/ql/test/query-tests/unusedentities/main.rs +++ b/rust/ql/test/query-tests/unusedentities/main.rs @@ -488,7 +488,7 @@ macro_rules! use_value { fn macros1() { let a: u16; let b: u16 = 2; - set_value!(a, 1); + set_value!(a, 1); // $ Alert[rust/unused-value] use_value!(b); match std::env::args().nth(1).unwrap().parse::() { @@ -513,13 +513,7 @@ fn macros2() { fn macros3() { let x; - println!( - "The value of x is {}", - ({ - x = 10; // $ MISSING: Alert[rust/unused-value] - 10 - }) - ); + println!("The value of x is {}", ({ x = 10; 10 })); // $ Alert[rust/unused-value] } macro_rules! let_in_macro { diff --git a/swift/ql/.generated.list b/swift/ql/.generated.list index 1d3e3da7e3ee..8d2fb9a2ebca 100644 --- a/swift/ql/.generated.list +++ b/swift/ql/.generated.list @@ -737,10 +737,10 @@ lib/codeql/swift/generated/KeyPathComponent.qll e11dcf952045b5e6062e24c23515cff9 lib/codeql/swift/generated/Locatable.qll 1d37fa20de71c0b9986bfd7a7c0cb82ab7bf3fda2d2008700f955ad82ce109a7 e97d4d4fb8a4800e0008cc00f60c8ed9b1ebd5f1140fd85e68b034616178d721 lib/codeql/swift/generated/Location.qll 5e20316c3e480ddfe632b7e88e016c19f10a67df1f6ae9c8f128755a6907d6f5 5a0af2d070bcb2ed53d6d0282bf9c60dc64c2dce89c21fdd485e9c7893c1c8fa lib/codeql/swift/generated/MacroRole.qll facf907e75490d69cd401c491215e4719324d751f40ea46c86ccf24cf3663c1f 969d8d4b44e3f1a9c193a152a4d83a303e56d2dbb871fc920c47a33f699cf018 -lib/codeql/swift/generated/ParentChild.qll 4d697f5372ad82380dc375a59fa0619ee56c7d88be58530147cd8e160262bbe3 e164b712a41f20d0b9986804cd753fb5e55ceb55139234d98bdb332a8f248db4 +lib/codeql/swift/generated/ParentChild.qll 7fdc133bdec6cc223d5ee85e757b02c5d2e1ab121bcf269bb48c8a12a31a61e9 d8dd6e21d290a293db4db510b1523a9ea428b12f48b7574f03acf00b9ca065ef lib/codeql/swift/generated/PureSynthConstructors.qll bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 -lib/codeql/swift/generated/Raw.qll f7dd5c3eb1afba1077dd6c291502e2b5dd5d18000ee581f7e3ad4f0050165c69 f042929df4651dfe587769cd3f539d07f97328c2fe17fbe19cbb8e4fbefe97f2 -lib/codeql/swift/generated/Synth.qll 6af0f5778c6c6a9d9a518c00707501c3fdb3ccaa96fa06793549c2b1f28c9cbb 575829e7a2a4c7619c6d98f1b7ec47d978d0b3d77d5c1a87eae5e9f98612ef5b +lib/codeql/swift/generated/Raw.qll 6adc2ec210e91051b6d3d6c84117b827f10dbea682a18b69348d1c6cdc53629c 9ff02fcca7a7b83c85303ffc6daa00ea392da6ce1f9cb389b5053b34d4a45e4c +lib/codeql/swift/generated/Synth.qll b0084d1f573ba1b10ec8a8fab169b15f15866ecb9a6aeeeac81553a442be28e3 09efe455f3fd6b8b983b30efbd797f09af46e6f5a1a1075801650528999ed938 lib/codeql/swift/generated/SynthConstructors.qll c40f01e1331bdbe238620a41d17409cefe34a6b23066708ef5d74f8631b54f48 c40f01e1331bdbe238620a41d17409cefe34a6b23066708ef5d74f8631b54f48 lib/codeql/swift/generated/UnknownFile.qll 247ddf2ebb49ce5ed4bf7bf91a969ddff37de6c78d43d8affccaf7eb586e06f2 452b29f0465ef45e978ef8b647b75e5a2a1e53f2a568fc003bc8f52f73b3fa4d lib/codeql/swift/generated/UnknownLocation.qll d871000b4f53ffca4f67ea23ca5626e5dcce125d62a4d4b9969e08cc974af6fc b05971d7774e60790362fb810fb7086314f40a2de747b8cb1bc823ec6494a4dd diff --git a/swift/ql/lib/codeql/swift/generated/ParentChild.qll b/swift/ql/lib/codeql/swift/generated/ParentChild.qll index 28b92e4902ae..efed12bb5fe0 100644 --- a/swift/ql/lib/codeql/swift/generated/ParentChild.qll +++ b/swift/ql/lib/codeql/swift/generated/ParentChild.qll @@ -45,7 +45,7 @@ private module Impl { ) { exists(int n, int nSpec | n = 0 and - nSpec = n + 1 + max(int i | i = -1 or exists(e.getSpec(i)) | i) and + nSpec = n + e.getNumberOfSpecs() and ( none() or @@ -66,7 +66,7 @@ private module Impl { ) { exists(int n, int nSubscriptArgument | n = 0 and - nSubscriptArgument = n + 1 + max(int i | i = -1 or exists(e.getSubscriptArgument(i)) | i) and + nSubscriptArgument = n + e.getNumberOfSubscriptArguments() and ( none() or @@ -100,7 +100,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -115,7 +115,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -130,8 +130,8 @@ private module Impl { ) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -149,7 +149,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -162,7 +162,7 @@ private module Impl { private Element getImmediateChildOfImportDecl(ImportDecl e, int index, string partialPredicateCall) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -177,7 +177,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -192,7 +192,7 @@ private module Impl { ) { exists(int n, int nMember, int nInit, int nPattern | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and nInit = nMember + 1 + max(int i | i = -1 or exists(e.getImmediateInit(i)) | i) and nPattern = nInit + 1 + max(int i | i = -1 or exists(e.getImmediatePattern(i)) | i) and ( @@ -215,7 +215,7 @@ private module Impl { ) { exists(int n, int nMember, int nMessage | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and nMessage = nMember + 1 and ( none() @@ -233,7 +233,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -248,7 +248,7 @@ private module Impl { ) { exists(int n, int nMember, int nBody | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and nBody = nMember + 1 and ( none() @@ -264,7 +264,7 @@ private module Impl { private Element getImmediateChildOfUsingDecl(UsingDecl e, int index, string partialPredicateCall) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -279,8 +279,8 @@ private module Impl { ) { exists(int n, int nMember, int nParam | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - nParam = nMember + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nMember = n + e.getNumberOfMembers() and + nParam = nMember + e.getNumberOfParams() and ( none() or @@ -298,7 +298,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -311,8 +311,8 @@ private module Impl { private Element getImmediateChildOfMacroDecl(MacroDecl e, int index, string partialPredicateCall) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -330,7 +330,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -345,7 +345,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -362,12 +362,12 @@ private module Impl { int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and nSelfParam = nMember + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -397,12 +397,12 @@ private module Impl { int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and nSelfParam = nMember + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -428,7 +428,7 @@ private module Impl { private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index, string partialPredicateCall) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -443,11 +443,10 @@ private module Impl { ) { exists(int n, int nMember, int nAccessor, int nGenericTypeParam, int nParam | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and - nGenericTypeParam = - nAccessor + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nParam = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and + nGenericTypeParam = nAccessor + e.getNumberOfGenericTypeParams() and + nParam = nGenericTypeParam + e.getNumberOfParams() and ( none() or @@ -471,12 +470,12 @@ private module Impl { int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and nSelfParam = nMember + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -504,7 +503,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -523,8 +522,8 @@ private module Impl { int nPropertyWrapperProjectionVar | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and nPropertyWrapperBackingVarBinding = nAccessor + 1 and nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and @@ -562,7 +561,7 @@ private module Impl { ) { exists(int n, int nMember | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMember = n + e.getNumberOfMembers() and ( none() or @@ -579,12 +578,12 @@ private module Impl { int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and nSelfParam = nMember + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -612,8 +611,8 @@ private module Impl { ) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -634,8 +633,8 @@ private module Impl { int nPropertyWrapperLocalWrappedVar | n = 0 and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and nPropertyWrapperBackingVarBinding = nAccessor + 1 and nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and @@ -683,8 +682,8 @@ private module Impl { ) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -700,8 +699,8 @@ private module Impl { private Element getImmediateChildOfClassDecl(ClassDecl e, int index, string partialPredicateCall) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -717,8 +716,8 @@ private module Impl { private Element getImmediateChildOfEnumDecl(EnumDecl e, int index, string partialPredicateCall) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -736,8 +735,8 @@ private module Impl { ) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -753,8 +752,8 @@ private module Impl { private Element getImmediateChildOfStructDecl(StructDecl e, int index, string partialPredicateCall) { exists(int n, int nGenericTypeParam, int nMember | n = 0 and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and ( none() or @@ -827,8 +826,8 @@ private module Impl { ) { exists(int n, int nBindingDecl, int nVariable, int nClosureBody | n = 0 and - nBindingDecl = n + 1 + max(int i | i = -1 or exists(e.getBindingDecl(i)) | i) and - nVariable = nBindingDecl + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and + nBindingDecl = n + e.getNumberOfBindingDecls() and + nVariable = nBindingDecl + e.getNumberOfVariables() and nClosureBody = nVariable + 1 and ( none() @@ -1040,7 +1039,7 @@ private module Impl { exists(int n, int nRoot, int nComponent | n = 0 and nRoot = n + 1 and - nComponent = nRoot + 1 + max(int i | i = -1 or exists(e.getComponent(i)) | i) and + nComponent = nRoot + e.getNumberOfComponents() and ( none() or @@ -1493,9 +1492,9 @@ private module Impl { exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and nSelfParam = n + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -1528,7 +1527,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -1584,7 +1583,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -1797,9 +1796,9 @@ private module Impl { exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | n = 0 and nSelfParam = n + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nParam = nSelfParam + e.getNumberOfParams() and nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and + nCapture = nBody + e.getNumberOfCaptures() and ( none() or @@ -2014,7 +2013,7 @@ private module Impl { ) { exists(int n, int nArgument | n = 0 and - nArgument = n + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = n + e.getNumberOfArguments() and ( none() or @@ -2070,7 +2069,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -2088,7 +2087,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -2140,7 +2139,7 @@ private module Impl { exists(int n, int nBase, int nArgument | n = 0 and nBase = n + 1 and - nArgument = nBase + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nBase + e.getNumberOfArguments() and ( none() or @@ -2286,7 +2285,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -2346,7 +2345,7 @@ private module Impl { exists(int n, int nFunction, int nArgument | n = 0 and nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + nArgument = nFunction + e.getNumberOfArguments() and ( none() or @@ -2578,7 +2577,7 @@ private module Impl { ) { exists(int n, int nElement | n = 0 and - nElement = n + 1 + max(int i | i = -1 or exists(e.getElement(i)) | i) and + nElement = n + e.getNumberOfElements() and ( none() or @@ -2591,7 +2590,7 @@ private module Impl { private Element getImmediateChildOfBraceStmt(BraceStmt e, int index, string partialPredicateCall) { exists(int n, int nVariable, int nElement | n = 0 and - nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and + nVariable = n + e.getNumberOfVariables() and nElement = nVariable + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() @@ -2612,8 +2611,8 @@ private module Impl { private Element getImmediateChildOfCaseStmt(CaseStmt e, int index, string partialPredicateCall) { exists(int n, int nLabel, int nVariable, int nBody | n = 0 and - nLabel = n + 1 + max(int i | i = -1 or exists(e.getLabel(i)) | i) and - nVariable = nLabel + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and + nLabel = n + e.getNumberOfLabels() and + nVariable = nLabel + e.getNumberOfVariables() and nBody = nVariable + 1 and ( none() @@ -2732,7 +2731,7 @@ private module Impl { exists(int n, int nBody, int nCatch | n = 0 and nBody = n + 1 and - nCatch = nBody + 1 + max(int i | i = -1 or exists(e.getCatch(i)) | i) and + nCatch = nBody + e.getNumberOfCatches() and ( none() or @@ -2763,7 +2762,7 @@ private module Impl { int n, int nVariable, int nPattern, int nWhere, int nIteratorVar, int nNextCall, int nBody | n = 0 and - nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and + nVariable = n + e.getNumberOfVariables() and nPattern = nVariable + 1 and nWhere = nPattern + 1 and nIteratorVar = nWhere + 1 and @@ -2813,7 +2812,7 @@ private module Impl { exists(int n, int nExpr, int nCase | n = 0 and nExpr = n + 1 and - nCase = nExpr + 1 + max(int i | i = -1 or exists(e.getCase(i)) | i) and + nCase = nExpr + e.getNumberOfCases() and ( none() or diff --git a/swift/ql/lib/codeql/swift/generated/Raw.qll b/swift/ql/lib/codeql/swift/generated/Raw.qll index 39bc6ac7373d..714579218bcb 100644 --- a/swift/ql/lib/codeql/swift/generated/Raw.qll +++ b/swift/ql/lib/codeql/swift/generated/Raw.qll @@ -87,6 +87,8 @@ module Raw { string getText() { comments(this, result) } } + private Element getImmediateChildOfComment(Comment e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -94,6 +96,8 @@ module Raw { override string toString() { result = "DbFile" } } + private Element getImmediateChildOfDbFile(DbFile e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -101,6 +105,8 @@ module Raw { override string toString() { result = "DbLocation" } } + private Element getImmediateChildOfDbLocation(DbLocation e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -118,6 +124,8 @@ module Raw { int getKind() { diagnostics(this, _, result) } } + private Element getImmediateChildOfDiagnostics(Diagnostics e, int index) { none() } + /** * INTERNAL: Do not use. * The superclass of all elements indicating some kind of error. @@ -152,6 +160,23 @@ module Raw { * Gets the `index`th spec of this availability info (0-based). */ AvailabilitySpec getSpec(int index) { availability_info_specs(this, index, result) } + + /** + * Gets the number of specs of this availability info. + */ + int getNumberOfSpecs() { result = count(int i | availability_info_specs(this, i, _)) } + } + + private Element getImmediateChildOfAvailabilityInfo(AvailabilityInfo e, int index) { + exists(int n, int nSpec | + n = 0 and + nSpec = n + e.getNumberOfSpecs() and + ( + none() + or + result = e.getSpec(index - n) + ) + ) } /** @@ -180,6 +205,8 @@ module Raw { predicate isWildcard() { availability_spec_is_wildcard(this) } } + private Element getImmediateChildOfAvailabilitySpec(AvailabilitySpec e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -201,6 +228,11 @@ module Raw { */ ParamDecl getParam(int index) { callable_params(this, index, result) } + /** + * Gets the number of parameters of this callable. + */ + int getNumberOfParams() { result = count(int i | callable_params(this, i, _)) } + /** * Gets the body of this callable, if it exists. * @@ -212,6 +244,11 @@ module Raw { * Gets the `index`th capture of this callable (0-based). */ CapturedDecl getCapture(int index) { callable_captures(this, index, result) } + + /** + * Gets the number of captures of this callable. + */ + int getNumberOfCaptures() { result = count(int i | callable_captures(this, i, _)) } } /** @@ -243,6 +280,13 @@ module Raw { key_path_component_subscript_arguments(this, index, result) } + /** + * Gets the number of arguments to an array or dictionary subscript expression. + */ + int getNumberOfSubscriptArguments() { + result = count(int i | key_path_component_subscript_arguments(this, i, _)) + } + /** * Gets the tuple index of this key path component, if it exists. */ @@ -263,6 +307,18 @@ module Raw { Type getComponentType() { key_path_components(this, _, result) } } + private Element getImmediateChildOfKeyPathComponent(KeyPathComponent e, int index) { + exists(int n, int nSubscriptArgument | + n = 0 and + nSubscriptArgument = n + e.getNumberOfSubscriptArguments() and + ( + none() + or + result = e.getSubscriptArgument(index - n) + ) + ) + } + /** * INTERNAL: Do not use. * The role of a macro, for example #freestanding(declaration) or @attached(member). @@ -285,12 +341,24 @@ module Raw { */ Expr getConformance(int index) { macro_role_conformances(this, index, result) } + /** + * Gets the number of conformances of this macro role. + */ + int getNumberOfConformances() { result = count(int i | macro_role_conformances(this, i, _)) } + /** * Gets the `index`th name of this macro role (0-based). */ string getName(int index) { macro_role_names(this, index, result) } + + /** + * Gets the number of names of this macro role. + */ + int getNumberOfNames() { result = count(int i | macro_role_names(this, i, _)) } } + private Element getImmediateChildOfMacroRole(MacroRole e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -323,6 +391,23 @@ module Raw { * These will be present only in certain downgraded databases. */ AstNode getChild(int index) { unspecified_element_children(this, index, result) } + + /** + * Gets the number of children of this unspecified element. + */ + int getNumberOfChildren() { result = count(int i | unspecified_element_children(this, i, _)) } + } + + private Element getImmediateChildOfUnspecifiedElement(UnspecifiedElement e, int index) { + exists(int n, int nChild | + n = 0 and + nChild = n + e.getNumberOfChildren() and + ( + none() + or + result = e.getChild(index - n) + ) + ) } /** @@ -342,6 +427,11 @@ module Raw { * align with expectations, and could change in future releases. */ Decl getMember(int index) { decl_members(this, index, result) } + + /** + * Gets the number of members of this declaration. + */ + int getNumberOfMembers() { result = count(int i | decl_members(this, i, _)) } } /** @@ -354,6 +444,13 @@ module Raw { GenericTypeParamDecl getGenericTypeParam(int index) { generic_context_generic_type_params(this, index, result) } + + /** + * Gets the number of generic type parameters of this generic context. + */ + int getNumberOfGenericTypeParams() { + result = count(int i | generic_context_generic_type_params(this, i, _)) + } } /** @@ -378,6 +475,18 @@ module Raw { predicate isEscaping() { captured_decl_is_escaping(this) } } + private Element getImmediateChildOfCapturedDecl(CapturedDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -388,6 +497,23 @@ module Raw { * Gets the `index`th element of this enum case declaration (0-based). */ EnumElementDecl getElement(int index) { enum_case_decl_elements(this, index, result) } + + /** + * Gets the number of elements of this enum case declaration. + */ + int getNumberOfElements() { result = count(int i | enum_case_decl_elements(this, i, _)) } + } + + private Element getImmediateChildOfEnumCaseDecl(EnumCaseDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) } /** @@ -405,6 +531,26 @@ module Raw { * Gets the `index`th protocol of this extension declaration (0-based). */ ProtocolDecl getProtocol(int index) { extension_decl_protocols(this, index, result) } + + /** + * Gets the number of protocols of this extension declaration. + */ + int getNumberOfProtocols() { result = count(int i | extension_decl_protocols(this, i, _)) } + } + + private Element getImmediateChildOfExtensionDecl(ExtensionDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) } /** @@ -417,6 +563,25 @@ module Raw { * Gets the `index`th active element of this if config declaration (0-based). */ AstNode getActiveElement(int index) { if_config_decl_active_elements(this, index, result) } + + /** + * Gets the number of active elements of this if config declaration. + */ + int getNumberOfActiveElements() { + result = count(int i | if_config_decl_active_elements(this, i, _)) + } + } + + private Element getImmediateChildOfIfConfigDecl(IfConfigDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) } /** @@ -439,6 +604,23 @@ module Raw { * Gets the `index`th declaration of this import declaration (0-based). */ ValueDecl getDeclaration(int index) { import_decl_declarations(this, index, result) } + + /** + * Gets the number of declarations of this import declaration. + */ + int getNumberOfDeclarations() { result = count(int i | import_decl_declarations(this, i, _)) } + } + + private Element getImmediateChildOfImportDecl(ImportDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) } /** @@ -454,6 +636,18 @@ module Raw { string getName() { missing_member_decls(this, result) } } + private Element getImmediateChildOfMissingMemberDecl(MissingMemberDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -475,10 +669,38 @@ module Raw { */ Expr getInit(int index) { pattern_binding_decl_inits(this, index, result) } + /** + * Gets the number of inits of this pattern binding declaration. + */ + int getNumberOfInits() { result = count(int i | pattern_binding_decl_inits(this, i, _)) } + /** * Gets the `index`th pattern of this pattern binding declaration (0-based). */ Pattern getPattern(int index) { pattern_binding_decl_patterns(this, index, result) } + + /** + * Gets the number of patterns of this pattern binding declaration. + */ + int getNumberOfPatterns() { result = count(int i | pattern_binding_decl_patterns(this, i, _)) } + } + + private Element getImmediateChildOfPatternBindingDecl(PatternBindingDecl e, int index) { + exists(int n, int nMember, int nInit, int nPattern | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nInit = nMember + e.getNumberOfInits() and + nPattern = nInit + e.getNumberOfPatterns() and + ( + none() + or + result = e.getMember(index - n) + or + result = e.getInit(index - nMember) + or + result = e.getPattern(index - nInit) + ) + ) } /** @@ -501,6 +723,21 @@ module Raw { StringLiteralExpr getMessage() { pound_diagnostic_decls(this, _, result) } } + private Element getImmediateChildOfPoundDiagnosticDecl(PoundDiagnosticDecl e, int index) { + exists(int n, int nMember, int nMessage | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nMessage = nMember + 1 and + ( + none() + or + result = e.getMember(index - n) + or + index = nMember and result = e.getMessage() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -508,6 +745,18 @@ module Raw { override string toString() { result = "PrecedenceGroupDecl" } } + private Element getImmediateChildOfPrecedenceGroupDecl(PrecedenceGroupDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -520,6 +769,21 @@ module Raw { BraceStmt getBody() { top_level_code_decls(this, result) } } + private Element getImmediateChildOfTopLevelCodeDecl(TopLevelCodeDecl e, int index) { + exists(int n, int nMember, int nBody | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nBody = nMember + 1 and + ( + none() + or + result = e.getMember(index - n) + or + index = nMember and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -537,6 +801,18 @@ module Raw { predicate isNonisolated() { using_decl_is_nonisolated(this) } } + private Element getImmediateChildOfUsingDecl(UsingDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -555,6 +831,13 @@ module Raw { * Gets the `index`th accessor of this abstract storage declaration (0-based). */ Accessor getAccessor(int index) { abstract_storage_decl_accessors(this, index, result) } + + /** + * Gets the number of accessors of this abstract storage declaration. + */ + int getNumberOfAccessors() { + result = count(int i | abstract_storage_decl_accessors(this, i, _)) + } } /** @@ -572,6 +855,26 @@ module Raw { * Gets the `index`th parameter of this enum element declaration (0-based). */ ParamDecl getParam(int index) { enum_element_decl_params(this, index, result) } + + /** + * Gets the number of parameters of this enum element declaration. + */ + int getNumberOfParams() { result = count(int i | enum_element_decl_params(this, i, _)) } + } + + private Element getImmediateChildOfEnumElementDecl(EnumElementDecl e, int index) { + exists(int n, int nMember, int nParam | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nParam = nMember + e.getNumberOfParams() and + ( + none() + or + result = e.getMember(index - n) + or + result = e.getParam(index - nMember) + ) + ) } /** @@ -591,6 +894,18 @@ module Raw { PrecedenceGroupDecl getPrecedenceGroup() { infix_operator_decl_precedence_groups(this, result) } } + private Element getImmediateChildOfInfixOperatorDecl(InfixOperatorDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. * A declaration of a macro. Some examples: @@ -617,10 +932,35 @@ module Raw { */ ParamDecl getParameter(int index) { macro_decl_parameters(this, index, result) } + /** + * Gets the number of parameters of this macro. + */ + int getNumberOfParameters() { result = count(int i | macro_decl_parameters(this, i, _)) } + /** * Gets the `index`th role of this macro (0-based). */ MacroRole getRole(int index) { macro_decl_roles(this, index, result) } + + /** + * Gets the number of roles of this macro. + */ + int getNumberOfRoles() { result = count(int i | macro_decl_roles(this, i, _)) } + } + + private Element getImmediateChildOfMacroDecl(MacroDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) } /** @@ -630,6 +970,18 @@ module Raw { override string toString() { result = "PostfixOperatorDecl" } } + private Element getImmediateChildOfPostfixOperatorDecl(PostfixOperatorDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -637,6 +989,18 @@ module Raw { override string toString() { result = "PrefixOperatorDecl" } } + private Element getImmediateChildOfPrefixOperatorDecl(PrefixOperatorDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -653,6 +1017,13 @@ module Raw { * will not resolve `TypeAliasDecl`s or consider base types added by extensions. */ Type getInheritedType(int index) { type_decl_inherited_types(this, index, result) } + + /** + * Gets the number of inherited types of this type declaration. + */ + int getNumberOfInheritedTypes() { + result = count(int i | type_decl_inherited_types(this, i, _)) + } } /** @@ -672,6 +1043,35 @@ module Raw { override string toString() { result = "Deinitializer" } } + private Element getImmediateChildOfDeinitializer(Deinitializer e, int index) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + nSelfParam = nMember + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + or + index = nMember and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -684,6 +1084,35 @@ module Raw { override string toString() { result = "Initializer" } } + private Element getImmediateChildOfInitializer(Initializer e, int index) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + nSelfParam = nMember + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + or + index = nMember and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -713,6 +1142,18 @@ module Raw { ModuleDecl getAnExportedModule() { module_decl_exported_modules(this, result) } } + private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -724,12 +1165,38 @@ module Raw { */ ParamDecl getParam(int index) { subscript_decl_params(this, index, result) } + /** + * Gets the number of parameters of this subscript declaration. + */ + int getNumberOfParams() { result = count(int i | subscript_decl_params(this, i, _)) } + /** * Gets the element type of this subscript declaration. */ Type getElementType() { subscript_decls(this, result) } } + private Element getImmediateChildOfSubscriptDecl(SubscriptDecl e, int index) { + exists(int n, int nMember, int nAccessor, int nGenericTypeParam, int nParam | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and + nGenericTypeParam = nAccessor + e.getNumberOfGenericTypeParams() and + nParam = nGenericTypeParam + e.getNumberOfParams() and + ( + none() + or + result = e.getMember(index - n) + or + result = e.getAccessor(index - nMember) + or + result = e.getGenericTypeParam(index - nAccessor) + or + result = e.getParam(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. * A declaration of a variable such as @@ -913,6 +1380,35 @@ module Raw { predicate isInit() { accessor_is_init(this) } } + private Element getImmediateChildOfAccessor(Accessor e, int index) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + nSelfParam = nMember + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + or + index = nMember and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -920,6 +1416,18 @@ module Raw { override string toString() { result = "AssociatedTypeDecl" } } + private Element getImmediateChildOfAssociatedTypeDecl(AssociatedTypeDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -934,6 +1442,38 @@ module Raw { int getIntroducerInt() { concrete_var_decls(this, result) } } + private Element getImmediateChildOfConcreteVarDecl(ConcreteVarDecl e, int index) { + exists( + int n, int nMember, int nAccessor, int nPropertyWrapperBackingVarBinding, + int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, + int nPropertyWrapperProjectionVar + | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and + nPropertyWrapperBackingVarBinding = nAccessor + 1 and + nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and + nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and + nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 and + ( + none() + or + result = e.getMember(index - n) + or + result = e.getAccessor(index - nMember) + or + index = nAccessor and result = e.getPropertyWrapperBackingVarBinding() + or + index = nPropertyWrapperBackingVarBinding and result = e.getPropertyWrapperBackingVar() + or + index = nPropertyWrapperBackingVar and result = e.getPropertyWrapperProjectionVarBinding() + or + index = nPropertyWrapperProjectionVarBinding and + result = e.getPropertyWrapperProjectionVar() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -941,6 +1481,18 @@ module Raw { override string toString() { result = "GenericTypeParamDecl" } } + private Element getImmediateChildOfGenericTypeParamDecl(GenericTypeParamDecl e, int index) { + exists(int n, int nMember | + n = 0 and + nMember = n + e.getNumberOfMembers() and + ( + none() + or + result = e.getMember(index - n) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -948,6 +1500,35 @@ module Raw { override string toString() { result = "NamedFunction" } } + private Element getImmediateChildOfNamedFunction(NamedFunction e, int index) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + nSelfParam = nMember + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + or + index = nMember and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -984,6 +1565,28 @@ module Raw { GenericTypeParamType getOpaqueGenericParam(int index) { opaque_type_decl_opaque_generic_params(this, index, result) } + + /** + * Gets the number of opaque generic parameters of this opaque type declaration. + */ + int getNumberOfOpaqueGenericParams() { + result = count(int i | opaque_type_decl_opaque_generic_params(this, i, _)) + } + } + + private Element getImmediateChildOfOpaqueTypeDecl(OpaqueTypeDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) } /** @@ -1018,6 +1621,47 @@ module Raw { } } + private Element getImmediateChildOfParamDecl(ParamDecl e, int index) { + exists( + int n, int nMember, int nAccessor, int nPropertyWrapperBackingVarBinding, + int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, + int nPropertyWrapperProjectionVar, int nPropertyWrapperLocalWrappedVarBinding, + int nPropertyWrapperLocalWrappedVar + | + n = 0 and + nMember = n + e.getNumberOfMembers() and + nAccessor = nMember + e.getNumberOfAccessors() and + nPropertyWrapperBackingVarBinding = nAccessor + 1 and + nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and + nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and + nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 and + nPropertyWrapperLocalWrappedVarBinding = nPropertyWrapperProjectionVar + 1 and + nPropertyWrapperLocalWrappedVar = nPropertyWrapperLocalWrappedVarBinding + 1 and + ( + none() + or + result = e.getMember(index - n) + or + result = e.getAccessor(index - nMember) + or + index = nAccessor and result = e.getPropertyWrapperBackingVarBinding() + or + index = nPropertyWrapperBackingVarBinding and result = e.getPropertyWrapperBackingVar() + or + index = nPropertyWrapperBackingVar and result = e.getPropertyWrapperProjectionVarBinding() + or + index = nPropertyWrapperProjectionVarBinding and + result = e.getPropertyWrapperProjectionVar() + or + index = nPropertyWrapperProjectionVar and + result = e.getPropertyWrapperLocalWrappedVarBinding() + or + index = nPropertyWrapperLocalWrappedVarBinding and + result = e.getPropertyWrapperLocalWrappedVar() + ) + ) + } + /** * INTERNAL: Do not use. * A declaration of a type alias to another type. For example: @@ -1039,6 +1683,21 @@ module Raw { Type getAliasedType() { type_alias_decls(this, result) } } + private Element getImmediateChildOfTypeAliasDecl(TypeAliasDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1046,6 +1705,21 @@ module Raw { override string toString() { result = "ClassDecl" } } + private Element getImmediateChildOfClassDecl(ClassDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1053,6 +1727,21 @@ module Raw { override string toString() { result = "EnumDecl" } } + private Element getImmediateChildOfEnumDecl(EnumDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1060,6 +1749,21 @@ module Raw { override string toString() { result = "ProtocolDecl" } } + private Element getImmediateChildOfProtocolDecl(ProtocolDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1067,6 +1771,21 @@ module Raw { override string toString() { result = "StructDecl" } } + private Element getImmediateChildOfStructDecl(StructDecl e, int index) { + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + e.getNumberOfGenericTypeParams() and + nMember = nGenericTypeParam + e.getNumberOfMembers() and + ( + none() + or + result = e.getGenericTypeParam(index - n) + or + result = e.getMember(index - nGenericTypeParam) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1084,6 +1803,18 @@ module Raw { Expr getExpr() { arguments(this, _, result) } } + private Element getImmediateChildOfArgument(Argument e, int index) { + exists(int n, int nExpr | + n = 0 and + nExpr = n + 1 and + ( + none() + or + index = n and result = e.getExpr() + ) + ) + } + /** * INTERNAL: Do not use. * The base class for all expressions in Swift. @@ -1132,6 +1863,20 @@ module Raw { ParamDecl getParam() { applied_property_wrapper_exprs(this, _, _, result) } } + private Element getImmediateChildOfAppliedPropertyWrapperExpr( + AppliedPropertyWrapperExpr e, int index + ) { + exists(int n, int nValue | + n = 0 and + nValue = n + 1 and + ( + none() + or + index = n and result = e.getValue() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1145,6 +1890,11 @@ module Raw { * Gets the `index`th argument passed to the applied function (0-based). */ Argument getArgument(int index) { apply_expr_arguments(this, index, result) } + + /** + * Gets the number of arguments passed to the applied function. + */ + int getNumberOfArguments() { result = count(int i | apply_expr_arguments(this, i, _)) } } /** @@ -1164,6 +1914,21 @@ module Raw { Expr getSource() { assign_exprs(this, _, result) } } + private Element getImmediateChildOfAssignExpr(AssignExpr e, int index) { + exists(int n, int nDest, int nSource | + n = 0 and + nDest = n + 1 and + nSource = nDest + 1 and + ( + none() + or + index = n and result = e.getDest() + or + index = nDest and result = e.getSource() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1176,6 +1941,18 @@ module Raw { Expr getSubExpr() { bind_optional_exprs(this, result) } } + private Element getImmediateChildOfBindOptionalExpr(BindOptionalExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1189,12 +1966,35 @@ module Raw { capture_list_expr_binding_decls(this, index, result) } + /** + * Gets the number of binding declarations of this capture list expression. + */ + int getNumberOfBindingDecls() { + result = count(int i | capture_list_expr_binding_decls(this, i, _)) + } + /** * Gets the closure body of this capture list expression. */ ClosureExpr getClosureBody() { capture_list_exprs(this, result) } } + private Element getImmediateChildOfCaptureListExpr(CaptureListExpr e, int index) { + exists(int n, int nBindingDecl, int nVariable, int nClosureBody | + n = 0 and + nBindingDecl = n + e.getNumberOfBindingDecls() and + nVariable = nBindingDecl and + nClosureBody = nVariable + 1 and + ( + none() + or + result = e.getBindingDecl(index - n) + or + index = nVariable and result = e.getClosureBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1223,6 +2023,18 @@ module Raw { Expr getSubExpr() { consume_exprs(this, result) } } + private Element getImmediateChildOfConsumeExpr(ConsumeExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * An expression that forces value to be copied. In the example below, `copy` marks the copy expression: @@ -1241,6 +2053,18 @@ module Raw { Expr getSubExpr() { copy_exprs(this, result) } } + private Element getImmediateChildOfCopyExpr(CopyExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * An expression that extracts the actor isolation of the current context, of type `(any Actor)?`. @@ -1256,6 +2080,12 @@ module Raw { Expr getActor() { current_context_isolation_exprs(this, result) } } + private Element getImmediateChildOfCurrentContextIsolationExpr( + CurrentContextIsolationExpr e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -1272,6 +2102,13 @@ module Raw { */ Type getReplacementType(int index) { decl_ref_expr_replacement_types(this, index, result) } + /** + * Gets the number of replacement types of this declaration reference expression. + */ + int getNumberOfReplacementTypes() { + result = count(int i | decl_ref_expr_replacement_types(this, i, _)) + } + /** * Holds if this declaration reference expression has direct to storage semantics. */ @@ -1295,6 +2132,8 @@ module Raw { predicate hasDistributedThunkSemantics() { decl_ref_expr_has_distributed_thunk_semantics(this) } } + private Element getImmediateChildOfDeclRefExpr(DeclRefExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -1317,6 +2156,10 @@ module Raw { Expr getCallerSideDefault() { default_argument_expr_caller_side_defaults(this, result) } } + private Element getImmediateChildOfDefaultArgumentExpr(DefaultArgumentExpr e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -1324,6 +2167,10 @@ module Raw { override string toString() { result = "DiscardAssignmentExpr" } } + private Element getImmediateChildOfDiscardAssignmentExpr(DiscardAssignmentExpr e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -1341,6 +2188,21 @@ module Raw { Expr getSubExpr() { dot_syntax_base_ignored_exprs(this, _, result) } } + private Element getImmediateChildOfDotSyntaxBaseIgnoredExpr(DotSyntaxBaseIgnoredExpr e, int index) { + exists(int n, int nQualifier, int nSubExpr | + n = 0 and + nQualifier = n + 1 and + nSubExpr = nQualifier + 1 and + ( + none() + or + index = n and result = e.getQualifier() + or + index = nQualifier and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1353,6 +2215,18 @@ module Raw { Expr getBase() { dynamic_type_exprs(this, result) } } + private Element getImmediateChildOfDynamicTypeExpr(DynamicTypeExpr e, int index) { + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and + ( + none() + or + index = n and result = e.getBase() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1370,6 +2244,18 @@ module Raw { EnumElementDecl getElement() { enum_is_case_exprs(this, _, result) } } + private Element getImmediateChildOfEnumIsCaseExpr(EnumIsCaseExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1377,6 +2263,8 @@ module Raw { override string toString() { result = "ErrorExpr" } } + private Element getImmediateChildOfErrorExpr(ErrorExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -1408,6 +2296,20 @@ module Raw { Expr getFunctionExpr() { extract_function_isolation_exprs(this, result) } } + private Element getImmediateChildOfExtractFunctionIsolationExpr( + ExtractFunctionIsolationExpr e, int index + ) { + exists(int n, int nFunctionExpr | + n = 0 and + nFunctionExpr = n + 1 and + ( + none() + or + index = n and result = e.getFunctionExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1420,6 +2322,18 @@ module Raw { Expr getSubExpr() { force_value_exprs(this, result) } } + private Element getImmediateChildOfForceValueExpr(ForceValueExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1452,6 +2366,24 @@ module Raw { Expr getElseExpr() { if_exprs(this, _, _, result) } } + private Element getImmediateChildOfIfExpr(IfExpr e, int index) { + exists(int n, int nCondition, int nThenExpr, int nElseExpr | + n = 0 and + nCondition = n + 1 and + nThenExpr = nCondition + 1 and + nElseExpr = nThenExpr + 1 and + ( + none() + or + index = n and result = e.getCondition() + or + index = nCondition and result = e.getThenExpr() + or + index = nThenExpr and result = e.getElseExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1474,6 +2406,18 @@ module Raw { Expr getSubExpr() { in_out_exprs(this, result) } } + private Element getImmediateChildOfInOutExpr(InOutExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1491,6 +2435,21 @@ module Raw { Expr getKeyPath() { key_path_application_exprs(this, _, result) } } + private Element getImmediateChildOfKeyPathApplicationExpr(KeyPathApplicationExpr e, int index) { + exists(int n, int nBase, int nKeyPath | + n = 0 and + nBase = n + 1 and + nKeyPath = nBase + 1 and + ( + none() + or + index = n and result = e.getBase() + or + index = nBase and result = e.getKeyPath() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1498,6 +2457,8 @@ module Raw { override string toString() { result = "KeyPathDotExpr" } } + private Element getImmediateChildOfKeyPathDotExpr(KeyPathDotExpr e, int index) { none() } + /** * INTERNAL: Do not use. * A key-path expression. @@ -1514,6 +2475,26 @@ module Raw { * Gets the `index`th component of this key path expression (0-based). */ KeyPathComponent getComponent(int index) { key_path_expr_components(this, index, result) } + + /** + * Gets the number of components of this key path expression. + */ + int getNumberOfComponents() { result = count(int i | key_path_expr_components(this, i, _)) } + } + + private Element getImmediateChildOfKeyPathExpr(KeyPathExpr e, int index) { + exists(int n, int nRoot, int nComponent | + n = 0 and + nRoot = n + 1 and + nComponent = nRoot + e.getNumberOfComponents() and + ( + none() + or + index = n and result = e.getRoot() + or + result = e.getComponent(index - nRoot) + ) + ) } /** @@ -1528,6 +2509,18 @@ module Raw { Expr getSubExpr() { lazy_initialization_exprs(this, result) } } + private Element getImmediateChildOfLazyInitializationExpr(LazyInitializationExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1570,6 +2563,26 @@ module Raw { Expr getSubExpr() { make_temporarily_escapable_exprs(this, _, _, result) } } + private Element getImmediateChildOfMakeTemporarilyEscapableExpr( + MakeTemporarilyEscapableExpr e, int index + ) { + exists(int n, int nEscapingClosure, int nNonescapingClosure, int nSubExpr | + n = 0 and + nEscapingClosure = n + 1 and + nNonescapingClosure = nEscapingClosure + 1 and + nSubExpr = nNonescapingClosure + 1 and + ( + none() + or + index = n and result = e.getEscapingClosure() + or + index = nEscapingClosure and result = e.getNonescapingClosure() + or + index = nNonescapingClosure and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * An expression that materializes a pack during expansion. Appears around PackExpansionExpr. @@ -1586,6 +2599,18 @@ module Raw { Expr getSubExpr() { materialize_pack_exprs(this, result) } } + private Element getImmediateChildOfMaterializePackExpr(MaterializePackExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1603,6 +2628,18 @@ module Raw { Function getMethod() { obj_c_selector_exprs(this, _, result) } } + private Element getImmediateChildOfObjCSelectorExpr(ObjCSelectorExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1615,6 +2652,18 @@ module Raw { Expr getSubExpr() { one_way_exprs(this, result) } } + private Element getImmediateChildOfOneWayExpr(OneWayExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1622,6 +2671,8 @@ module Raw { override string toString() { result = "OpaqueValueExpr" } } + private Element getImmediateChildOfOpaqueValueExpr(OpaqueValueExpr e, int index) { none() } + /** * INTERNAL: Do not use. * An implicit expression created by the compiler when a method is called on a protocol. For example in @@ -1657,6 +2708,21 @@ module Raw { OpaqueValueExpr getOpaqueExpr() { open_existential_exprs(this, _, _, result) } } + private Element getImmediateChildOfOpenExistentialExpr(OpenExistentialExpr e, int index) { + exists(int n, int nSubExpr, int nExistential | + n = 0 and + nSubExpr = n + 1 and + nExistential = nSubExpr + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + or + index = nSubExpr and result = e.getExistential() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1669,6 +2735,18 @@ module Raw { Expr getSubExpr() { optional_evaluation_exprs(this, result) } } + private Element getImmediateChildOfOptionalEvaluationExpr(OptionalEvaluationExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1681,6 +2759,10 @@ module Raw { Initializer getInitializer() { other_initializer_ref_exprs(this, result) } } + private Element getImmediateChildOfOtherInitializerRefExpr(OtherInitializerRefExpr e, int index) { + none() + } + /** * INTERNAL: Do not use. * An ambiguous expression that might refer to multiple declarations. This will be present only @@ -1695,6 +2777,17 @@ module Raw { ValueDecl getPossibleDeclaration(int index) { overloaded_decl_ref_expr_possible_declarations(this, index, result) } + + /** + * Gets the number of possible declarations of this overloaded declaration reference expression. + */ + int getNumberOfPossibleDeclarations() { + result = count(int i | overloaded_decl_ref_expr_possible_declarations(this, i, _)) + } + } + + private Element getImmediateChildOfOverloadedDeclRefExpr(OverloadedDeclRefExpr e, int index) { + none() } /** @@ -1720,6 +2813,18 @@ module Raw { Expr getSubExpr() { pack_element_exprs(this, result) } } + private Element getImmediateChildOfPackElementExpr(PackElementExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A pack expansion expression. @@ -1743,6 +2848,18 @@ module Raw { Expr getPatternExpr() { pack_expansion_exprs(this, result) } } + private Element getImmediateChildOfPackExpansionExpr(PackExpansionExpr e, int index) { + exists(int n, int nPatternExpr | + n = 0 and + nPatternExpr = n + 1 and + ( + none() + or + index = n and result = e.getPatternExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A placeholder substituting property initializations with `=` when the property has a property @@ -1762,6 +2879,12 @@ module Raw { OpaqueValueExpr getPlaceholder() { property_wrapper_value_placeholder_exprs(this, result) } } + private Element getImmediateChildOfPropertyWrapperValuePlaceholderExpr( + PropertyWrapperValuePlaceholderExpr e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -1779,6 +2902,20 @@ module Raw { VarDecl getSelf() { rebind_self_in_initializer_exprs(this, _, result) } } + private Element getImmediateChildOfRebindSelfInInitializerExpr( + RebindSelfInInitializerExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1789,6 +2926,23 @@ module Raw { * Gets the `index`th element of this sequence expression (0-based). */ Expr getElement(int index) { sequence_expr_elements(this, index, result) } + + /** + * Gets the number of elements of this sequence expression. + */ + int getNumberOfElements() { result = count(int i | sequence_expr_elements(this, i, _)) } + } + + private Element getImmediateChildOfSequenceExpr(SequenceExpr e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -1804,6 +2958,18 @@ module Raw { Stmt getStmt() { single_value_stmt_exprs(this, result) } } + private Element getImmediateChildOfSingleValueStmtExpr(SingleValueStmtExpr e, int index) { + exists(int n, int nStmt | + n = 0 and + nStmt = n + 1 and + ( + none() + or + index = n and result = e.getStmt() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1816,6 +2982,8 @@ module Raw { VarDecl getSelf() { super_ref_exprs(this, result) } } + private Element getImmediateChildOfSuperRefExpr(SuperRefExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -1838,6 +3006,21 @@ module Raw { VarDecl getVar() { tap_exprs(this, _, result) } } + private Element getImmediateChildOfTapExpr(TapExpr e, int index) { + exists(int n, int nSubExpr, int nBody | + n = 0 and + nSubExpr = n + 1 and + nBody = nSubExpr + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + or + index = nSubExpr and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1855,6 +3038,18 @@ module Raw { int getIndex() { tuple_element_exprs(this, _, result) } } + private Element getImmediateChildOfTupleElementExpr(TupleElementExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1865,6 +3060,23 @@ module Raw { * Gets the `index`th element of this tuple expression (0-based). */ Expr getElement(int index) { tuple_expr_elements(this, index, result) } + + /** + * Gets the number of elements of this tuple expression. + */ + int getNumberOfElements() { result = count(int i | tuple_expr_elements(this, i, _)) } + } + + private Element getImmediateChildOfTupleExpr(TupleExpr e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -1879,6 +3091,18 @@ module Raw { TypeRepr getTypeRepr() { type_expr_type_reprs(this, result) } } + private Element getImmediateChildOfTypeExpr(TypeExpr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1891,6 +3115,18 @@ module Raw { TypeRepr getTypeRepr() { type_value_exprs(this, result) } } + private Element getImmediateChildOfTypeValueExpr(TypeValueExpr e, int index) { + exists(int n, int nTypeRepr | + n = 0 and + nTypeRepr = n + 1 and + ( + none() + or + index = n and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1903,7 +3139,11 @@ module Raw { string getName() { unresolved_decl_ref_expr_names(this, result) } } - /** + private Element getImmediateChildOfUnresolvedDeclRefExpr(UnresolvedDeclRefExpr e, int index) { + none() + } + + /** * INTERNAL: Do not use. */ class UnresolvedDotExpr extends @unresolved_dot_expr, Expr, ErrorElement { @@ -1920,6 +3160,18 @@ module Raw { string getName() { unresolved_dot_exprs(this, _, result) } } + private Element getImmediateChildOfUnresolvedDotExpr(UnresolvedDotExpr e, int index) { + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and + ( + none() + or + index = n and result = e.getBase() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1932,6 +3184,10 @@ module Raw { string getName() { unresolved_member_exprs(this, result) } } + private Element getImmediateChildOfUnresolvedMemberExpr(UnresolvedMemberExpr e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -1944,6 +3200,18 @@ module Raw { Pattern getSubPattern() { unresolved_pattern_exprs(this, result) } } + private Element getImmediateChildOfUnresolvedPatternExpr(UnresolvedPatternExpr e, int index) { + exists(int n, int nSubPattern | + n = 0 and + nSubPattern = n + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1956,6 +3224,18 @@ module Raw { Expr getSubExpr() { unresolved_specialize_exprs(this, result) } } + private Element getImmediateChildOfUnresolvedSpecializeExpr(UnresolvedSpecializeExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1968,6 +3248,18 @@ module Raw { Expr getSubExpr() { vararg_expansion_exprs(this, result) } } + private Element getImmediateChildOfVarargExpansionExpr(VarargExpansionExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1975,6 +3267,18 @@ module Raw { override string toString() { result = "AbiSafeConversionExpr" } } + private Element getImmediateChildOfAbiSafeConversionExpr(AbiSafeConversionExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A conversion that erases the actor isolation of an expression with `@isolated(any)` function @@ -1984,6 +3288,20 @@ module Raw { override string toString() { result = "ActorIsolationErasureExpr" } } + private Element getImmediateChildOfActorIsolationErasureExpr( + ActorIsolationErasureExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1991,6 +3309,18 @@ module Raw { override string toString() { result = "AnyHashableErasureExpr" } } + private Element getImmediateChildOfAnyHashableErasureExpr(AnyHashableErasureExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -1998,6 +3328,18 @@ module Raw { override string toString() { result = "ArchetypeToSuperExpr" } } + private Element getImmediateChildOfArchetypeToSuperExpr(ArchetypeToSuperExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2008,6 +3350,23 @@ module Raw { * Gets the `index`th element of this array expression (0-based). */ Expr getElement(int index) { array_expr_elements(this, index, result) } + + /** + * Gets the number of elements of this array expression. + */ + int getNumberOfElements() { result = count(int i | array_expr_elements(this, i, _)) } + } + + private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -2017,6 +3376,18 @@ module Raw { override string toString() { result = "ArrayToPointerExpr" } } + private Element getImmediateChildOfArrayToPointerExpr(ArrayToPointerExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2024,6 +3395,27 @@ module Raw { override string toString() { result = "AutoClosureExpr" } } + private Element getImmediateChildOfAutoClosureExpr(AutoClosureExpr e, int index) { + exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | + n = 0 and + nSelfParam = n + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + index = n and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2031,6 +3423,18 @@ module Raw { override string toString() { result = "AwaitExpr" } } + private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2038,6 +3442,21 @@ module Raw { override string toString() { result = "BinaryExpr" } } + private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. * An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression: @@ -2051,6 +3470,18 @@ module Raw { override string toString() { result = "BorrowExpr" } } + private Element getImmediateChildOfBorrowExpr(BorrowExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2058,6 +3489,18 @@ module Raw { override string toString() { result = "BridgeFromObjCExpr" } } + private Element getImmediateChildOfBridgeFromObjCExpr(BridgeFromObjCExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2065,6 +3508,18 @@ module Raw { override string toString() { result = "BridgeToObjCExpr" } } + private Element getImmediateChildOfBridgeToObjCExpr(BridgeToObjCExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2077,6 +3532,21 @@ module Raw { override string toString() { result = "CallExpr" } } + private Element getImmediateChildOfCallExpr(CallExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2089,6 +3559,20 @@ module Raw { override string toString() { result = "ClassMetatypeToObjectExpr" } } + private Element getImmediateChildOfClassMetatypeToObjectExpr( + ClassMetatypeToObjectExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2096,6 +3580,18 @@ module Raw { override string toString() { result = "CoerceExpr" } } + private Element getImmediateChildOfCoerceExpr(CoerceExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2105,6 +3601,20 @@ module Raw { override string toString() { result = "CollectionUpcastConversionExpr" } } + private Element getImmediateChildOfCollectionUpcastConversionExpr( + CollectionUpcastConversionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2114,6 +3624,20 @@ module Raw { override string toString() { result = "ConditionalBridgeFromObjCExpr" } } + private Element getImmediateChildOfConditionalBridgeFromObjCExpr( + ConditionalBridgeFromObjCExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2123,6 +3647,20 @@ module Raw { override string toString() { result = "CovariantFunctionConversionExpr" } } + private Element getImmediateChildOfCovariantFunctionConversionExpr( + CovariantFunctionConversionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2132,6 +3670,20 @@ module Raw { override string toString() { result = "CovariantReturnConversionExpr" } } + private Element getImmediateChildOfCovariantReturnConversionExpr( + CovariantReturnConversionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2139,6 +3691,18 @@ module Raw { override string toString() { result = "DerivedToBaseExpr" } } + private Element getImmediateChildOfDerivedToBaseExpr(DerivedToBaseExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2146,6 +3710,18 @@ module Raw { override string toString() { result = "DestructureTupleExpr" } } + private Element getImmediateChildOfDestructureTupleExpr(DestructureTupleExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2156,6 +3732,23 @@ module Raw { * Gets the `index`th element of this dictionary expression (0-based). */ Expr getElement(int index) { dictionary_expr_elements(this, index, result) } + + /** + * Gets the number of elements of this dictionary expression. + */ + int getNumberOfElements() { result = count(int i | dictionary_expr_elements(this, i, _)) } + } + + private Element getImmediateChildOfDictionaryExpr(DictionaryExpr e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -2165,6 +3758,20 @@ module Raw { override string toString() { result = "DifferentiableFunctionExpr" } } + private Element getImmediateChildOfDifferentiableFunctionExpr( + DifferentiableFunctionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2174,6 +3781,20 @@ module Raw { override string toString() { result = "DifferentiableFunctionExtractOriginalExpr" } } + private Element getImmediateChildOfDifferentiableFunctionExtractOriginalExpr( + DifferentiableFunctionExtractOriginalExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2181,6 +3802,18 @@ module Raw { override string toString() { result = "DotSelfExpr" } } + private Element getImmediateChildOfDotSelfExpr(DotSelfExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2193,6 +3826,18 @@ module Raw { override string toString() { result = "ErasureExpr" } } + private Element getImmediateChildOfErasureExpr(ErasureExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2202,6 +3847,20 @@ module Raw { override string toString() { result = "ExistentialMetatypeToObjectExpr" } } + private Element getImmediateChildOfExistentialMetatypeToObjectExpr( + ExistentialMetatypeToObjectExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2209,6 +3868,27 @@ module Raw { override string toString() { result = "ExplicitClosureExpr" } } + private Element getImmediateChildOfExplicitClosureExpr(ExplicitClosureExpr e, int index) { + exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | + n = 0 and + nSelfParam = n + 1 and + nParam = nSelfParam + e.getNumberOfParams() and + nBody = nParam + 1 and + nCapture = nBody + e.getNumberOfCaptures() and + ( + none() + or + index = n and result = e.getSelfParam() + or + result = e.getParam(index - nSelfParam) + or + index = nParam and result = e.getBody() + or + result = e.getCapture(index - nBody) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2216,6 +3896,18 @@ module Raw { override string toString() { result = "ForceTryExpr" } } + private Element getImmediateChildOfForceTryExpr(ForceTryExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2223,6 +3915,20 @@ module Raw { override string toString() { result = "ForeignObjectConversionExpr" } } + private Element getImmediateChildOfForeignObjectConversionExpr( + ForeignObjectConversionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2230,6 +3936,18 @@ module Raw { override string toString() { result = "FunctionConversionExpr" } } + private Element getImmediateChildOfFunctionConversionExpr(FunctionConversionExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2237,6 +3955,18 @@ module Raw { override string toString() { result = "InOutToPointerExpr" } } + private Element getImmediateChildOfInOutToPointerExpr(InOutToPointerExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2244,6 +3974,18 @@ module Raw { override string toString() { result = "InjectIntoOptionalExpr" } } + private Element getImmediateChildOfInjectIntoOptionalExpr(InjectIntoOptionalExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2263,6 +4005,20 @@ module Raw { TapExpr getAppendingExpr() { interpolated_string_literal_expr_appending_exprs(this, result) } } + private Element getImmediateChildOfInterpolatedStringLiteralExpr( + InterpolatedStringLiteralExpr e, int index + ) { + exists(int n, int nAppendingExpr | + n = 0 and + nAppendingExpr = n + 1 and + ( + none() + or + index = n and result = e.getAppendingExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2270,6 +4026,18 @@ module Raw { override string toString() { result = "LinearFunctionExpr" } } + private Element getImmediateChildOfLinearFunctionExpr(LinearFunctionExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2279,6 +4047,20 @@ module Raw { override string toString() { result = "LinearFunctionExtractOriginalExpr" } } + private Element getImmediateChildOfLinearFunctionExtractOriginalExpr( + LinearFunctionExtractOriginalExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2288,6 +4070,20 @@ module Raw { override string toString() { result = "LinearToDifferentiableFunctionExpr" } } + private Element getImmediateChildOfLinearToDifferentiableFunctionExpr( + LinearToDifferentiableFunctionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2295,6 +4091,18 @@ module Raw { override string toString() { result = "LoadExpr" } } + private Element getImmediateChildOfLoadExpr(LoadExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2328,6 +4136,18 @@ module Raw { } } + private Element getImmediateChildOfMemberRefExpr(MemberRefExpr e, int index) { + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and + ( + none() + or + index = n and result = e.getBase() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2335,6 +4155,18 @@ module Raw { override string toString() { result = "MetatypeConversionExpr" } } + private Element getImmediateChildOfMetatypeConversionExpr(MetatypeConversionExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2342,6 +4174,8 @@ module Raw { override string toString() { result = "NilLiteralExpr" } } + private Element getImmediateChildOfNilLiteralExpr(NilLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. * An instance of `#fileLiteral`, `#imageLiteral` or `#colorLiteral` expressions, which are used in playgrounds. @@ -2360,6 +4194,23 @@ module Raw { * Gets the `index`th argument of this object literal expression (0-based). */ Argument getArgument(int index) { object_literal_expr_arguments(this, index, result) } + + /** + * Gets the number of arguments of this object literal expression. + */ + int getNumberOfArguments() { result = count(int i | object_literal_expr_arguments(this, i, _)) } + } + + private Element getImmediateChildOfObjectLiteralExpr(ObjectLiteralExpr e, int index) { + exists(int n, int nArgument | + n = 0 and + nArgument = n + e.getNumberOfArguments() and + ( + none() + or + result = e.getArgument(index - n) + ) + ) } /** @@ -2369,6 +4220,18 @@ module Raw { override string toString() { result = "OptionalTryExpr" } } + private Element getImmediateChildOfOptionalTryExpr(OptionalTryExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2376,6 +4239,18 @@ module Raw { override string toString() { result = "ParenExpr" } } + private Element getImmediateChildOfParenExpr(ParenExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2383,6 +4258,18 @@ module Raw { override string toString() { result = "PointerToPointerExpr" } } + private Element getImmediateChildOfPointerToPointerExpr(PointerToPointerExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2390,6 +4277,21 @@ module Raw { override string toString() { result = "PostfixUnaryExpr" } } + private Element getImmediateChildOfPostfixUnaryExpr(PostfixUnaryExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2397,6 +4299,21 @@ module Raw { override string toString() { result = "PrefixUnaryExpr" } } + private Element getImmediateChildOfPrefixUnaryExpr(PrefixUnaryExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2406,6 +4323,20 @@ module Raw { override string toString() { result = "ProtocolMetatypeToObjectExpr" } } + private Element getImmediateChildOfProtocolMetatypeToObjectExpr( + ProtocolMetatypeToObjectExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A regular expression literal which is checked at compile time, for example `/a(a|b)*b/`. @@ -2424,6 +4355,8 @@ module Raw { int getVersion() { regex_literal_exprs(this, _, result) } } + private Element getImmediateChildOfRegexLiteralExpr(RegexLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. * An internal raw instance of method lookups like `x.foo` in `x.foo()`. @@ -2443,6 +4376,18 @@ module Raw { override string toString() { result = "StringToPointerExpr" } } + private Element getImmediateChildOfStringToPointerExpr(StringToPointerExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2454,6 +4399,11 @@ module Raw { */ Argument getArgument(int index) { subscript_expr_arguments(this, index, result) } + /** + * Gets the number of arguments of this subscript expression. + */ + int getNumberOfArguments() { result = count(int i | subscript_expr_arguments(this, i, _)) } + /** * Holds if this subscript expression has direct to storage semantics. */ @@ -2479,6 +4429,21 @@ module Raw { } } + private Element getImmediateChildOfSubscriptExpr(SubscriptExpr e, int index) { + exists(int n, int nBase, int nArgument | + n = 0 and + nBase = n + 1 and + nArgument = nBase + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getBase() + or + result = e.getArgument(index - nBase) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2486,6 +4451,18 @@ module Raw { override string toString() { result = "TryExpr" } } + private Element getImmediateChildOfTryExpr(TryExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2493,6 +4470,18 @@ module Raw { override string toString() { result = "UnderlyingToOpaqueExpr" } } + private Element getImmediateChildOfUnderlyingToOpaqueExpr(UnderlyingToOpaqueExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2500,6 +4489,18 @@ module Raw { override string toString() { result = "UnevaluatedInstanceExpr" } } + private Element getImmediateChildOfUnevaluatedInstanceExpr(UnevaluatedInstanceExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A conversion from the uninhabited type to any other type. It's never evaluated. @@ -2508,6 +4509,18 @@ module Raw { override string toString() { result = "UnreachableExpr" } } + private Element getImmediateChildOfUnreachableExpr(UnreachableExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2517,6 +4530,20 @@ module Raw { override string toString() { result = "UnresolvedMemberChainResultExpr" } } + private Element getImmediateChildOfUnresolvedMemberChainResultExpr( + UnresolvedMemberChainResultExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2526,6 +4553,20 @@ module Raw { override string toString() { result = "UnresolvedTypeConversionExpr" } } + private Element getImmediateChildOfUnresolvedTypeConversionExpr( + UnresolvedTypeConversionExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. * A conversion that performs an unsafe bitcast. @@ -2534,6 +4575,18 @@ module Raw { override string toString() { result = "UnsafeCastExpr" } } + private Element getImmediateChildOfUnsafeCastExpr(UnsafeCastExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2541,6 +4594,18 @@ module Raw { override string toString() { result = "UnsafeExpr" } } + private Element getImmediateChildOfUnsafeExpr(UnsafeExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2553,6 +4618,8 @@ module Raw { boolean getValue() { boolean_literal_exprs(this, result) } } + private Element getImmediateChildOfBooleanLiteralExpr(BooleanLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2560,6 +4627,20 @@ module Raw { override string toString() { result = "ConditionalCheckedCastExpr" } } + private Element getImmediateChildOfConditionalCheckedCastExpr( + ConditionalCheckedCastExpr e, int index + ) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2567,6 +4648,21 @@ module Raw { override string toString() { result = "DotSyntaxCallExpr" } } + private Element getImmediateChildOfDotSyntaxCallExpr(DotSyntaxCallExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2574,6 +4670,18 @@ module Raw { override string toString() { result = "DynamicMemberRefExpr" } } + private Element getImmediateChildOfDynamicMemberRefExpr(DynamicMemberRefExpr e, int index) { + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and + ( + none() + or + index = n and result = e.getBase() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2581,6 +4689,18 @@ module Raw { override string toString() { result = "DynamicSubscriptExpr" } } + private Element getImmediateChildOfDynamicSubscriptExpr(DynamicSubscriptExpr e, int index) { + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and + ( + none() + or + index = n and result = e.getBase() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2588,6 +4708,18 @@ module Raw { override string toString() { result = "ForcedCheckedCastExpr" } } + private Element getImmediateChildOfForcedCheckedCastExpr(ForcedCheckedCastExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2595,6 +4727,21 @@ module Raw { override string toString() { result = "InitializerRefCallExpr" } } + private Element getImmediateChildOfInitializerRefCallExpr(InitializerRefCallExpr e, int index) { + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + e.getNumberOfArguments() and + ( + none() + or + index = n and result = e.getFunction() + or + result = e.getArgument(index - nFunction) + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2602,6 +4749,18 @@ module Raw { override string toString() { result = "IsExpr" } } + private Element getImmediateChildOfIsExpr(IsExpr e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2614,6 +4773,12 @@ module Raw { string getKind() { magic_identifier_literal_exprs(this, result) } } + private Element getImmediateChildOfMagicIdentifierLiteralExpr( + MagicIdentifierLiteralExpr e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -2631,6 +4796,8 @@ module Raw { string getValue() { string_literal_exprs(this, result) } } + private Element getImmediateChildOfStringLiteralExpr(StringLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2643,6 +4810,8 @@ module Raw { string getStringValue() { float_literal_exprs(this, result) } } + private Element getImmediateChildOfFloatLiteralExpr(FloatLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2655,6 +4824,8 @@ module Raw { string getStringValue() { integer_literal_exprs(this, result) } } + private Element getImmediateChildOfIntegerLiteralExpr(IntegerLiteralExpr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2672,6 +4843,8 @@ module Raw { override string toString() { result = "AnyPattern" } } + private Element getImmediateChildOfAnyPattern(AnyPattern e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2684,6 +4857,18 @@ module Raw { Pattern getSubPattern() { binding_patterns(this, result) } } + private Element getImmediateChildOfBindingPattern(BindingPattern e, int index) { + exists(int n, int nSubPattern | + n = 0 and + nSubPattern = n + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2696,6 +4881,8 @@ module Raw { boolean getValue() { bool_patterns(this, result) } } + private Element getImmediateChildOfBoolPattern(BoolPattern e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2713,6 +4900,18 @@ module Raw { Pattern getSubPattern() { enum_element_pattern_sub_patterns(this, result) } } + private Element getImmediateChildOfEnumElementPattern(EnumElementPattern e, int index) { + exists(int n, int nSubPattern | + n = 0 and + nSubPattern = n + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2725,6 +4924,18 @@ module Raw { Expr getSubExpr() { expr_patterns(this, result) } } + private Element getImmediateChildOfExprPattern(ExprPattern e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2742,6 +4953,21 @@ module Raw { Pattern getSubPattern() { is_pattern_sub_patterns(this, result) } } + private Element getImmediateChildOfIsPattern(IsPattern e, int index) { + exists(int n, int nCastTypeRepr, int nSubPattern | + n = 0 and + nCastTypeRepr = n + 1 and + nSubPattern = nCastTypeRepr + 1 and + ( + none() + or + index = n and result = e.getCastTypeRepr() + or + index = nCastTypeRepr and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2754,6 +4980,8 @@ module Raw { VarDecl getVarDecl() { named_patterns(this, result) } } + private Element getImmediateChildOfNamedPattern(NamedPattern e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2766,6 +4994,18 @@ module Raw { Pattern getSubPattern() { optional_some_patterns(this, result) } } + private Element getImmediateChildOfOptionalSomePattern(OptionalSomePattern e, int index) { + exists(int n, int nSubPattern | + n = 0 and + nSubPattern = n + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2778,6 +5018,18 @@ module Raw { Pattern getSubPattern() { paren_patterns(this, result) } } + private Element getImmediateChildOfParenPattern(ParenPattern e, int index) { + exists(int n, int nSubPattern | + n = 0 and + nSubPattern = n + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2788,6 +5040,23 @@ module Raw { * Gets the `index`th element of this tuple pattern (0-based). */ Pattern getElement(int index) { tuple_pattern_elements(this, index, result) } + + /** + * Gets the number of elements of this tuple pattern. + */ + int getNumberOfElements() { result = count(int i | tuple_pattern_elements(this, i, _)) } + } + + private Element getImmediateChildOfTuplePattern(TuplePattern e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -2807,6 +5076,21 @@ module Raw { TypeRepr getTypeRepr() { typed_pattern_type_reprs(this, result) } } + private Element getImmediateChildOfTypedPattern(TypedPattern e, int index) { + exists(int n, int nSubPattern, int nTypeRepr | + n = 0 and + nSubPattern = n + 1 and + nTypeRepr = nSubPattern + 1 and + ( + none() + or + index = n and result = e.getSubPattern() + or + index = nSubPattern and result = e.getTypeRepr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2824,6 +5108,21 @@ module Raw { Expr getGuard() { case_label_item_guards(this, result) } } + private Element getImmediateChildOfCaseLabelItem(CaseLabelItem e, int index) { + exists(int n, int nPattern, int nGuard | + n = 0 and + nPattern = n + 1 and + nGuard = nPattern + 1 and + ( + none() + or + index = n and result = e.getPattern() + or + index = nPattern and result = e.getGuard() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2851,6 +5150,27 @@ module Raw { AvailabilityInfo getAvailability() { condition_element_availabilities(this, result) } } + private Element getImmediateChildOfConditionElement(ConditionElement e, int index) { + exists(int n, int nBoolean, int nPattern, int nInitializer, int nAvailability | + n = 0 and + nBoolean = n + 1 and + nPattern = nBoolean + 1 and + nInitializer = nPattern + 1 and + nAvailability = nInitializer + 1 and + ( + none() + or + index = n and result = e.getBoolean() + or + index = nBoolean and result = e.getPattern() + or + index = nPattern and result = e.getInitializer() + or + index = nInitializer and result = e.getAvailability() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2866,6 +5186,23 @@ module Raw { * Gets the `index`th element of this statement condition (0-based). */ ConditionElement getElement(int index) { stmt_condition_elements(this, index, result) } + + /** + * Gets the number of elements of this statement condition. + */ + int getNumberOfElements() { result = count(int i | stmt_condition_elements(this, i, _)) } + } + + private Element getImmediateChildOfStmtCondition(StmtCondition e, int index) { + exists(int n, int nElement | + n = 0 and + nElement = n + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - n) + ) + ) } /** @@ -2878,6 +5215,24 @@ module Raw { * Gets the `index`th element of this brace statement (0-based). */ AstNode getElement(int index) { brace_stmt_elements(this, index, result) } + + /** + * Gets the number of elements of this brace statement. + */ + int getNumberOfElements() { result = count(int i | brace_stmt_elements(this, i, _)) } + } + + private Element getImmediateChildOfBraceStmt(BraceStmt e, int index) { + exists(int n, int nVariable, int nElement | + n = 0 and + nVariable = n and + nElement = nVariable + e.getNumberOfElements() and + ( + none() + or + result = e.getElement(index - nVariable) + ) + ) } /** @@ -2897,6 +5252,8 @@ module Raw { Stmt getTarget() { break_stmt_targets(this, result) } } + private Element getImmediateChildOfBreakStmt(BreakStmt e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2908,17 +5265,45 @@ module Raw { */ CaseLabelItem getLabel(int index) { case_stmt_labels(this, index, result) } + /** + * Gets the number of labels of this case statement. + */ + int getNumberOfLabels() { result = count(int i | case_stmt_labels(this, i, _)) } + /** * Gets the `index`th variable of this case statement (0-based). */ VarDecl getVariable(int index) { case_stmt_variables(this, index, result) } + /** + * Gets the number of variables of this case statement. + */ + int getNumberOfVariables() { result = count(int i | case_stmt_variables(this, i, _)) } + /** * Gets the body of this case statement. */ Stmt getBody() { case_stmts(this, result) } } + private Element getImmediateChildOfCaseStmt(CaseStmt e, int index) { + exists(int n, int nLabel, int nVariable, int nBody | + n = 0 and + nLabel = n + e.getNumberOfLabels() and + nVariable = nLabel + e.getNumberOfVariables() and + nBody = nVariable + 1 and + ( + none() + or + result = e.getLabel(index - n) + or + result = e.getVariable(index - nLabel) + or + index = nVariable and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2936,6 +5321,8 @@ module Raw { Stmt getTarget() { continue_stmt_targets(this, result) } } + private Element getImmediateChildOfContinueStmt(ContinueStmt e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2948,6 +5335,18 @@ module Raw { BraceStmt getBody() { defer_stmts(this, result) } } + private Element getImmediateChildOfDeferStmt(DeferStmt e, int index) { + exists(int n, int nBody | + n = 0 and + nBody = n + 1 and + ( + none() + or + index = n and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. * A statement that takes a non-copyable value and destructs its members/fields. @@ -2966,6 +5365,18 @@ module Raw { Expr getSubExpr() { discard_stmts(this, result) } } + private Element getImmediateChildOfDiscardStmt(DiscardStmt e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -2973,6 +5384,8 @@ module Raw { override string toString() { result = "FailStmt" } } + private Element getImmediateChildOfFailStmt(FailStmt e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -2990,6 +5403,8 @@ module Raw { CaseStmt getFallthroughDest() { fallthrough_stmts(this, _, result) } } + private Element getImmediateChildOfFallthroughStmt(FallthroughStmt e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3017,6 +5432,8 @@ module Raw { string getMessage() { pound_assert_stmts(this, _, result) } } + private Element getImmediateChildOfPoundAssertStmt(PoundAssertStmt e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3029,6 +5446,18 @@ module Raw { Expr getResult() { return_stmt_results(this, result) } } + private Element getImmediateChildOfReturnStmt(ReturnStmt e, int index) { + exists(int n, int nResult | + n = 0 and + nResult = n + 1 and + ( + none() + or + index = n and result = e.getResult() + ) + ) + } + /** * INTERNAL: Do not use. * A statement implicitly wrapping values to be used in branches of if/switch expressions. For example in: @@ -3050,6 +5479,18 @@ module Raw { Expr getResult() { then_stmts(this, result) } } + private Element getImmediateChildOfThenStmt(ThenStmt e, int index) { + exists(int n, int nResult | + n = 0 and + nResult = n + 1 and + ( + none() + or + index = n and result = e.getResult() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3062,6 +5503,18 @@ module Raw { Expr getSubExpr() { throw_stmts(this, result) } } + private Element getImmediateChildOfThrowStmt(ThrowStmt e, int index) { + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and + ( + none() + or + index = n and result = e.getSubExpr() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3072,6 +5525,23 @@ module Raw { * Gets the `index`th result of this yield statement (0-based). */ Expr getResult(int index) { yield_stmt_results(this, index, result) } + + /** + * Gets the number of results of this yield statement. + */ + int getNumberOfResults() { result = count(int i | yield_stmt_results(this, i, _)) } + } + + private Element getImmediateChildOfYieldStmt(YieldStmt e, int index) { + exists(int n, int nResult | + n = 0 and + nResult = n + e.getNumberOfResults() and + ( + none() + or + result = e.getResult(index - n) + ) + ) } /** @@ -3089,6 +5559,26 @@ module Raw { * Gets the `index`th catch of this do catch statement (0-based). */ CaseStmt getCatch(int index) { do_catch_stmt_catches(this, index, result) } + + /** + * Gets the number of catches of this do catch statement. + */ + int getNumberOfCatches() { result = count(int i | do_catch_stmt_catches(this, i, _)) } + } + + private Element getImmediateChildOfDoCatchStmt(DoCatchStmt e, int index) { + exists(int n, int nBody, int nCatch | + n = 0 and + nBody = n + 1 and + nCatch = nBody + e.getNumberOfCatches() and + ( + none() + or + index = n and result = e.getBody() + or + result = e.getCatch(index - nBody) + ) + ) } /** @@ -3103,6 +5593,18 @@ module Raw { BraceStmt getBody() { do_stmts(this, result) } } + private Element getImmediateChildOfDoStmt(DoStmt e, int index) { + exists(int n, int nBody | + n = 0 and + nBody = n + 1 and + ( + none() + or + index = n and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3114,6 +5616,11 @@ module Raw { */ VarDecl getVariable(int index) { for_each_stmt_variables(this, index, result) } + /** + * Gets the number of variables of this for each statement. + */ + int getNumberOfVariables() { result = count(int i | for_each_stmt_variables(this, i, _)) } + /** * Gets the pattern of this for each statement. */ @@ -3140,6 +5647,35 @@ module Raw { BraceStmt getBody() { for_each_stmts(this, _, result) } } + private Element getImmediateChildOfForEachStmt(ForEachStmt e, int index) { + exists( + int n, int nVariable, int nPattern, int nWhere, int nIteratorVar, int nNextCall, int nBody + | + n = 0 and + nVariable = n + e.getNumberOfVariables() and + nPattern = nVariable + 1 and + nWhere = nPattern + 1 and + nIteratorVar = nWhere + 1 and + nNextCall = nIteratorVar + 1 and + nBody = nNextCall + 1 and + ( + none() + or + result = e.getVariable(index - n) + or + index = nVariable and result = e.getPattern() + or + index = nPattern and result = e.getWhere() + or + index = nWhere and result = e.getIteratorVar() + or + index = nIteratorVar and result = e.getNextCall() + or + index = nNextCall and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3167,6 +5703,21 @@ module Raw { Stmt getBody() { repeat_while_stmts(this, _, result) } } + private Element getImmediateChildOfRepeatWhileStmt(RepeatWhileStmt e, int index) { + exists(int n, int nCondition, int nBody | + n = 0 and + nCondition = n + 1 and + nBody = nCondition + 1 and + ( + none() + or + index = n and result = e.getCondition() + or + index = nCondition and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3182,6 +5733,26 @@ module Raw { * Gets the `index`th case of this switch statement (0-based). */ CaseStmt getCase(int index) { switch_stmt_cases(this, index, result) } + + /** + * Gets the number of cases of this switch statement. + */ + int getNumberOfCases() { result = count(int i | switch_stmt_cases(this, i, _)) } + } + + private Element getImmediateChildOfSwitchStmt(SwitchStmt e, int index) { + exists(int n, int nExpr, int nCase | + n = 0 and + nExpr = n + 1 and + nCase = nExpr + e.getNumberOfCases() and + ( + none() + or + index = n and result = e.getExpr() + or + result = e.getCase(index - nExpr) + ) + ) } /** @@ -3196,6 +5767,21 @@ module Raw { BraceStmt getBody() { guard_stmts(this, result) } } + private Element getImmediateChildOfGuardStmt(GuardStmt e, int index) { + exists(int n, int nCondition, int nBody | + n = 0 and + nCondition = n + 1 and + nBody = nCondition + 1 and + ( + none() + or + index = n and result = e.getCondition() + or + index = nCondition and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3213,6 +5799,24 @@ module Raw { Stmt getElse() { if_stmt_elses(this, result) } } + private Element getImmediateChildOfIfStmt(IfStmt e, int index) { + exists(int n, int nCondition, int nThen, int nElse | + n = 0 and + nCondition = n + 1 and + nThen = nCondition + 1 and + nElse = nThen + 1 and + ( + none() + or + index = n and result = e.getCondition() + or + index = nCondition and result = e.getThen() + or + index = nThen and result = e.getElse() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3225,6 +5829,21 @@ module Raw { Stmt getBody() { while_stmts(this, result) } } + private Element getImmediateChildOfWhileStmt(WhileStmt e, int index) { + exists(int n, int nCondition, int nBody | + n = 0 and + nCondition = n + 1 and + nBody = nCondition + 1 and + ( + none() + or + index = n and result = e.getCondition() + or + index = nCondition and result = e.getBody() + ) + ) + } + /** * INTERNAL: Do not use. */ @@ -3258,6 +5877,8 @@ module Raw { Type getType() { type_reprs(this, result) } } + private Element getImmediateChildOfTypeRepr(TypeRepr e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3272,6 +5893,13 @@ module Raw { */ Type getParamType(int index) { any_function_type_param_types(this, index, result) } + /** + * Gets the number of parameter types of this function type. + */ + int getNumberOfParamTypes() { + result = count(int i | any_function_type_param_types(this, i, _)) + } + /** * Holds if this type refers to a throwing function. */ @@ -3325,6 +5953,10 @@ module Raw { AssociatedTypeDecl getAssociatedTypeDecl() { dependent_member_types(this, _, result) } } + private Element getImmediateChildOfDependentMemberType(DependentMemberType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3337,6 +5969,8 @@ module Raw { Type getStaticSelfType() { dynamic_self_types(this, result) } } + private Element getImmediateChildOfDynamicSelfType(DynamicSelfType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3344,6 +5978,8 @@ module Raw { override string toString() { result = "ErrorType" } } + private Element getImmediateChildOfErrorType(ErrorType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3356,6 +5992,8 @@ module Raw { Type getConstraint() { existential_types(this, result) } } + private Element getImmediateChildOfExistentialType(ExistentialType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3368,6 +6006,8 @@ module Raw { Type getObjectType() { in_out_types(this, result) } } + private Element getImmediateChildOfInOutType(InOutType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3380,6 +6020,8 @@ module Raw { string getValue() { integer_types(this, result) } } + private Element getImmediateChildOfIntegerType(IntegerType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3392,6 +6034,8 @@ module Raw { Type getObjectType() { l_value_types(this, result) } } + private Element getImmediateChildOfLValueType(LValueType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3404,6 +6048,8 @@ module Raw { ModuleDecl getModule() { module_types(this, result) } } + private Element getImmediateChildOfModuleType(ModuleType e, int index) { none() } + /** * INTERNAL: Do not use. * A type of PackElementExpr, see PackElementExpr for more information. @@ -3417,6 +6063,8 @@ module Raw { Type getPackType() { pack_element_types(this, result) } } + private Element getImmediateChildOfPackElementType(PackElementType e, int index) { none() } + /** * INTERNAL: Do not use. * A type of PackExpansionExpr, see PackExpansionExpr for more information. @@ -3435,6 +6083,8 @@ module Raw { Type getCountType() { pack_expansion_types(this, _, result) } } + private Element getImmediateChildOfPackExpansionType(PackExpansionType e, int index) { none() } + /** * INTERNAL: Do not use. * An actual type of a pack expression at the instatiation point. @@ -3455,8 +6105,15 @@ module Raw { * Gets the `index`th element of this pack type (0-based). */ Type getElement(int index) { pack_type_elements(this, index, result) } + + /** + * Gets the number of elements of this pack type. + */ + int getNumberOfElements() { result = count(int i | pack_type_elements(this, i, _)) } } + private Element getImmediateChildOfPackType(PackType e, int index) { none() } + /** * INTERNAL: Do not use. * A sugar type of the form `P` with `P` a protocol. @@ -3475,6 +6132,17 @@ module Raw { * Gets the `index`th argument of this parameterized protocol type (0-based). */ Type getArg(int index) { parameterized_protocol_type_args(this, index, result) } + + /** + * Gets the number of arguments of this parameterized protocol type. + */ + int getNumberOfArgs() { result = count(int i | parameterized_protocol_type_args(this, i, _)) } + } + + private Element getImmediateChildOfParameterizedProtocolType( + ParameterizedProtocolType e, int index + ) { + none() } /** @@ -3487,6 +6155,17 @@ module Raw { * Gets the `index`th member of this protocol composition type (0-based). */ Type getMember(int index) { protocol_composition_type_members(this, index, result) } + + /** + * Gets the number of members of this protocol composition type. + */ + int getNumberOfMembers() { + result = count(int i | protocol_composition_type_members(this, i, _)) + } + } + + private Element getImmediateChildOfProtocolCompositionType(ProtocolCompositionType e, int index) { + none() } /** @@ -3520,12 +6199,24 @@ module Raw { */ Type getType(int index) { tuple_type_types(this, index, result) } + /** + * Gets the number of types of this tuple type. + */ + int getNumberOfTypes() { result = count(int i | tuple_type_types(this, i, _)) } + /** * Gets the `index`th name of this tuple type (0-based), if it exists. */ string getName(int index) { tuple_type_names(this, index, result) } + + /** + * Gets the number of names of this tuple type. + */ + int getNumberOfNames() { result = count(int i | tuple_type_names(this, i, _)) } } + private Element getImmediateChildOfTupleType(TupleType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3533,6 +6224,8 @@ module Raw { override string toString() { result = "UnresolvedType" } } + private Element getImmediateChildOfUnresolvedType(UnresolvedType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3556,6 +6249,11 @@ module Raw { * Gets the `index`th protocol of this archetype type (0-based). */ ProtocolDecl getProtocol(int index) { archetype_type_protocols(this, index, result) } + + /** + * Gets the number of protocols of this archetype type. + */ + int getNumberOfProtocols() { result = count(int i | archetype_type_protocols(this, i, _)) } } /** @@ -3565,6 +6263,10 @@ module Raw { override string toString() { result = "BuiltinBridgeObjectType" } } + private Element getImmediateChildOfBuiltinBridgeObjectType(BuiltinBridgeObjectType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3572,6 +6274,12 @@ module Raw { override string toString() { result = "BuiltinDefaultActorStorageType" } } + private Element getImmediateChildOfBuiltinDefaultActorStorageType( + BuiltinDefaultActorStorageType e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3579,6 +6287,10 @@ module Raw { override string toString() { result = "BuiltinExecutorType" } } + private Element getImmediateChildOfBuiltinExecutorType(BuiltinExecutorType e, int index) { + none() + } + /** * INTERNAL: Do not use. * A builtin type representing N values stored contiguously. @@ -3587,6 +6299,10 @@ module Raw { override string toString() { result = "BuiltinFixedArrayType" } } + private Element getImmediateChildOfBuiltinFixedArrayType(BuiltinFixedArrayType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3594,6 +6310,8 @@ module Raw { override string toString() { result = "BuiltinFloatType" } } + private Element getImmediateChildOfBuiltinFloatType(BuiltinFloatType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3601,6 +6319,8 @@ module Raw { override string toString() { result = "BuiltinJobType" } } + private Element getImmediateChildOfBuiltinJobType(BuiltinJobType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3608,6 +6328,10 @@ module Raw { override string toString() { result = "BuiltinNativeObjectType" } } + private Element getImmediateChildOfBuiltinNativeObjectType(BuiltinNativeObjectType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3615,6 +6339,10 @@ module Raw { override string toString() { result = "BuiltinRawPointerType" } } + private Element getImmediateChildOfBuiltinRawPointerType(BuiltinRawPointerType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3622,6 +6350,12 @@ module Raw { override string toString() { result = "BuiltinRawUnsafeContinuationType" } } + private Element getImmediateChildOfBuiltinRawUnsafeContinuationType( + BuiltinRawUnsafeContinuationType e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3629,6 +6363,12 @@ module Raw { override string toString() { result = "BuiltinUnsafeValueBufferType" } } + private Element getImmediateChildOfBuiltinUnsafeValueBufferType( + BuiltinUnsafeValueBufferType e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3636,6 +6376,8 @@ module Raw { override string toString() { result = "BuiltinVectorType" } } + private Element getImmediateChildOfBuiltinVectorType(BuiltinVectorType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3643,6 +6385,10 @@ module Raw { override string toString() { result = "ExistentialMetatypeType" } } + private Element getImmediateChildOfExistentialMetatypeType(ExistentialMetatypeType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3650,6 +6396,8 @@ module Raw { override string toString() { result = "FunctionType" } } + private Element getImmediateChildOfFunctionType(FunctionType e, int index) { none() } + /** * INTERNAL: Do not use. * The type of a generic function with type parameters @@ -3663,6 +6411,17 @@ module Raw { GenericTypeParamType getGenericParam(int index) { generic_function_type_generic_params(this, index, result) } + + /** + * Gets the number of type parameters of this generic type. + */ + int getNumberOfGenericParams() { + result = count(int i | generic_function_type_generic_params(this, i, _)) + } + } + + private Element getImmediateChildOfGenericFunctionType(GenericFunctionType e, int index) { + none() } /** @@ -3672,6 +6431,10 @@ module Raw { override string toString() { result = "GenericTypeParamType" } } + private Element getImmediateChildOfGenericTypeParamType(GenericTypeParamType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3679,6 +6442,8 @@ module Raw { override string toString() { result = "MetatypeType" } } + private Element getImmediateChildOfMetatypeType(MetatypeType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3698,6 +6463,8 @@ module Raw { Type getType() { paren_types(this, result) } } + private Element getImmediateChildOfParenType(ParenType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3715,6 +6482,8 @@ module Raw { TypeAliasDecl getDecl() { type_alias_types(this, result) } } + private Element getImmediateChildOfTypeAliasType(TypeAliasType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3722,6 +6491,8 @@ module Raw { override string toString() { result = "UnboundGenericType" } } + private Element getImmediateChildOfUnboundGenericType(UnboundGenericType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3729,6 +6500,10 @@ module Raw { override string toString() { result = "UnmanagedStorageType" } } + private Element getImmediateChildOfUnmanagedStorageType(UnmanagedStorageType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3736,6 +6511,8 @@ module Raw { override string toString() { result = "UnownedStorageType" } } + private Element getImmediateChildOfUnownedStorageType(UnownedStorageType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3743,6 +6520,8 @@ module Raw { override string toString() { result = "WeakStorageType" } } + private Element getImmediateChildOfWeakStorageType(WeakStorageType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3751,6 +6530,11 @@ module Raw { * Gets the `index`th argument type of this bound generic type (0-based). */ Type getArgType(int index) { bound_generic_type_arg_types(this, index, result) } + + /** + * Gets the number of argument types of this bound generic type. + */ + int getNumberOfArgTypes() { result = count(int i | bound_generic_type_arg_types(this, i, _)) } } /** @@ -3760,6 +6544,12 @@ module Raw { override string toString() { result = "BuiltinIntegerLiteralType" } } + private Element getImmediateChildOfBuiltinIntegerLiteralType( + BuiltinIntegerLiteralType e, int index + ) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3772,6 +6562,8 @@ module Raw { int getWidth() { builtin_integer_type_widths(this, result) } } + private Element getImmediateChildOfBuiltinIntegerType(BuiltinIntegerType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3789,6 +6581,8 @@ module Raw { Type getValueType() { dictionary_types(this, _, result) } } + private Element getImmediateChildOfDictionaryType(DictionaryType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3806,6 +6600,8 @@ module Raw { Type getElementType() { inline_array_types(this, _, result) } } + private Element getImmediateChildOfInlineArrayType(InlineArrayType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3831,6 +6627,10 @@ module Raw { OpaqueTypeDecl getDeclaration() { opaque_type_archetype_types(this, result) } } + private Element getImmediateChildOfOpaqueTypeArchetypeType(OpaqueTypeArchetypeType e, int index) { + none() + } + /** * INTERNAL: Do not use. * An archetype type of PackType. @@ -3839,6 +6639,8 @@ module Raw { override string toString() { result = "PackArchetypeType" } } + private Element getImmediateChildOfPackArchetypeType(PackArchetypeType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3846,6 +6648,10 @@ module Raw { override string toString() { result = "PrimaryArchetypeType" } } + private Element getImmediateChildOfPrimaryArchetypeType(PrimaryArchetypeType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3863,6 +6669,8 @@ module Raw { override string toString() { result = "ArraySliceType" } } + private Element getImmediateChildOfArraySliceType(ArraySliceType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3870,6 +6678,10 @@ module Raw { override string toString() { result = "BoundGenericClassType" } } + private Element getImmediateChildOfBoundGenericClassType(BoundGenericClassType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3877,6 +6689,10 @@ module Raw { override string toString() { result = "BoundGenericEnumType" } } + private Element getImmediateChildOfBoundGenericEnumType(BoundGenericEnumType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3884,6 +6700,10 @@ module Raw { override string toString() { result = "BoundGenericStructType" } } + private Element getImmediateChildOfBoundGenericStructType(BoundGenericStructType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3891,6 +6711,8 @@ module Raw { override string toString() { result = "ClassType" } } + private Element getImmediateChildOfClassType(ClassType e, int index) { none() } + /** * INTERNAL: Do not use. * An archetype type of PackElementType. @@ -3899,6 +6721,10 @@ module Raw { override string toString() { result = "ElementArchetypeType" } } + private Element getImmediateChildOfElementArchetypeType(ElementArchetypeType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3906,6 +6732,8 @@ module Raw { override string toString() { result = "EnumType" } } + private Element getImmediateChildOfEnumType(EnumType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3913,6 +6741,10 @@ module Raw { override string toString() { result = "ExistentialArchetypeType" } } + private Element getImmediateChildOfExistentialArchetypeType(ExistentialArchetypeType e, int index) { + none() + } + /** * INTERNAL: Do not use. */ @@ -3920,6 +6752,8 @@ module Raw { override string toString() { result = "OptionalType" } } + private Element getImmediateChildOfOptionalType(OptionalType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3927,6 +6761,8 @@ module Raw { override string toString() { result = "ProtocolType" } } + private Element getImmediateChildOfProtocolType(ProtocolType e, int index) { none() } + /** * INTERNAL: Do not use. */ @@ -3934,10 +6770,534 @@ module Raw { override string toString() { result = "StructType" } } + private Element getImmediateChildOfStructType(StructType e, int index) { none() } + /** * INTERNAL: Do not use. */ class VariadicSequenceType extends @variadic_sequence_type, UnarySyntaxSugarType { override string toString() { result = "VariadicSequenceType" } } + + private Element getImmediateChildOfVariadicSequenceType(VariadicSequenceType e, int index) { + none() + } + + /** + * Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. + */ + pragma[nomagic] + Element getImmediateChild(Element e, int index) { + // why does this look more complicated than it should? + // * none() simplifies generation, as we can append `or ...` without a special case for the first item + none() + or + result = getImmediateChildOfComment(e, index) + or + result = getImmediateChildOfDbFile(e, index) + or + result = getImmediateChildOfDbLocation(e, index) + or + result = getImmediateChildOfDiagnostics(e, index) + or + result = getImmediateChildOfAvailabilityInfo(e, index) + or + result = getImmediateChildOfAvailabilitySpec(e, index) + or + result = getImmediateChildOfKeyPathComponent(e, index) + or + result = getImmediateChildOfMacroRole(e, index) + or + result = getImmediateChildOfUnspecifiedElement(e, index) + or + result = getImmediateChildOfCapturedDecl(e, index) + or + result = getImmediateChildOfEnumCaseDecl(e, index) + or + result = getImmediateChildOfExtensionDecl(e, index) + or + result = getImmediateChildOfIfConfigDecl(e, index) + or + result = getImmediateChildOfImportDecl(e, index) + or + result = getImmediateChildOfMissingMemberDecl(e, index) + or + result = getImmediateChildOfPatternBindingDecl(e, index) + or + result = getImmediateChildOfPoundDiagnosticDecl(e, index) + or + result = getImmediateChildOfPrecedenceGroupDecl(e, index) + or + result = getImmediateChildOfTopLevelCodeDecl(e, index) + or + result = getImmediateChildOfUsingDecl(e, index) + or + result = getImmediateChildOfEnumElementDecl(e, index) + or + result = getImmediateChildOfInfixOperatorDecl(e, index) + or + result = getImmediateChildOfMacroDecl(e, index) + or + result = getImmediateChildOfPostfixOperatorDecl(e, index) + or + result = getImmediateChildOfPrefixOperatorDecl(e, index) + or + result = getImmediateChildOfDeinitializer(e, index) + or + result = getImmediateChildOfInitializer(e, index) + or + result = getImmediateChildOfModuleDecl(e, index) + or + result = getImmediateChildOfSubscriptDecl(e, index) + or + result = getImmediateChildOfAccessor(e, index) + or + result = getImmediateChildOfAssociatedTypeDecl(e, index) + or + result = getImmediateChildOfConcreteVarDecl(e, index) + or + result = getImmediateChildOfGenericTypeParamDecl(e, index) + or + result = getImmediateChildOfNamedFunction(e, index) + or + result = getImmediateChildOfOpaqueTypeDecl(e, index) + or + result = getImmediateChildOfParamDecl(e, index) + or + result = getImmediateChildOfTypeAliasDecl(e, index) + or + result = getImmediateChildOfClassDecl(e, index) + or + result = getImmediateChildOfEnumDecl(e, index) + or + result = getImmediateChildOfProtocolDecl(e, index) + or + result = getImmediateChildOfStructDecl(e, index) + or + result = getImmediateChildOfArgument(e, index) + or + result = getImmediateChildOfAppliedPropertyWrapperExpr(e, index) + or + result = getImmediateChildOfAssignExpr(e, index) + or + result = getImmediateChildOfBindOptionalExpr(e, index) + or + result = getImmediateChildOfCaptureListExpr(e, index) + or + result = getImmediateChildOfConsumeExpr(e, index) + or + result = getImmediateChildOfCopyExpr(e, index) + or + result = getImmediateChildOfCurrentContextIsolationExpr(e, index) + or + result = getImmediateChildOfDeclRefExpr(e, index) + or + result = getImmediateChildOfDefaultArgumentExpr(e, index) + or + result = getImmediateChildOfDiscardAssignmentExpr(e, index) + or + result = getImmediateChildOfDotSyntaxBaseIgnoredExpr(e, index) + or + result = getImmediateChildOfDynamicTypeExpr(e, index) + or + result = getImmediateChildOfEnumIsCaseExpr(e, index) + or + result = getImmediateChildOfErrorExpr(e, index) + or + result = getImmediateChildOfExtractFunctionIsolationExpr(e, index) + or + result = getImmediateChildOfForceValueExpr(e, index) + or + result = getImmediateChildOfIfExpr(e, index) + or + result = getImmediateChildOfInOutExpr(e, index) + or + result = getImmediateChildOfKeyPathApplicationExpr(e, index) + or + result = getImmediateChildOfKeyPathDotExpr(e, index) + or + result = getImmediateChildOfKeyPathExpr(e, index) + or + result = getImmediateChildOfLazyInitializationExpr(e, index) + or + result = getImmediateChildOfMakeTemporarilyEscapableExpr(e, index) + or + result = getImmediateChildOfMaterializePackExpr(e, index) + or + result = getImmediateChildOfObjCSelectorExpr(e, index) + or + result = getImmediateChildOfOneWayExpr(e, index) + or + result = getImmediateChildOfOpaqueValueExpr(e, index) + or + result = getImmediateChildOfOpenExistentialExpr(e, index) + or + result = getImmediateChildOfOptionalEvaluationExpr(e, index) + or + result = getImmediateChildOfOtherInitializerRefExpr(e, index) + or + result = getImmediateChildOfOverloadedDeclRefExpr(e, index) + or + result = getImmediateChildOfPackElementExpr(e, index) + or + result = getImmediateChildOfPackExpansionExpr(e, index) + or + result = getImmediateChildOfPropertyWrapperValuePlaceholderExpr(e, index) + or + result = getImmediateChildOfRebindSelfInInitializerExpr(e, index) + or + result = getImmediateChildOfSequenceExpr(e, index) + or + result = getImmediateChildOfSingleValueStmtExpr(e, index) + or + result = getImmediateChildOfSuperRefExpr(e, index) + or + result = getImmediateChildOfTapExpr(e, index) + or + result = getImmediateChildOfTupleElementExpr(e, index) + or + result = getImmediateChildOfTupleExpr(e, index) + or + result = getImmediateChildOfTypeExpr(e, index) + or + result = getImmediateChildOfTypeValueExpr(e, index) + or + result = getImmediateChildOfUnresolvedDeclRefExpr(e, index) + or + result = getImmediateChildOfUnresolvedDotExpr(e, index) + or + result = getImmediateChildOfUnresolvedMemberExpr(e, index) + or + result = getImmediateChildOfUnresolvedPatternExpr(e, index) + or + result = getImmediateChildOfUnresolvedSpecializeExpr(e, index) + or + result = getImmediateChildOfVarargExpansionExpr(e, index) + or + result = getImmediateChildOfAbiSafeConversionExpr(e, index) + or + result = getImmediateChildOfActorIsolationErasureExpr(e, index) + or + result = getImmediateChildOfAnyHashableErasureExpr(e, index) + or + result = getImmediateChildOfArchetypeToSuperExpr(e, index) + or + result = getImmediateChildOfArrayExpr(e, index) + or + result = getImmediateChildOfArrayToPointerExpr(e, index) + or + result = getImmediateChildOfAutoClosureExpr(e, index) + or + result = getImmediateChildOfAwaitExpr(e, index) + or + result = getImmediateChildOfBinaryExpr(e, index) + or + result = getImmediateChildOfBorrowExpr(e, index) + or + result = getImmediateChildOfBridgeFromObjCExpr(e, index) + or + result = getImmediateChildOfBridgeToObjCExpr(e, index) + or + result = getImmediateChildOfCallExpr(e, index) + or + result = getImmediateChildOfClassMetatypeToObjectExpr(e, index) + or + result = getImmediateChildOfCoerceExpr(e, index) + or + result = getImmediateChildOfCollectionUpcastConversionExpr(e, index) + or + result = getImmediateChildOfConditionalBridgeFromObjCExpr(e, index) + or + result = getImmediateChildOfCovariantFunctionConversionExpr(e, index) + or + result = getImmediateChildOfCovariantReturnConversionExpr(e, index) + or + result = getImmediateChildOfDerivedToBaseExpr(e, index) + or + result = getImmediateChildOfDestructureTupleExpr(e, index) + or + result = getImmediateChildOfDictionaryExpr(e, index) + or + result = getImmediateChildOfDifferentiableFunctionExpr(e, index) + or + result = getImmediateChildOfDifferentiableFunctionExtractOriginalExpr(e, index) + or + result = getImmediateChildOfDotSelfExpr(e, index) + or + result = getImmediateChildOfErasureExpr(e, index) + or + result = getImmediateChildOfExistentialMetatypeToObjectExpr(e, index) + or + result = getImmediateChildOfExplicitClosureExpr(e, index) + or + result = getImmediateChildOfForceTryExpr(e, index) + or + result = getImmediateChildOfForeignObjectConversionExpr(e, index) + or + result = getImmediateChildOfFunctionConversionExpr(e, index) + or + result = getImmediateChildOfInOutToPointerExpr(e, index) + or + result = getImmediateChildOfInjectIntoOptionalExpr(e, index) + or + result = getImmediateChildOfInterpolatedStringLiteralExpr(e, index) + or + result = getImmediateChildOfLinearFunctionExpr(e, index) + or + result = getImmediateChildOfLinearFunctionExtractOriginalExpr(e, index) + or + result = getImmediateChildOfLinearToDifferentiableFunctionExpr(e, index) + or + result = getImmediateChildOfLoadExpr(e, index) + or + result = getImmediateChildOfMemberRefExpr(e, index) + or + result = getImmediateChildOfMetatypeConversionExpr(e, index) + or + result = getImmediateChildOfNilLiteralExpr(e, index) + or + result = getImmediateChildOfObjectLiteralExpr(e, index) + or + result = getImmediateChildOfOptionalTryExpr(e, index) + or + result = getImmediateChildOfParenExpr(e, index) + or + result = getImmediateChildOfPointerToPointerExpr(e, index) + or + result = getImmediateChildOfPostfixUnaryExpr(e, index) + or + result = getImmediateChildOfPrefixUnaryExpr(e, index) + or + result = getImmediateChildOfProtocolMetatypeToObjectExpr(e, index) + or + result = getImmediateChildOfRegexLiteralExpr(e, index) + or + result = getImmediateChildOfStringToPointerExpr(e, index) + or + result = getImmediateChildOfSubscriptExpr(e, index) + or + result = getImmediateChildOfTryExpr(e, index) + or + result = getImmediateChildOfUnderlyingToOpaqueExpr(e, index) + or + result = getImmediateChildOfUnevaluatedInstanceExpr(e, index) + or + result = getImmediateChildOfUnreachableExpr(e, index) + or + result = getImmediateChildOfUnresolvedMemberChainResultExpr(e, index) + or + result = getImmediateChildOfUnresolvedTypeConversionExpr(e, index) + or + result = getImmediateChildOfUnsafeCastExpr(e, index) + or + result = getImmediateChildOfUnsafeExpr(e, index) + or + result = getImmediateChildOfBooleanLiteralExpr(e, index) + or + result = getImmediateChildOfConditionalCheckedCastExpr(e, index) + or + result = getImmediateChildOfDotSyntaxCallExpr(e, index) + or + result = getImmediateChildOfDynamicMemberRefExpr(e, index) + or + result = getImmediateChildOfDynamicSubscriptExpr(e, index) + or + result = getImmediateChildOfForcedCheckedCastExpr(e, index) + or + result = getImmediateChildOfInitializerRefCallExpr(e, index) + or + result = getImmediateChildOfIsExpr(e, index) + or + result = getImmediateChildOfMagicIdentifierLiteralExpr(e, index) + or + result = getImmediateChildOfStringLiteralExpr(e, index) + or + result = getImmediateChildOfFloatLiteralExpr(e, index) + or + result = getImmediateChildOfIntegerLiteralExpr(e, index) + or + result = getImmediateChildOfAnyPattern(e, index) + or + result = getImmediateChildOfBindingPattern(e, index) + or + result = getImmediateChildOfBoolPattern(e, index) + or + result = getImmediateChildOfEnumElementPattern(e, index) + or + result = getImmediateChildOfExprPattern(e, index) + or + result = getImmediateChildOfIsPattern(e, index) + or + result = getImmediateChildOfNamedPattern(e, index) + or + result = getImmediateChildOfOptionalSomePattern(e, index) + or + result = getImmediateChildOfParenPattern(e, index) + or + result = getImmediateChildOfTuplePattern(e, index) + or + result = getImmediateChildOfTypedPattern(e, index) + or + result = getImmediateChildOfCaseLabelItem(e, index) + or + result = getImmediateChildOfConditionElement(e, index) + or + result = getImmediateChildOfStmtCondition(e, index) + or + result = getImmediateChildOfBraceStmt(e, index) + or + result = getImmediateChildOfBreakStmt(e, index) + or + result = getImmediateChildOfCaseStmt(e, index) + or + result = getImmediateChildOfContinueStmt(e, index) + or + result = getImmediateChildOfDeferStmt(e, index) + or + result = getImmediateChildOfDiscardStmt(e, index) + or + result = getImmediateChildOfFailStmt(e, index) + or + result = getImmediateChildOfFallthroughStmt(e, index) + or + result = getImmediateChildOfPoundAssertStmt(e, index) + or + result = getImmediateChildOfReturnStmt(e, index) + or + result = getImmediateChildOfThenStmt(e, index) + or + result = getImmediateChildOfThrowStmt(e, index) + or + result = getImmediateChildOfYieldStmt(e, index) + or + result = getImmediateChildOfDoCatchStmt(e, index) + or + result = getImmediateChildOfDoStmt(e, index) + or + result = getImmediateChildOfForEachStmt(e, index) + or + result = getImmediateChildOfRepeatWhileStmt(e, index) + or + result = getImmediateChildOfSwitchStmt(e, index) + or + result = getImmediateChildOfGuardStmt(e, index) + or + result = getImmediateChildOfIfStmt(e, index) + or + result = getImmediateChildOfWhileStmt(e, index) + or + result = getImmediateChildOfTypeRepr(e, index) + or + result = getImmediateChildOfDependentMemberType(e, index) + or + result = getImmediateChildOfDynamicSelfType(e, index) + or + result = getImmediateChildOfErrorType(e, index) + or + result = getImmediateChildOfExistentialType(e, index) + or + result = getImmediateChildOfInOutType(e, index) + or + result = getImmediateChildOfIntegerType(e, index) + or + result = getImmediateChildOfLValueType(e, index) + or + result = getImmediateChildOfModuleType(e, index) + or + result = getImmediateChildOfPackElementType(e, index) + or + result = getImmediateChildOfPackExpansionType(e, index) + or + result = getImmediateChildOfPackType(e, index) + or + result = getImmediateChildOfParameterizedProtocolType(e, index) + or + result = getImmediateChildOfProtocolCompositionType(e, index) + or + result = getImmediateChildOfTupleType(e, index) + or + result = getImmediateChildOfUnresolvedType(e, index) + or + result = getImmediateChildOfBuiltinBridgeObjectType(e, index) + or + result = getImmediateChildOfBuiltinDefaultActorStorageType(e, index) + or + result = getImmediateChildOfBuiltinExecutorType(e, index) + or + result = getImmediateChildOfBuiltinFixedArrayType(e, index) + or + result = getImmediateChildOfBuiltinFloatType(e, index) + or + result = getImmediateChildOfBuiltinJobType(e, index) + or + result = getImmediateChildOfBuiltinNativeObjectType(e, index) + or + result = getImmediateChildOfBuiltinRawPointerType(e, index) + or + result = getImmediateChildOfBuiltinRawUnsafeContinuationType(e, index) + or + result = getImmediateChildOfBuiltinUnsafeValueBufferType(e, index) + or + result = getImmediateChildOfBuiltinVectorType(e, index) + or + result = getImmediateChildOfExistentialMetatypeType(e, index) + or + result = getImmediateChildOfFunctionType(e, index) + or + result = getImmediateChildOfGenericFunctionType(e, index) + or + result = getImmediateChildOfGenericTypeParamType(e, index) + or + result = getImmediateChildOfMetatypeType(e, index) + or + result = getImmediateChildOfParenType(e, index) + or + result = getImmediateChildOfTypeAliasType(e, index) + or + result = getImmediateChildOfUnboundGenericType(e, index) + or + result = getImmediateChildOfUnmanagedStorageType(e, index) + or + result = getImmediateChildOfUnownedStorageType(e, index) + or + result = getImmediateChildOfWeakStorageType(e, index) + or + result = getImmediateChildOfBuiltinIntegerLiteralType(e, index) + or + result = getImmediateChildOfBuiltinIntegerType(e, index) + or + result = getImmediateChildOfDictionaryType(e, index) + or + result = getImmediateChildOfInlineArrayType(e, index) + or + result = getImmediateChildOfOpaqueTypeArchetypeType(e, index) + or + result = getImmediateChildOfPackArchetypeType(e, index) + or + result = getImmediateChildOfPrimaryArchetypeType(e, index) + or + result = getImmediateChildOfArraySliceType(e, index) + or + result = getImmediateChildOfBoundGenericClassType(e, index) + or + result = getImmediateChildOfBoundGenericEnumType(e, index) + or + result = getImmediateChildOfBoundGenericStructType(e, index) + or + result = getImmediateChildOfClassType(e, index) + or + result = getImmediateChildOfElementArchetypeType(e, index) + or + result = getImmediateChildOfEnumType(e, index) + or + result = getImmediateChildOfExistentialArchetypeType(e, index) + or + result = getImmediateChildOfOptionalType(e, index) + or + result = getImmediateChildOfProtocolType(e, index) + or + result = getImmediateChildOfStructType(e, index) + or + result = getImmediateChildOfVariadicSequenceType(e, index) + } } diff --git a/swift/ql/lib/codeql/swift/generated/Synth.qll b/swift/ql/lib/codeql/swift/generated/Synth.qll index 886fb8550470..27508df94e97 100644 --- a/swift/ql/lib/codeql/swift/generated/Synth.qll +++ b/swift/ql/lib/codeql/swift/generated/Synth.qll @@ -1453,66 +1453,84 @@ module Synth { /** * INTERNAL: Do not use. + * + * Gets the parent of synthetic element `e`. + */ + Raw::Element getSynthParent(TElement e) { none() } + + /** + * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAvailabilityInfo`, if possible. */ TAvailabilityInfo convertAvailabilityInfoFromRaw(Raw::Element e) { result = TAvailabilityInfo(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAvailabilitySpec`, if possible. */ TAvailabilitySpec convertAvailabilitySpecFromRaw(Raw::Element e) { result = TAvailabilitySpec(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TComment`, if possible. */ TComment convertCommentFromRaw(Raw::Element e) { result = TComment(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDbFile`, if possible. */ TDbFile convertDbFileFromRaw(Raw::Element e) { result = TDbFile(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDbLocation`, if possible. */ TDbLocation convertDbLocationFromRaw(Raw::Element e) { result = TDbLocation(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDiagnostics`, if possible. */ TDiagnostics convertDiagnosticsFromRaw(Raw::Element e) { result = TDiagnostics(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TKeyPathComponent`, if possible. */ TKeyPathComponent convertKeyPathComponentFromRaw(Raw::Element e) { result = TKeyPathComponent(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroRole`, if possible. */ TMacroRole convertMacroRoleFromRaw(Raw::Element e) { result = TMacroRole(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnknownFile`, if possible. */ TUnknownFile convertUnknownFileFromRaw(Raw::Element e) { none() } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnknownLocation`, if possible. */ TUnknownLocation convertUnknownLocationFromRaw(Raw::Element e) { none() } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnspecifiedElement`, if possible. */ TUnspecifiedElement convertUnspecifiedElementFromRaw(Raw::Element e) { @@ -1521,12 +1539,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAccessor`, if possible. */ TAccessor convertAccessorFromRaw(Raw::Element e) { result = TAccessor(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAssociatedTypeDecl`, if possible. */ TAssociatedTypeDecl convertAssociatedTypeDeclFromRaw(Raw::Element e) { @@ -1535,54 +1555,63 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCapturedDecl`, if possible. */ TCapturedDecl convertCapturedDeclFromRaw(Raw::Element e) { result = TCapturedDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TClassDecl`, if possible. */ TClassDecl convertClassDeclFromRaw(Raw::Element e) { result = TClassDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConcreteVarDecl`, if possible. */ TConcreteVarDecl convertConcreteVarDeclFromRaw(Raw::Element e) { result = TConcreteVarDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDeinitializer`, if possible. */ TDeinitializer convertDeinitializerFromRaw(Raw::Element e) { result = TDeinitializer(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumCaseDecl`, if possible. */ TEnumCaseDecl convertEnumCaseDeclFromRaw(Raw::Element e) { result = TEnumCaseDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumDecl`, if possible. */ TEnumDecl convertEnumDeclFromRaw(Raw::Element e) { result = TEnumDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumElementDecl`, if possible. */ TEnumElementDecl convertEnumElementDeclFromRaw(Raw::Element e) { result = TEnumElementDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExtensionDecl`, if possible. */ TExtensionDecl convertExtensionDeclFromRaw(Raw::Element e) { result = TExtensionDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGenericTypeParamDecl`, if possible. */ TGenericTypeParamDecl convertGenericTypeParamDeclFromRaw(Raw::Element e) { @@ -1591,18 +1620,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIfConfigDecl`, if possible. */ TIfConfigDecl convertIfConfigDeclFromRaw(Raw::Element e) { result = TIfConfigDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TImportDecl`, if possible. */ TImportDecl convertImportDeclFromRaw(Raw::Element e) { result = TImportDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInfixOperatorDecl`, if possible. */ TInfixOperatorDecl convertInfixOperatorDeclFromRaw(Raw::Element e) { @@ -1611,18 +1643,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInitializer`, if possible. */ TInitializer convertInitializerFromRaw(Raw::Element e) { result = TInitializer(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMacroDecl`, if possible. */ TMacroDecl convertMacroDeclFromRaw(Raw::Element e) { result = TMacroDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMissingMemberDecl`, if possible. */ TMissingMemberDecl convertMissingMemberDeclFromRaw(Raw::Element e) { @@ -1631,30 +1666,35 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TModuleDecl`, if possible. */ TModuleDecl convertModuleDeclFromRaw(Raw::Element e) { result = TModuleDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNamedFunction`, if possible. */ TNamedFunction convertNamedFunctionFromRaw(Raw::Element e) { result = TNamedFunction(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOpaqueTypeDecl`, if possible. */ TOpaqueTypeDecl convertOpaqueTypeDeclFromRaw(Raw::Element e) { result = TOpaqueTypeDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParamDecl`, if possible. */ TParamDecl convertParamDeclFromRaw(Raw::Element e) { result = TParamDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPatternBindingDecl`, if possible. */ TPatternBindingDecl convertPatternBindingDeclFromRaw(Raw::Element e) { @@ -1663,6 +1703,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPostfixOperatorDecl`, if possible. */ TPostfixOperatorDecl convertPostfixOperatorDeclFromRaw(Raw::Element e) { @@ -1671,6 +1712,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPoundDiagnosticDecl`, if possible. */ TPoundDiagnosticDecl convertPoundDiagnosticDeclFromRaw(Raw::Element e) { @@ -1679,6 +1721,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPrecedenceGroupDecl`, if possible. */ TPrecedenceGroupDecl convertPrecedenceGroupDeclFromRaw(Raw::Element e) { @@ -1687,6 +1730,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPrefixOperatorDecl`, if possible. */ TPrefixOperatorDecl convertPrefixOperatorDeclFromRaw(Raw::Element e) { @@ -1695,42 +1739,49 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TProtocolDecl`, if possible. */ TProtocolDecl convertProtocolDeclFromRaw(Raw::Element e) { result = TProtocolDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructDecl`, if possible. */ TStructDecl convertStructDeclFromRaw(Raw::Element e) { result = TStructDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSubscriptDecl`, if possible. */ TSubscriptDecl convertSubscriptDeclFromRaw(Raw::Element e) { result = TSubscriptDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTopLevelCodeDecl`, if possible. */ TTopLevelCodeDecl convertTopLevelCodeDeclFromRaw(Raw::Element e) { result = TTopLevelCodeDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeAliasDecl`, if possible. */ TTypeAliasDecl convertTypeAliasDeclFromRaw(Raw::Element e) { result = TTypeAliasDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUsingDecl`, if possible. */ TUsingDecl convertUsingDeclFromRaw(Raw::Element e) { result = TUsingDecl(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAbiSafeConversionExpr`, if possible. */ TAbiSafeConversionExpr convertAbiSafeConversionExprFromRaw(Raw::Element e) { @@ -1739,6 +1790,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TActorIsolationErasureExpr`, if possible. */ TActorIsolationErasureExpr convertActorIsolationErasureExprFromRaw(Raw::Element e) { @@ -1747,6 +1799,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAnyHashableErasureExpr`, if possible. */ TAnyHashableErasureExpr convertAnyHashableErasureExprFromRaw(Raw::Element e) { @@ -1755,6 +1808,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAppliedPropertyWrapperExpr`, if possible. */ TAppliedPropertyWrapperExpr convertAppliedPropertyWrapperExprFromRaw(Raw::Element e) { @@ -1763,6 +1817,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArchetypeToSuperExpr`, if possible. */ TArchetypeToSuperExpr convertArchetypeToSuperExprFromRaw(Raw::Element e) { @@ -1771,18 +1826,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArgument`, if possible. */ TArgument convertArgumentFromRaw(Raw::Element e) { result = TArgument(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayExpr`, if possible. */ TArrayExpr convertArrayExprFromRaw(Raw::Element e) { result = TArrayExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArrayToPointerExpr`, if possible. */ TArrayToPointerExpr convertArrayToPointerExprFromRaw(Raw::Element e) { @@ -1791,36 +1849,42 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAssignExpr`, if possible. */ TAssignExpr convertAssignExprFromRaw(Raw::Element e) { result = TAssignExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAutoClosureExpr`, if possible. */ TAutoClosureExpr convertAutoClosureExprFromRaw(Raw::Element e) { result = TAutoClosureExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAwaitExpr`, if possible. */ TAwaitExpr convertAwaitExprFromRaw(Raw::Element e) { result = TAwaitExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBinaryExpr`, if possible. */ TBinaryExpr convertBinaryExprFromRaw(Raw::Element e) { result = TBinaryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBindOptionalExpr`, if possible. */ TBindOptionalExpr convertBindOptionalExprFromRaw(Raw::Element e) { result = TBindOptionalExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBooleanLiteralExpr`, if possible. */ TBooleanLiteralExpr convertBooleanLiteralExprFromRaw(Raw::Element e) { @@ -1829,12 +1893,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBorrowExpr`, if possible. */ TBorrowExpr convertBorrowExprFromRaw(Raw::Element e) { result = TBorrowExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBridgeFromObjCExpr`, if possible. */ TBridgeFromObjCExpr convertBridgeFromObjCExprFromRaw(Raw::Element e) { @@ -1843,24 +1909,28 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBridgeToObjCExpr`, if possible. */ TBridgeToObjCExpr convertBridgeToObjCExprFromRaw(Raw::Element e) { result = TBridgeToObjCExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCallExpr`, if possible. */ TCallExpr convertCallExprFromRaw(Raw::Element e) { result = TCallExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCaptureListExpr`, if possible. */ TCaptureListExpr convertCaptureListExprFromRaw(Raw::Element e) { result = TCaptureListExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TClassMetatypeToObjectExpr`, if possible. */ TClassMetatypeToObjectExpr convertClassMetatypeToObjectExprFromRaw(Raw::Element e) { @@ -1869,12 +1939,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCoerceExpr`, if possible. */ TCoerceExpr convertCoerceExprFromRaw(Raw::Element e) { result = TCoerceExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCollectionUpcastConversionExpr`, if possible. */ TCollectionUpcastConversionExpr convertCollectionUpcastConversionExprFromRaw(Raw::Element e) { @@ -1883,6 +1955,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConditionalBridgeFromObjCExpr`, if possible. */ TConditionalBridgeFromObjCExpr convertConditionalBridgeFromObjCExprFromRaw(Raw::Element e) { @@ -1891,6 +1964,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConditionalCheckedCastExpr`, if possible. */ TConditionalCheckedCastExpr convertConditionalCheckedCastExprFromRaw(Raw::Element e) { @@ -1899,18 +1973,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConsumeExpr`, if possible. */ TConsumeExpr convertConsumeExprFromRaw(Raw::Element e) { result = TConsumeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCopyExpr`, if possible. */ TCopyExpr convertCopyExprFromRaw(Raw::Element e) { result = TCopyExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCovariantFunctionConversionExpr`, if possible. */ TCovariantFunctionConversionExpr convertCovariantFunctionConversionExprFromRaw(Raw::Element e) { @@ -1919,6 +1996,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCovariantReturnConversionExpr`, if possible. */ TCovariantReturnConversionExpr convertCovariantReturnConversionExprFromRaw(Raw::Element e) { @@ -1927,6 +2005,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCurrentContextIsolationExpr`, if possible. */ TCurrentContextIsolationExpr convertCurrentContextIsolationExprFromRaw(Raw::Element e) { @@ -1935,12 +2014,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDeclRefExpr`, if possible. */ TDeclRefExpr convertDeclRefExprFromRaw(Raw::Element e) { result = TDeclRefExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDefaultArgumentExpr`, if possible. */ TDefaultArgumentExpr convertDefaultArgumentExprFromRaw(Raw::Element e) { @@ -1949,6 +2030,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDerivedToBaseExpr`, if possible. */ TDerivedToBaseExpr convertDerivedToBaseExprFromRaw(Raw::Element e) { @@ -1957,6 +2039,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDestructureTupleExpr`, if possible. */ TDestructureTupleExpr convertDestructureTupleExprFromRaw(Raw::Element e) { @@ -1965,12 +2048,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDictionaryExpr`, if possible. */ TDictionaryExpr convertDictionaryExprFromRaw(Raw::Element e) { result = TDictionaryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDifferentiableFunctionExpr`, if possible. */ TDifferentiableFunctionExpr convertDifferentiableFunctionExprFromRaw(Raw::Element e) { @@ -1979,6 +2064,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDifferentiableFunctionExtractOriginalExpr`, if possible. */ TDifferentiableFunctionExtractOriginalExpr convertDifferentiableFunctionExtractOriginalExprFromRaw( @@ -1989,6 +2075,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDiscardAssignmentExpr`, if possible. */ TDiscardAssignmentExpr convertDiscardAssignmentExprFromRaw(Raw::Element e) { @@ -1997,12 +2084,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDotSelfExpr`, if possible. */ TDotSelfExpr convertDotSelfExprFromRaw(Raw::Element e) { result = TDotSelfExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDotSyntaxBaseIgnoredExpr`, if possible. */ TDotSyntaxBaseIgnoredExpr convertDotSyntaxBaseIgnoredExprFromRaw(Raw::Element e) { @@ -2011,6 +2100,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDotSyntaxCallExpr`, if possible. */ TDotSyntaxCallExpr convertDotSyntaxCallExprFromRaw(Raw::Element e) { @@ -2019,6 +2109,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDynamicMemberRefExpr`, if possible. */ TDynamicMemberRefExpr convertDynamicMemberRefExprFromRaw(Raw::Element e) { @@ -2027,6 +2118,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDynamicSubscriptExpr`, if possible. */ TDynamicSubscriptExpr convertDynamicSubscriptExprFromRaw(Raw::Element e) { @@ -2035,30 +2127,35 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDynamicTypeExpr`, if possible. */ TDynamicTypeExpr convertDynamicTypeExprFromRaw(Raw::Element e) { result = TDynamicTypeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumIsCaseExpr`, if possible. */ TEnumIsCaseExpr convertEnumIsCaseExprFromRaw(Raw::Element e) { result = TEnumIsCaseExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TErasureExpr`, if possible. */ TErasureExpr convertErasureExprFromRaw(Raw::Element e) { result = TErasureExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TErrorExpr`, if possible. */ TErrorExpr convertErrorExprFromRaw(Raw::Element e) { result = TErrorExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExistentialMetatypeToObjectExpr`, if possible. */ TExistentialMetatypeToObjectExpr convertExistentialMetatypeToObjectExprFromRaw(Raw::Element e) { @@ -2067,6 +2164,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExplicitClosureExpr`, if possible. */ TExplicitClosureExpr convertExplicitClosureExprFromRaw(Raw::Element e) { @@ -2075,6 +2173,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExtractFunctionIsolationExpr`, if possible. */ TExtractFunctionIsolationExpr convertExtractFunctionIsolationExprFromRaw(Raw::Element e) { @@ -2083,24 +2182,28 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFloatLiteralExpr`, if possible. */ TFloatLiteralExpr convertFloatLiteralExprFromRaw(Raw::Element e) { result = TFloatLiteralExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForceTryExpr`, if possible. */ TForceTryExpr convertForceTryExprFromRaw(Raw::Element e) { result = TForceTryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForceValueExpr`, if possible. */ TForceValueExpr convertForceValueExprFromRaw(Raw::Element e) { result = TForceValueExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForcedCheckedCastExpr`, if possible. */ TForcedCheckedCastExpr convertForcedCheckedCastExprFromRaw(Raw::Element e) { @@ -2109,6 +2212,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForeignObjectConversionExpr`, if possible. */ TForeignObjectConversionExpr convertForeignObjectConversionExprFromRaw(Raw::Element e) { @@ -2117,6 +2221,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFunctionConversionExpr`, if possible. */ TFunctionConversionExpr convertFunctionConversionExprFromRaw(Raw::Element e) { @@ -2125,18 +2230,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIfExpr`, if possible. */ TIfExpr convertIfExprFromRaw(Raw::Element e) { result = TIfExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInOutExpr`, if possible. */ TInOutExpr convertInOutExprFromRaw(Raw::Element e) { result = TInOutExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInOutToPointerExpr`, if possible. */ TInOutToPointerExpr convertInOutToPointerExprFromRaw(Raw::Element e) { @@ -2145,6 +2253,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInitializerRefCallExpr`, if possible. */ TInitializerRefCallExpr convertInitializerRefCallExprFromRaw(Raw::Element e) { @@ -2153,6 +2262,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInjectIntoOptionalExpr`, if possible. */ TInjectIntoOptionalExpr convertInjectIntoOptionalExprFromRaw(Raw::Element e) { @@ -2161,6 +2271,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIntegerLiteralExpr`, if possible. */ TIntegerLiteralExpr convertIntegerLiteralExprFromRaw(Raw::Element e) { @@ -2169,6 +2280,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInterpolatedStringLiteralExpr`, if possible. */ TInterpolatedStringLiteralExpr convertInterpolatedStringLiteralExprFromRaw(Raw::Element e) { @@ -2177,12 +2289,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIsExpr`, if possible. */ TIsExpr convertIsExprFromRaw(Raw::Element e) { result = TIsExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TKeyPathApplicationExpr`, if possible. */ TKeyPathApplicationExpr convertKeyPathApplicationExprFromRaw(Raw::Element e) { @@ -2191,18 +2305,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TKeyPathDotExpr`, if possible. */ TKeyPathDotExpr convertKeyPathDotExprFromRaw(Raw::Element e) { result = TKeyPathDotExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TKeyPathExpr`, if possible. */ TKeyPathExpr convertKeyPathExprFromRaw(Raw::Element e) { result = TKeyPathExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLazyInitializationExpr`, if possible. */ TLazyInitializationExpr convertLazyInitializationExprFromRaw(Raw::Element e) { @@ -2211,6 +2328,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLinearFunctionExpr`, if possible. */ TLinearFunctionExpr convertLinearFunctionExprFromRaw(Raw::Element e) { @@ -2219,6 +2337,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLinearFunctionExtractOriginalExpr`, if possible. */ TLinearFunctionExtractOriginalExpr convertLinearFunctionExtractOriginalExprFromRaw(Raw::Element e) { @@ -2227,6 +2346,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLinearToDifferentiableFunctionExpr`, if possible. */ TLinearToDifferentiableFunctionExpr convertLinearToDifferentiableFunctionExprFromRaw( @@ -2237,12 +2357,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLoadExpr`, if possible. */ TLoadExpr convertLoadExprFromRaw(Raw::Element e) { result = TLoadExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMagicIdentifierLiteralExpr`, if possible. */ TMagicIdentifierLiteralExpr convertMagicIdentifierLiteralExprFromRaw(Raw::Element e) { @@ -2251,6 +2373,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMakeTemporarilyEscapableExpr`, if possible. */ TMakeTemporarilyEscapableExpr convertMakeTemporarilyEscapableExprFromRaw(Raw::Element e) { @@ -2259,6 +2382,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMaterializePackExpr`, if possible. */ TMaterializePackExpr convertMaterializePackExprFromRaw(Raw::Element e) { @@ -2267,12 +2391,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMemberRefExpr`, if possible. */ TMemberRefExpr convertMemberRefExprFromRaw(Raw::Element e) { result = TMemberRefExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMetatypeConversionExpr`, if possible. */ TMetatypeConversionExpr convertMetatypeConversionExprFromRaw(Raw::Element e) { @@ -2281,24 +2407,28 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMethodLookupExpr`, if possible. */ TMethodLookupExpr convertMethodLookupExprFromRaw(Raw::Element e) { result = TMethodLookupExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNilLiteralExpr`, if possible. */ TNilLiteralExpr convertNilLiteralExprFromRaw(Raw::Element e) { result = TNilLiteralExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TObjCSelectorExpr`, if possible. */ TObjCSelectorExpr convertObjCSelectorExprFromRaw(Raw::Element e) { result = TObjCSelectorExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TObjectLiteralExpr`, if possible. */ TObjectLiteralExpr convertObjectLiteralExprFromRaw(Raw::Element e) { @@ -2307,18 +2437,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOneWayExpr`, if possible. */ TOneWayExpr convertOneWayExprFromRaw(Raw::Element e) { result = TOneWayExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOpaqueValueExpr`, if possible. */ TOpaqueValueExpr convertOpaqueValueExprFromRaw(Raw::Element e) { result = TOpaqueValueExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOpenExistentialExpr`, if possible. */ TOpenExistentialExpr convertOpenExistentialExprFromRaw(Raw::Element e) { @@ -2327,6 +2460,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOptionalEvaluationExpr`, if possible. */ TOptionalEvaluationExpr convertOptionalEvaluationExprFromRaw(Raw::Element e) { @@ -2335,12 +2469,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOptionalTryExpr`, if possible. */ TOptionalTryExpr convertOptionalTryExprFromRaw(Raw::Element e) { result = TOptionalTryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOtherInitializerRefExpr`, if possible. */ TOtherInitializerRefExpr convertOtherInitializerRefExprFromRaw(Raw::Element e) { @@ -2349,6 +2485,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOverloadedDeclRefExpr`, if possible. */ TOverloadedDeclRefExpr convertOverloadedDeclRefExprFromRaw(Raw::Element e) { @@ -2357,12 +2494,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackElementExpr`, if possible. */ TPackElementExpr convertPackElementExprFromRaw(Raw::Element e) { result = TPackElementExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackExpansionExpr`, if possible. */ TPackExpansionExpr convertPackExpansionExprFromRaw(Raw::Element e) { @@ -2371,12 +2510,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenExpr`, if possible. */ TParenExpr convertParenExprFromRaw(Raw::Element e) { result = TParenExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPointerToPointerExpr`, if possible. */ TPointerToPointerExpr convertPointerToPointerExprFromRaw(Raw::Element e) { @@ -2385,18 +2526,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPostfixUnaryExpr`, if possible. */ TPostfixUnaryExpr convertPostfixUnaryExprFromRaw(Raw::Element e) { result = TPostfixUnaryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPrefixUnaryExpr`, if possible. */ TPrefixUnaryExpr convertPrefixUnaryExprFromRaw(Raw::Element e) { result = TPrefixUnaryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPropertyWrapperValuePlaceholderExpr`, if possible. */ TPropertyWrapperValuePlaceholderExpr convertPropertyWrapperValuePlaceholderExprFromRaw( @@ -2407,6 +2551,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TProtocolMetatypeToObjectExpr`, if possible. */ TProtocolMetatypeToObjectExpr convertProtocolMetatypeToObjectExprFromRaw(Raw::Element e) { @@ -2415,6 +2560,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRebindSelfInInitializerExpr`, if possible. */ TRebindSelfInInitializerExpr convertRebindSelfInInitializerExprFromRaw(Raw::Element e) { @@ -2423,18 +2569,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRegexLiteralExpr`, if possible. */ TRegexLiteralExpr convertRegexLiteralExprFromRaw(Raw::Element e) { result = TRegexLiteralExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSequenceExpr`, if possible. */ TSequenceExpr convertSequenceExprFromRaw(Raw::Element e) { result = TSequenceExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSingleValueStmtExpr`, if possible. */ TSingleValueStmtExpr convertSingleValueStmtExprFromRaw(Raw::Element e) { @@ -2443,6 +2592,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStringLiteralExpr`, if possible. */ TStringLiteralExpr convertStringLiteralExprFromRaw(Raw::Element e) { @@ -2451,6 +2601,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStringToPointerExpr`, if possible. */ TStringToPointerExpr convertStringToPointerExprFromRaw(Raw::Element e) { @@ -2459,54 +2610,63 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSubscriptExpr`, if possible. */ TSubscriptExpr convertSubscriptExprFromRaw(Raw::Element e) { result = TSubscriptExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSuperRefExpr`, if possible. */ TSuperRefExpr convertSuperRefExprFromRaw(Raw::Element e) { result = TSuperRefExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTapExpr`, if possible. */ TTapExpr convertTapExprFromRaw(Raw::Element e) { result = TTapExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTryExpr`, if possible. */ TTryExpr convertTryExprFromRaw(Raw::Element e) { result = TTryExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleElementExpr`, if possible. */ TTupleElementExpr convertTupleElementExprFromRaw(Raw::Element e) { result = TTupleElementExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleExpr`, if possible. */ TTupleExpr convertTupleExprFromRaw(Raw::Element e) { result = TTupleExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeExpr`, if possible. */ TTypeExpr convertTypeExprFromRaw(Raw::Element e) { result = TTypeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeValueExpr`, if possible. */ TTypeValueExpr convertTypeValueExprFromRaw(Raw::Element e) { result = TTypeValueExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnderlyingToOpaqueExpr`, if possible. */ TUnderlyingToOpaqueExpr convertUnderlyingToOpaqueExprFromRaw(Raw::Element e) { @@ -2515,6 +2675,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnevaluatedInstanceExpr`, if possible. */ TUnevaluatedInstanceExpr convertUnevaluatedInstanceExprFromRaw(Raw::Element e) { @@ -2523,12 +2684,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnreachableExpr`, if possible. */ TUnreachableExpr convertUnreachableExprFromRaw(Raw::Element e) { result = TUnreachableExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedDeclRefExpr`, if possible. */ TUnresolvedDeclRefExpr convertUnresolvedDeclRefExprFromRaw(Raw::Element e) { @@ -2537,6 +2700,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedDotExpr`, if possible. */ TUnresolvedDotExpr convertUnresolvedDotExprFromRaw(Raw::Element e) { @@ -2545,6 +2709,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedMemberChainResultExpr`, if possible. */ TUnresolvedMemberChainResultExpr convertUnresolvedMemberChainResultExprFromRaw(Raw::Element e) { @@ -2553,6 +2718,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedMemberExpr`, if possible. */ TUnresolvedMemberExpr convertUnresolvedMemberExprFromRaw(Raw::Element e) { @@ -2561,6 +2727,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedPatternExpr`, if possible. */ TUnresolvedPatternExpr convertUnresolvedPatternExprFromRaw(Raw::Element e) { @@ -2569,6 +2736,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedSpecializeExpr`, if possible. */ TUnresolvedSpecializeExpr convertUnresolvedSpecializeExprFromRaw(Raw::Element e) { @@ -2577,6 +2745,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedTypeConversionExpr`, if possible. */ TUnresolvedTypeConversionExpr convertUnresolvedTypeConversionExprFromRaw(Raw::Element e) { @@ -2585,18 +2754,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnsafeCastExpr`, if possible. */ TUnsafeCastExpr convertUnsafeCastExprFromRaw(Raw::Element e) { result = TUnsafeCastExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnsafeExpr`, if possible. */ TUnsafeExpr convertUnsafeExprFromRaw(Raw::Element e) { result = TUnsafeExpr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TVarargExpansionExpr`, if possible. */ TVarargExpansionExpr convertVarargExpansionExprFromRaw(Raw::Element e) { @@ -2605,24 +2777,28 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TAnyPattern`, if possible. */ TAnyPattern convertAnyPatternFromRaw(Raw::Element e) { result = TAnyPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBindingPattern`, if possible. */ TBindingPattern convertBindingPatternFromRaw(Raw::Element e) { result = TBindingPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBoolPattern`, if possible. */ TBoolPattern convertBoolPatternFromRaw(Raw::Element e) { result = TBoolPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumElementPattern`, if possible. */ TEnumElementPattern convertEnumElementPatternFromRaw(Raw::Element e) { @@ -2631,24 +2807,28 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExprPattern`, if possible. */ TExprPattern convertExprPatternFromRaw(Raw::Element e) { result = TExprPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIsPattern`, if possible. */ TIsPattern convertIsPatternFromRaw(Raw::Element e) { result = TIsPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TNamedPattern`, if possible. */ TNamedPattern convertNamedPatternFromRaw(Raw::Element e) { result = TNamedPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOptionalSomePattern`, if possible. */ TOptionalSomePattern convertOptionalSomePatternFromRaw(Raw::Element e) { @@ -2657,174 +2837,203 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenPattern`, if possible. */ TParenPattern convertParenPatternFromRaw(Raw::Element e) { result = TParenPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTuplePattern`, if possible. */ TTuplePattern convertTuplePatternFromRaw(Raw::Element e) { result = TTuplePattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypedPattern`, if possible. */ TTypedPattern convertTypedPatternFromRaw(Raw::Element e) { result = TTypedPattern(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBraceStmt`, if possible. */ TBraceStmt convertBraceStmtFromRaw(Raw::Element e) { result = TBraceStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBreakStmt`, if possible. */ TBreakStmt convertBreakStmtFromRaw(Raw::Element e) { result = TBreakStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCaseLabelItem`, if possible. */ TCaseLabelItem convertCaseLabelItemFromRaw(Raw::Element e) { result = TCaseLabelItem(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TCaseStmt`, if possible. */ TCaseStmt convertCaseStmtFromRaw(Raw::Element e) { result = TCaseStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TConditionElement`, if possible. */ TConditionElement convertConditionElementFromRaw(Raw::Element e) { result = TConditionElement(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TContinueStmt`, if possible. */ TContinueStmt convertContinueStmtFromRaw(Raw::Element e) { result = TContinueStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDeferStmt`, if possible. */ TDeferStmt convertDeferStmtFromRaw(Raw::Element e) { result = TDeferStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDiscardStmt`, if possible. */ TDiscardStmt convertDiscardStmtFromRaw(Raw::Element e) { result = TDiscardStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDoCatchStmt`, if possible. */ TDoCatchStmt convertDoCatchStmtFromRaw(Raw::Element e) { result = TDoCatchStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDoStmt`, if possible. */ TDoStmt convertDoStmtFromRaw(Raw::Element e) { result = TDoStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFailStmt`, if possible. */ TFailStmt convertFailStmtFromRaw(Raw::Element e) { result = TFailStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFallthroughStmt`, if possible. */ TFallthroughStmt convertFallthroughStmtFromRaw(Raw::Element e) { result = TFallthroughStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TForEachStmt`, if possible. */ TForEachStmt convertForEachStmtFromRaw(Raw::Element e) { result = TForEachStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGuardStmt`, if possible. */ TGuardStmt convertGuardStmtFromRaw(Raw::Element e) { result = TGuardStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIfStmt`, if possible. */ TIfStmt convertIfStmtFromRaw(Raw::Element e) { result = TIfStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPoundAssertStmt`, if possible. */ TPoundAssertStmt convertPoundAssertStmtFromRaw(Raw::Element e) { result = TPoundAssertStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TRepeatWhileStmt`, if possible. */ TRepeatWhileStmt convertRepeatWhileStmtFromRaw(Raw::Element e) { result = TRepeatWhileStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TReturnStmt`, if possible. */ TReturnStmt convertReturnStmtFromRaw(Raw::Element e) { result = TReturnStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStmtCondition`, if possible. */ TStmtCondition convertStmtConditionFromRaw(Raw::Element e) { result = TStmtCondition(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TSwitchStmt`, if possible. */ TSwitchStmt convertSwitchStmtFromRaw(Raw::Element e) { result = TSwitchStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TThenStmt`, if possible. */ TThenStmt convertThenStmtFromRaw(Raw::Element e) { result = TThenStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TThrowStmt`, if possible. */ TThrowStmt convertThrowStmtFromRaw(Raw::Element e) { result = TThrowStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWhileStmt`, if possible. */ TWhileStmt convertWhileStmtFromRaw(Raw::Element e) { result = TWhileStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TYieldStmt`, if possible. */ TYieldStmt convertYieldStmtFromRaw(Raw::Element e) { result = TYieldStmt(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TArraySliceType`, if possible. */ TArraySliceType convertArraySliceTypeFromRaw(Raw::Element e) { result = TArraySliceType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBoundGenericClassType`, if possible. */ TBoundGenericClassType convertBoundGenericClassTypeFromRaw(Raw::Element e) { @@ -2833,6 +3042,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBoundGenericEnumType`, if possible. */ TBoundGenericEnumType convertBoundGenericEnumTypeFromRaw(Raw::Element e) { @@ -2841,6 +3051,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBoundGenericStructType`, if possible. */ TBoundGenericStructType convertBoundGenericStructTypeFromRaw(Raw::Element e) { @@ -2849,6 +3060,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinBridgeObjectType`, if possible. */ TBuiltinBridgeObjectType convertBuiltinBridgeObjectTypeFromRaw(Raw::Element e) { @@ -2857,6 +3069,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinDefaultActorStorageType`, if possible. */ TBuiltinDefaultActorStorageType convertBuiltinDefaultActorStorageTypeFromRaw(Raw::Element e) { @@ -2865,6 +3078,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinExecutorType`, if possible. */ TBuiltinExecutorType convertBuiltinExecutorTypeFromRaw(Raw::Element e) { @@ -2873,6 +3087,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinFixedArrayType`, if possible. */ TBuiltinFixedArrayType convertBuiltinFixedArrayTypeFromRaw(Raw::Element e) { @@ -2881,12 +3096,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinFloatType`, if possible. */ TBuiltinFloatType convertBuiltinFloatTypeFromRaw(Raw::Element e) { result = TBuiltinFloatType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinIntegerLiteralType`, if possible. */ TBuiltinIntegerLiteralType convertBuiltinIntegerLiteralTypeFromRaw(Raw::Element e) { @@ -2895,6 +3112,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinIntegerType`, if possible. */ TBuiltinIntegerType convertBuiltinIntegerTypeFromRaw(Raw::Element e) { @@ -2903,12 +3121,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinJobType`, if possible. */ TBuiltinJobType convertBuiltinJobTypeFromRaw(Raw::Element e) { result = TBuiltinJobType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinNativeObjectType`, if possible. */ TBuiltinNativeObjectType convertBuiltinNativeObjectTypeFromRaw(Raw::Element e) { @@ -2917,6 +3137,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinRawPointerType`, if possible. */ TBuiltinRawPointerType convertBuiltinRawPointerTypeFromRaw(Raw::Element e) { @@ -2925,6 +3146,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinRawUnsafeContinuationType`, if possible. */ TBuiltinRawUnsafeContinuationType convertBuiltinRawUnsafeContinuationTypeFromRaw(Raw::Element e) { @@ -2933,6 +3155,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinUnsafeValueBufferType`, if possible. */ TBuiltinUnsafeValueBufferType convertBuiltinUnsafeValueBufferTypeFromRaw(Raw::Element e) { @@ -2941,6 +3164,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TBuiltinVectorType`, if possible. */ TBuiltinVectorType convertBuiltinVectorTypeFromRaw(Raw::Element e) { @@ -2949,12 +3173,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TClassType`, if possible. */ TClassType convertClassTypeFromRaw(Raw::Element e) { result = TClassType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDependentMemberType`, if possible. */ TDependentMemberType convertDependentMemberTypeFromRaw(Raw::Element e) { @@ -2963,18 +3189,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDictionaryType`, if possible. */ TDictionaryType convertDictionaryTypeFromRaw(Raw::Element e) { result = TDictionaryType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TDynamicSelfType`, if possible. */ TDynamicSelfType convertDynamicSelfTypeFromRaw(Raw::Element e) { result = TDynamicSelfType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TElementArchetypeType`, if possible. */ TElementArchetypeType convertElementArchetypeTypeFromRaw(Raw::Element e) { @@ -2983,18 +3212,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TEnumType`, if possible. */ TEnumType convertEnumTypeFromRaw(Raw::Element e) { result = TEnumType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TErrorType`, if possible. */ TErrorType convertErrorTypeFromRaw(Raw::Element e) { result = TErrorType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExistentialArchetypeType`, if possible. */ TExistentialArchetypeType convertExistentialArchetypeTypeFromRaw(Raw::Element e) { @@ -3003,6 +3235,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExistentialMetatypeType`, if possible. */ TExistentialMetatypeType convertExistentialMetatypeTypeFromRaw(Raw::Element e) { @@ -3011,18 +3244,21 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TExistentialType`, if possible. */ TExistentialType convertExistentialTypeFromRaw(Raw::Element e) { result = TExistentialType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TFunctionType`, if possible. */ TFunctionType convertFunctionTypeFromRaw(Raw::Element e) { result = TFunctionType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGenericFunctionType`, if possible. */ TGenericFunctionType convertGenericFunctionTypeFromRaw(Raw::Element e) { @@ -3031,6 +3267,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TGenericTypeParamType`, if possible. */ TGenericTypeParamType convertGenericTypeParamTypeFromRaw(Raw::Element e) { @@ -3039,42 +3276,49 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInOutType`, if possible. */ TInOutType convertInOutTypeFromRaw(Raw::Element e) { result = TInOutType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TInlineArrayType`, if possible. */ TInlineArrayType convertInlineArrayTypeFromRaw(Raw::Element e) { result = TInlineArrayType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TIntegerType`, if possible. */ TIntegerType convertIntegerTypeFromRaw(Raw::Element e) { result = TIntegerType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TLValueType`, if possible. */ TLValueType convertLValueTypeFromRaw(Raw::Element e) { result = TLValueType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TMetatypeType`, if possible. */ TMetatypeType convertMetatypeTypeFromRaw(Raw::Element e) { result = TMetatypeType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TModuleType`, if possible. */ TModuleType convertModuleTypeFromRaw(Raw::Element e) { result = TModuleType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOpaqueTypeArchetypeType`, if possible. */ TOpaqueTypeArchetypeType convertOpaqueTypeArchetypeTypeFromRaw(Raw::Element e) { @@ -3083,12 +3327,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TOptionalType`, if possible. */ TOptionalType convertOptionalTypeFromRaw(Raw::Element e) { result = TOptionalType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackArchetypeType`, if possible. */ TPackArchetypeType convertPackArchetypeTypeFromRaw(Raw::Element e) { @@ -3097,12 +3343,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackElementType`, if possible. */ TPackElementType convertPackElementTypeFromRaw(Raw::Element e) { result = TPackElementType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackExpansionType`, if possible. */ TPackExpansionType convertPackExpansionTypeFromRaw(Raw::Element e) { @@ -3111,12 +3359,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPackType`, if possible. */ TPackType convertPackTypeFromRaw(Raw::Element e) { result = TPackType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParameterizedProtocolType`, if possible. */ TParameterizedProtocolType convertParameterizedProtocolTypeFromRaw(Raw::Element e) { @@ -3125,12 +3375,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TParenType`, if possible. */ TParenType convertParenTypeFromRaw(Raw::Element e) { result = TParenType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TPrimaryArchetypeType`, if possible. */ TPrimaryArchetypeType convertPrimaryArchetypeTypeFromRaw(Raw::Element e) { @@ -3139,6 +3391,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TProtocolCompositionType`, if possible. */ TProtocolCompositionType convertProtocolCompositionTypeFromRaw(Raw::Element e) { @@ -3147,36 +3400,42 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TProtocolType`, if possible. */ TProtocolType convertProtocolTypeFromRaw(Raw::Element e) { result = TProtocolType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TStructType`, if possible. */ TStructType convertStructTypeFromRaw(Raw::Element e) { result = TStructType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTupleType`, if possible. */ TTupleType convertTupleTypeFromRaw(Raw::Element e) { result = TTupleType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeAliasType`, if possible. */ TTypeAliasType convertTypeAliasTypeFromRaw(Raw::Element e) { result = TTypeAliasType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TTypeRepr`, if possible. */ TTypeRepr convertTypeReprFromRaw(Raw::Element e) { result = TTypeRepr(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnboundGenericType`, if possible. */ TUnboundGenericType convertUnboundGenericTypeFromRaw(Raw::Element e) { @@ -3185,6 +3444,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnmanagedStorageType`, if possible. */ TUnmanagedStorageType convertUnmanagedStorageTypeFromRaw(Raw::Element e) { @@ -3193,6 +3453,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnownedStorageType`, if possible. */ TUnownedStorageType convertUnownedStorageTypeFromRaw(Raw::Element e) { @@ -3201,12 +3462,14 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TUnresolvedType`, if possible. */ TUnresolvedType convertUnresolvedTypeFromRaw(Raw::Element e) { result = TUnresolvedType(e) } /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TVariadicSequenceType`, if possible. */ TVariadicSequenceType convertVariadicSequenceTypeFromRaw(Raw::Element e) { @@ -3215,6 +3478,7 @@ module Synth { /** * INTERNAL: Do not use. + * * Converts a raw element to a synthesized `TWeakStorageType`, if possible. */ TWeakStorageType convertWeakStorageTypeFromRaw(Raw::Element e) { result = TWeakStorageType(e) }