From a3e250aef5a483e129a6487bef42072f8348bcee Mon Sep 17 00:00:00 2001 From: Robert Marsh Date: Fri, 8 Sep 2023 19:08:57 +0000 Subject: [PATCH] Swift: extract iterator variable for for-in loops --- .../extractor/translators/StmtTranslator.cpp | 3 +- swift/ql/.generated.list | 3 - swift/ql/.gitattributes | 3 - .../internal/ControlFlowGraphImpl.qll | 17 +- .../codeql/swift/generated/ParentChild.qll | 10570 ++++++++-------- swift/ql/lib/codeql/swift/generated/Raw.qll | 2089 ++- .../swift/generated/stmt/ForEachStmt.qll | 87 +- swift/ql/lib/swift.dbscheme | 7 +- .../test/library-tests/ast/PrintAst.expected | 105 +- swift/schema.py | 2 +- 10 files changed, 7002 insertions(+), 5884 deletions(-) diff --git a/swift/extractor/translators/StmtTranslator.cpp b/swift/extractor/translators/StmtTranslator.cpp index f600f59951a..c856e5c0ab1 100644 --- a/swift/extractor/translators/StmtTranslator.cpp +++ b/swift/extractor/translators/StmtTranslator.cpp @@ -73,8 +73,9 @@ codeql::ForEachStmt StmtTranslator::translateForEachStmt(const swift::ForEachStm auto entry = dispatcher.createEntry(stmt); fillLabeledStmt(stmt, entry); entry.body = dispatcher.fetchLabel(stmt.getBody()); - entry.sequence = dispatcher.fetchLabel(stmt.getTypeCheckedSequence()); + // entry.sequence = dispatcher.fetchLabel(stmt.getTypeCheckedSequence()); entry.pattern = dispatcher.fetchLabel(stmt.getPattern()); + entry.iteratorVar = dispatcher.fetchLabel(stmt.getIteratorVar()); entry.where = dispatcher.fetchOptionalLabel(stmt.getWhere()); entry.nextCall = dispatcher.fetchOptionalLabel(stmt.getNextCall()); return entry; diff --git a/swift/ql/.generated.list b/swift/ql/.generated.list index 8b2b65b3cce..9dbe6b1fec6 100644 --- a/swift/ql/.generated.list +++ b/swift/ql/.generated.list @@ -379,10 +379,8 @@ lib/codeql/swift/generated/KeyPathComponent.qll c79c7bc04fc1426992ab472eedc1a20a lib/codeql/swift/generated/Locatable.qll be20967d48a34cdba126fe298606e0adc11697831f097acba9c52a0b7ce9983e 8aa01bc376614abbc3209e25785c72f86c9b4e94bb5f471a4a0677fedaec4f61 lib/codeql/swift/generated/Location.qll c5793987e77812059a28254dadee29bfe9b38153c0399fbb1bf6a2f5c237fdab 6e6d8802b021e36bbaad81845657769dd48a798ea33080ada05e9818a20b38f7 lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5 -lib/codeql/swift/generated/ParentChild.qll 04b2871246a5d9c028de9add03077ee8728a418bd03f72fc2585fedd6b3ab630 03ccfa01fad473385a3fa467e0a784419955a1437fd5e432da3877b0ac369186 lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0 lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 -lib/codeql/swift/generated/Raw.qll a216c5a0fd2331229db65795df7c2380ac51c7bc735c43ca985560183071d646 6afeb64476f461421c9e0958240e9771a543b198d78eb880325a436fd3a51f04 lib/codeql/swift/generated/Synth.qll 551fdf7e4b53f9ee1314d1bb42c2638cf82f45bfa1f40a635dfa7b6072e4418c 9ab178464700a19951fc5285acacda4913addee81515d8e072b3d7055935a814 lib/codeql/swift/generated/SynthConstructors.qll 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 @@ -576,7 +574,6 @@ lib/codeql/swift/generated/stmt/DoCatchStmt.qll b418fdb6d48c2c0d30d11c0b256692af lib/codeql/swift/generated/stmt/DoStmt.qll 582f56113ecc384ee80610ae80e2a040fbe58c56b72c76b6c7da3daaeee739bd 3778445dc2f6173d4182cbda47ca0d0e066d931379ed7da89bb3afd1fda1e81b lib/codeql/swift/generated/stmt/FailStmt.qll d8f5816c51c5027fd6dacc8d9f5ddd21f691c138dfc80c6c79e250402a1fe165 d8f5816c51c5027fd6dacc8d9f5ddd21f691c138dfc80c6c79e250402a1fe165 lib/codeql/swift/generated/stmt/FallthroughStmt.qll aa400a95593395d97b196a78462fb5ab7cad0497b395cdd98885e1593271614d 4df6bfa7d2f4e2b5e5155351e445bb6c710e7c20c82fa3321564b11ef60b086a -lib/codeql/swift/generated/stmt/ForEachStmt.qll 766bdc3ceb4271c2813d4c6dbdd784b6d1d098094aa8caa439868493bad35648 b436469bbb584b35a02a143a3132dd728822e55cc03b041ffc5bb822a863d450 lib/codeql/swift/generated/stmt/GuardStmt.qll f31660bbe32231e310ff3d33dfece761ee7ec888fe74683359f86a3766e7c378 ce1f8279839e0b6311107ea9473871cbcfdc7c12d2368ac55b989f9bff2c5e7c lib/codeql/swift/generated/stmt/IfStmt.qll 80f1caba3a477e589b6aa3543ec1787005ab1ffab91a77832512c79dffce48c7 2126cf386e917a230175ba7e07450e390b4bd65da6fce1af8395e5ffd3f79dca lib/codeql/swift/generated/stmt/LabeledConditionalStmt.qll 057c6c556ecd836ca7f40d208c04e43039dde53e41eb27cc27f5f502a38a86fa 2ee979a35e0e9fa72253ab21d57c18b7268b7acc1edb4ec514b73b99b0aa2c6c diff --git a/swift/ql/.gitattributes b/swift/ql/.gitattributes index 0826b0e6966..efdce022ec4 100644 --- a/swift/ql/.gitattributes +++ b/swift/ql/.gitattributes @@ -381,10 +381,8 @@ /lib/codeql/swift/generated/Locatable.qll linguist-generated /lib/codeql/swift/generated/Location.qll linguist-generated /lib/codeql/swift/generated/OtherAvailabilitySpec.qll linguist-generated -/lib/codeql/swift/generated/ParentChild.qll linguist-generated /lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll linguist-generated /lib/codeql/swift/generated/PureSynthConstructors.qll linguist-generated -/lib/codeql/swift/generated/Raw.qll linguist-generated /lib/codeql/swift/generated/Synth.qll linguist-generated /lib/codeql/swift/generated/SynthConstructors.qll linguist-generated /lib/codeql/swift/generated/UnknownFile.qll linguist-generated @@ -578,7 +576,6 @@ /lib/codeql/swift/generated/stmt/DoStmt.qll linguist-generated /lib/codeql/swift/generated/stmt/FailStmt.qll linguist-generated /lib/codeql/swift/generated/stmt/FallthroughStmt.qll linguist-generated -/lib/codeql/swift/generated/stmt/ForEachStmt.qll linguist-generated /lib/codeql/swift/generated/stmt/GuardStmt.qll linguist-generated /lib/codeql/swift/generated/stmt/IfStmt.qll linguist-generated /lib/codeql/swift/generated/stmt/LabeledConditionalStmt.qll linguist-generated diff --git a/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll b/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll index 570e1882261..f13d66b0425 100644 --- a/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll +++ b/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll @@ -486,7 +486,9 @@ module Stmts { override ForEachStmt ast; final override predicate propagatesAbnormal(ControlFlowElement child) { - child.asAstNode() = ast.getSequence().getFullyConverted() + child.asAstNode() = ast.getIteratorVar() + or + child.asAstNode() = ast.getNextCall() or child.asAstNode() = ast.getPattern().getFullyUnresolved() } @@ -495,7 +497,7 @@ module Stmts { // Unlike most other statements, `foreach` statements are not modeled in // pre-order, because we use the `foreach` node itself to represent the // emptiness test that determines whether to execute the loop body - astFirst(ast.getSequence().getFullyConverted(), first) + astFirst(ast.getIteratorVar(), first) } final override predicate last(ControlFlowElement last, Completion c) { @@ -518,8 +520,13 @@ module Stmts { } override predicate succ(ControlFlowElement pred, ControlFlowElement succ, Completion c) { - // Flow from last element of iterator expression to emptiness test - astLast(ast.getSequence().getFullyConverted(), pred, c) and + // Flow from last element of iterator expression to first element of iterator call + astLast(ast.getIteratorVar(), pred, c) and + c instanceof NormalCompletion and + astFirst(ast.getNextCall(), succ) + or + // Flow from iterator call to emptiness test + astLast(ast.getNextCall(), pred, c) and c instanceof NormalCompletion and succ.asAstNode() = ast or @@ -555,7 +562,7 @@ module Stmts { // Flow from last element of loop body back to emptiness test. astLast(ast.getBody(), pred, c) and c.continuesLoop(ast) and - succ.asAstNode() = ast + astFirst(ast.getNextCall(), succ) } } } diff --git a/swift/ql/lib/codeql/swift/generated/ParentChild.qll b/swift/ql/lib/codeql/swift/generated/ParentChild.qll index 2ae9729f1ce..b38c8b8d04d 100644 --- a/swift/ql/lib/codeql/swift/generated/ParentChild.qll +++ b/swift/ql/lib/codeql/swift/generated/ParentChild.qll @@ -1,4 +1,5 @@ // generated by codegen/codegen.py + import codeql.swift.elements import codeql.swift.elements.decl.AccessorOrNamedFunction import codeql.swift.elements.expr.DotSyntaxCallExpr @@ -6,5313 +7,5292 @@ import codeql.swift.elements.expr.InitializerRefCallExpr import codeql.swift.elements.expr.SelfApplyExpr private module Impl { - private Element getImmediateChildOfElement(Element e, int index, string partialPredicateCall) { + private Element getImmediateChildOfElement(Element e, int index, string partialPredicateCall) { none() - } + } + + private Element getImmediateChildOfCallable(Callable e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n, int nSelfParam, int nParam, int nBody, int nCapture | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and + nSelfParam = n + 1 + and + nParam = nSelfParam + 1+ max(int i | i = -1 or exists(e.getParam(i)) | i) + and + nBody = nParam + 1 + and + nCapture = nBody + 1+ max(int i | i = -1 or exists(e.getCapture(i)) | i) + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + or + index = n and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" + )) + } + + private Element getImmediateChildOfFile(File e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLocatable(Locatable e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLocation(Location e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAstNode(AstNode e, int index, string partialPredicateCall) { + + exists(int b, int bLocatable, int n | + b = 0 + and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) + and + n = bLocatable + and ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfComment(Comment e, int index, string partialPredicateCall) { + + exists(int b, int bLocatable, int n | + b = 0 + and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) + and + n = bLocatable + and ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDbFile(DbFile e, int index, string partialPredicateCall) { + + exists(int b, int bFile, int n | + b = 0 + and + bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) + and + n = bFile + and ( + none() + or + result = getImmediateChildOfFile(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDbLocation(DbLocation e, int index, string partialPredicateCall) { + + exists(int b, int bLocation, int n | + b = 0 + and + bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) + and + n = bLocation + and ( + none() + or + result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDiagnostics(Diagnostics e, int index, string partialPredicateCall) { + + exists(int b, int bLocatable, int n | + b = 0 + and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) + and + n = bLocatable + and ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfErrorElement(ErrorElement e, int index, string partialPredicateCall) { + + exists(int b, int bLocatable, int n | + b = 0 + and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) + and + n = bLocatable + and ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnknownFile(UnknownFile e, int index, string partialPredicateCall) { + + exists(int b, int bFile, int n | + b = 0 + and + bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) + and + n = bFile + and ( + none() + or + result = getImmediateChildOfFile(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnknownLocation(UnknownLocation e, int index, string partialPredicateCall) { + + exists(int b, int bLocation, int n | + b = 0 + and + bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) + and + n = bLocation + and ( + none() + or + result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAvailabilityInfo(AvailabilityInfo e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nSpec | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nSpec = n + 1+ max(int i | i = -1 or exists(e.getSpec(i)) | i) + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + result = e.getSpec(index - n) and partialPredicateCall = "Spec(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfAvailabilitySpec(AvailabilitySpec e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfKeyPathComponent(KeyPathComponent e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nSubscriptArgument | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nSubscriptArgument = n + 1+ max(int i | i = -1 or exists(e.getSubscriptArgument(i)) | i) + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + result = e.getSubscriptArgument(index - n) and partialPredicateCall = "SubscriptArgument(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfUnspecifiedElement(UnspecifiedElement e, int index, string partialPredicateCall) { + + exists(int b, int bErrorElement, int n | + b = 0 + and + bErrorElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfErrorElement(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOtherAvailabilitySpec(OtherAvailabilitySpec e, int index, string partialPredicateCall) { + + exists(int b, int bAvailabilitySpec, int n | + b = 0 + and + bAvailabilitySpec = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) + and + n = bAvailabilitySpec + and ( + none() + or + result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPlatformVersionAvailabilitySpec(PlatformVersionAvailabilitySpec e, int index, string partialPredicateCall) { + + exists(int b, int bAvailabilitySpec, int n | + b = 0 + and + bAvailabilitySpec = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) + and + n = bAvailabilitySpec + and ( + none() + or + result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDecl(Decl e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nMember | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nMember = n + 1+ max(int i | i = -1 or exists(e.getMember(i)) | i) + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + result = e.getMember(index - n) and partialPredicateCall = "Member(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfGenericContext(GenericContext e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n, int nGenericTypeParam | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and + nGenericTypeParam = n + 1+ max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + or + result = e.getGenericTypeParam(index - n) and partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfCapturedDecl(CapturedDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfEnumCaseDecl(EnumCaseDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExtensionDecl(ExtensionDecl e, int index, string partialPredicateCall) { + + exists(int b, int bGenericContext, int bDecl, int n | + b = 0 + and + bGenericContext = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) + and + bDecl = bGenericContext + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfDecl(e, index - bGenericContext, partialPredicateCall) + )) + } + + private Element getImmediateChildOfIfConfigDecl(IfConfigDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfImportDecl(ImportDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMissingMemberDecl(MissingMemberDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOperatorDecl(OperatorDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPatternBindingDecl(PatternBindingDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n, int nInit, int nPattern | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and + nInit = n + 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 ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + or + result = e.getImmediateInit(index - n) and partialPredicateCall = "Init(" + (index - n).toString() + ")" + or + result = e.getImmediatePattern(index - nInit) and partialPredicateCall = "Pattern(" + (index - nInit).toString() + ")" + )) + } + + private Element getImmediateChildOfPoundDiagnosticDecl(PoundDiagnosticDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n, int nMessage | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and + nMessage = n + 1 + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateMessage() and partialPredicateCall = "Message()" + )) + } + + private Element getImmediateChildOfPrecedenceGroupDecl(PrecedenceGroupDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTopLevelCodeDecl(TopLevelCodeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n, int nBody | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and + nBody = n + 1 + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfValueDecl(ValueDecl e, int index, string partialPredicateCall) { + + exists(int b, int bDecl, int n | + b = 0 + and + bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) + and + n = bDecl + and ( + none() + or + result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAbstractStorageDecl(AbstractStorageDecl e, int index, string partialPredicateCall) { + + exists(int b, int bValueDecl, int n, int nAccessor | + b = 0 + and + bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) + and + n = bValueDecl + and + nAccessor = n + 1+ max(int i | i = -1 or exists(e.getAccessor(i)) | i) + and ( + none() + or + result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) + or + result = e.getAccessor(index - n) and partialPredicateCall = "Accessor(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfEnumElementDecl(EnumElementDecl e, int index, string partialPredicateCall) { + + exists(int b, int bValueDecl, int n, int nParam | + b = 0 + and + bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) + and + n = bValueDecl + and + nParam = n + 1+ max(int i | i = -1 or exists(e.getParam(i)) | i) + and ( + none() + or + result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) + or + result = e.getParam(index - n) and partialPredicateCall = "Param(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) { + + exists(int b, int bGenericContext, int bValueDecl, int bCallable, int n | + b = 0 + and + bGenericContext = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) + and + bValueDecl = bGenericContext + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) + and + bCallable = bValueDecl + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) + and + n = bCallable + and ( + none() + or + result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfValueDecl(e, index - bGenericContext, partialPredicateCall) + or + result = getImmediateChildOfCallable(e, index - bValueDecl, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInfixOperatorDecl(InfixOperatorDecl e, int index, string partialPredicateCall) { + + exists(int b, int bOperatorDecl, int n | + b = 0 + and + bOperatorDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) + and + n = bOperatorDecl + and ( + none() + or + result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPostfixOperatorDecl(PostfixOperatorDecl e, int index, string partialPredicateCall) { + + exists(int b, int bOperatorDecl, int n | + b = 0 + and + bOperatorDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) + and + n = bOperatorDecl + and ( + none() + or + result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPrefixOperatorDecl(PrefixOperatorDecl e, int index, string partialPredicateCall) { + + exists(int b, int bOperatorDecl, int n | + b = 0 + and + bOperatorDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) + and + n = bOperatorDecl + and ( + none() + or + result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTypeDecl(TypeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bValueDecl, int n | + b = 0 + and + bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) + and + n = bValueDecl + and ( + none() + or + result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAbstractTypeParamDecl(AbstractTypeParamDecl e, int index, string partialPredicateCall) { + + exists(int b, int bTypeDecl, int n | + b = 0 + and + bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) + and + n = bTypeDecl + and ( + none() + or + result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAccessorOrNamedFunction(AccessorOrNamedFunction e, int index, string partialPredicateCall) { + + exists(int b, int bFunction, int n | + b = 0 + and + bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) + and + n = bFunction + and ( + none() + or + result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDeinitializer(Deinitializer e, int index, string partialPredicateCall) { + + exists(int b, int bFunction, int n | + b = 0 + and + bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) + and + n = bFunction + and ( + none() + or + result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfGenericTypeDecl(GenericTypeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bGenericContext, int bTypeDecl, int n | + b = 0 + and + bGenericContext = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) + and + bTypeDecl = bGenericContext + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) + and + n = bTypeDecl + and ( + none() + or + result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfTypeDecl(e, index - bGenericContext, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInitializer(Initializer e, int index, string partialPredicateCall) { + + exists(int b, int bFunction, int n | + b = 0 + and + bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) + and + n = bFunction + and ( + none() + or + result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index, string partialPredicateCall) { + + exists(int b, int bTypeDecl, int n | + b = 0 + and + bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) + and + n = bTypeDecl + and ( + none() + or + result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSubscriptDecl(SubscriptDecl e, int index, string partialPredicateCall) { + + exists(int b, int bAbstractStorageDecl, int bGenericContext, int n, int nParam | + b = 0 + and + bAbstractStorageDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) + and + bGenericContext = bAbstractStorageDecl + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) + and + n = bGenericContext + and + nParam = n + 1+ max(int i | i = -1 or exists(e.getParam(i)) | i) + and ( + none() + or + result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfGenericContext(e, index - bAbstractStorageDecl, partialPredicateCall) + or + result = e.getParam(index - n) and partialPredicateCall = "Param(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfVarDecl(VarDecl e, int index, string partialPredicateCall) { + + exists(int b, int bAbstractStorageDecl, int n, int nPropertyWrapperBackingVarBinding, int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, int nPropertyWrapperProjectionVar | + b = 0 + and + bAbstractStorageDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) + and + n = bAbstractStorageDecl + and + nPropertyWrapperBackingVarBinding = n + 1 + and + nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 + and + nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 + and + nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 + and ( + none() + or + result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) + or + index = n and result = e.getPropertyWrapperBackingVarBinding() and partialPredicateCall = "PropertyWrapperBackingVarBinding()" + or + index = nPropertyWrapperBackingVarBinding and result = e.getPropertyWrapperBackingVar() and partialPredicateCall = "PropertyWrapperBackingVar()" + or + index = nPropertyWrapperBackingVar and result = e.getPropertyWrapperProjectionVarBinding() and partialPredicateCall = "PropertyWrapperProjectionVarBinding()" + or + index = nPropertyWrapperProjectionVarBinding and result = e.getPropertyWrapperProjectionVar() and partialPredicateCall = "PropertyWrapperProjectionVar()" + )) + } + + private Element getImmediateChildOfAccessor(Accessor e, int index, string partialPredicateCall) { + + exists(int b, int bAccessorOrNamedFunction, int n | + b = 0 + and + bAccessorOrNamedFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) + and + n = bAccessorOrNamedFunction + and ( + none() + or + result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAssociatedTypeDecl(AssociatedTypeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bAbstractTypeParamDecl, int n | + b = 0 + and + bAbstractTypeParamDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) + and + n = bAbstractTypeParamDecl + and ( + none() + or + result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfConcreteVarDecl(ConcreteVarDecl e, int index, string partialPredicateCall) { + + exists(int b, int bVarDecl, int n | + b = 0 + and + bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) + and + n = bVarDecl + and ( + none() + or + result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfGenericTypeParamDecl(GenericTypeParamDecl e, int index, string partialPredicateCall) { + + exists(int b, int bAbstractTypeParamDecl, int n | + b = 0 + and + bAbstractTypeParamDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) + and + n = bAbstractTypeParamDecl + and ( + none() + or + result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfNamedFunction(NamedFunction e, int index, string partialPredicateCall) { + + exists(int b, int bAccessorOrNamedFunction, int n | + b = 0 + and + bAccessorOrNamedFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) + and + n = bAccessorOrNamedFunction + and ( + none() + or + result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfNominalTypeDecl(NominalTypeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bGenericTypeDecl, int n | + b = 0 + and + bGenericTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) + and + n = bGenericTypeDecl + and ( + none() + or + result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOpaqueTypeDecl(OpaqueTypeDecl e, int index, string partialPredicateCall) { + + exists(int b, int bGenericTypeDecl, int n | + b = 0 + and + bGenericTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) + and + n = bGenericTypeDecl + and ( + none() + or + result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfParamDecl(ParamDecl e, int index, string partialPredicateCall) { + + exists(int b, int bVarDecl, int n, int nPropertyWrapperLocalWrappedVarBinding, int nPropertyWrapperLocalWrappedVar | + b = 0 + and + bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) + and + n = bVarDecl + and + nPropertyWrapperLocalWrappedVarBinding = n + 1 + and + nPropertyWrapperLocalWrappedVar = nPropertyWrapperLocalWrappedVarBinding + 1 + and ( + none() + or + result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) + or + index = n and result = e.getPropertyWrapperLocalWrappedVarBinding() and partialPredicateCall = "PropertyWrapperLocalWrappedVarBinding()" + or + index = nPropertyWrapperLocalWrappedVarBinding and result = e.getPropertyWrapperLocalWrappedVar() and partialPredicateCall = "PropertyWrapperLocalWrappedVar()" + )) + } + + private Element getImmediateChildOfTypeAliasDecl(TypeAliasDecl e, int index, string partialPredicateCall) { + + exists(int b, int bGenericTypeDecl, int n | + b = 0 + and + bGenericTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) + and + n = bGenericTypeDecl + and ( + none() + or + result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfClassDecl(ClassDecl e, int index, string partialPredicateCall) { + + exists(int b, int bNominalTypeDecl, int n | + b = 0 + and + bNominalTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) + and + n = bNominalTypeDecl + and ( + none() + or + result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfEnumDecl(EnumDecl e, int index, string partialPredicateCall) { + + exists(int b, int bNominalTypeDecl, int n | + b = 0 + and + bNominalTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) + and + n = bNominalTypeDecl + and ( + none() + or + result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfProtocolDecl(ProtocolDecl e, int index, string partialPredicateCall) { + + exists(int b, int bNominalTypeDecl, int n | + b = 0 + and + bNominalTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) + and + n = bNominalTypeDecl + and ( + none() + or + result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfStructDecl(StructDecl e, int index, string partialPredicateCall) { + + exists(int b, int bNominalTypeDecl, int n | + b = 0 + and + bNominalTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) + and + n = bNominalTypeDecl + and ( + none() + or + result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfArgument(Argument e, int index, string partialPredicateCall) { + + exists(int b, int bLocatable, int n, int nExpr | + b = 0 + and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) + and + n = bLocatable + and + nExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" + )) + } + + private Element getImmediateChildOfExpr(Expr e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyTryExpr(AnyTryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfAppliedPropertyWrapperExpr(AppliedPropertyWrapperExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nValue | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nValue = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateValue() and partialPredicateCall = "Value()" + )) + } + + private Element getImmediateChildOfApplyExpr(ApplyExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nFunction, int nArgument | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nFunction = n + 1 + and + nArgument = nFunction + 1+ max(int i | i = -1 or exists(e.getArgument(i)) | i) + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" + )) + } + + private Element getImmediateChildOfAssignExpr(AssignExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nDest, int nSource | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nDest = n + 1 + and + nSource = nDest + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateDest() and partialPredicateCall = "Dest()" + or + index = nDest and result = e.getImmediateSource() and partialPredicateCall = "Source()" + )) + } + + private Element getImmediateChildOfBindOptionalExpr(BindOptionalExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfCaptureListExpr(CaptureListExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nBindingDecl, int nClosureBody | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nBindingDecl = n + 1+ max(int i | i = -1 or exists(e.getBindingDecl(i)) | i) + and + nClosureBody = nBindingDecl + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getBindingDecl(index - n) and partialPredicateCall = "BindingDecl(" + (index - n).toString() + ")" + or + index = nBindingDecl and result = e.getImmediateClosureBody() and partialPredicateCall = "ClosureBody()" + )) + } + + private Element getImmediateChildOfClosureExpr(ClosureExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bCallable, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bCallable = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) + and + n = bCallable + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfCallable(e, index - bExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCollectionExpr(CollectionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDeclRefExpr(DeclRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDefaultArgumentExpr(DefaultArgumentExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDiscardAssignmentExpr(DiscardAssignmentExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDotSyntaxBaseIgnoredExpr(DotSyntaxBaseIgnoredExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nQualifier, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nQualifier = n + 1 + and + nSubExpr = nQualifier + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateQualifier() and partialPredicateCall = "Qualifier()" + or + index = nQualifier and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfDynamicTypeExpr(DynamicTypeExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nBase | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nBase = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" + )) + } + + private Element getImmediateChildOfEnumIsCaseExpr(EnumIsCaseExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfErrorExpr(ErrorExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExplicitCastExpr(ExplicitCastExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfForceValueExpr(ForceValueExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfIdentityExpr(IdentityExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nCondition, int nThenExpr, int nElseExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nCondition = n + 1 + and + nThenExpr = nCondition + 1 + and + nElseExpr = nThenExpr + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" + or + index = nCondition and result = e.getImmediateThenExpr() and partialPredicateCall = "ThenExpr()" + or + index = nThenExpr and result = e.getImmediateElseExpr() and partialPredicateCall = "ElseExpr()" + )) + } + + private Element getImmediateChildOfImplicitConversionExpr(ImplicitConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfInOutExpr(InOutExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfKeyPathApplicationExpr(KeyPathApplicationExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nBase, int nKeyPath | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nBase = n + 1 + and + nKeyPath = nBase + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" + or + index = nBase and result = e.getImmediateKeyPath() and partialPredicateCall = "KeyPath()" + )) + } + + private Element getImmediateChildOfKeyPathDotExpr(KeyPathDotExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfKeyPathExpr(KeyPathExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nRoot, int nComponent | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nRoot = n + 1 + and + nComponent = nRoot + 1+ max(int i | i = -1 or exists(e.getComponent(i)) | i) + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getRoot() and partialPredicateCall = "Root()" + or + result = e.getComponent(index - nRoot) and partialPredicateCall = "Component(" + (index - nRoot).toString() + ")" + )) + } + + private Element getImmediateChildOfLazyInitializationExpr(LazyInitializationExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfLiteralExpr(LiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLookupExpr(LookupExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nBase | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nBase = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" + )) + } + + private Element getImmediateChildOfMakeTemporarilyEscapableExpr(MakeTemporarilyEscapableExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nEscapingClosure, int nNonescapingClosure, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nEscapingClosure = n + 1 + and + nNonescapingClosure = nEscapingClosure + 1 + and + nSubExpr = nNonescapingClosure + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateEscapingClosure() and partialPredicateCall = "EscapingClosure()" + or + index = nEscapingClosure and result = e.getImmediateNonescapingClosure() and partialPredicateCall = "NonescapingClosure()" + or + index = nNonescapingClosure and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfObjCSelectorExpr(ObjCSelectorExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfOneWayExpr(OneWayExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfOpaqueValueExpr(OpaqueValueExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOpenExistentialExpr(OpenExistentialExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr, int nExistential | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and + nExistential = nSubExpr + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + or + index = nSubExpr and result = e.getImmediateExistential() and partialPredicateCall = "Existential()" + )) + } + + private Element getImmediateChildOfOptionalEvaluationExpr(OptionalEvaluationExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfOtherInitializerRefExpr(OtherInitializerRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOverloadedDeclRefExpr(OverloadedDeclRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPropertyWrapperValuePlaceholderExpr(PropertyWrapperValuePlaceholderExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfRebindSelfInInitializerExpr(RebindSelfInInitializerExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfSequenceExpr(SequenceExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nElement | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfSuperRefExpr(SuperRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTapExpr(TapExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr, int nBody | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and + nBody = nSubExpr + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + or + index = nSubExpr and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfTupleElementExpr(TupleElementExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nElement | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfTypeExpr(TypeExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nTypeRepr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nTypeRepr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" + )) + } + + private Element getImmediateChildOfUnresolvedDeclRefExpr(UnresolvedDeclRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnresolvedDotExpr(UnresolvedDotExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n, int nBase | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and + nBase = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + or + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" + )) + } + + private Element getImmediateChildOfUnresolvedMemberExpr(UnresolvedMemberExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnresolvedPatternExpr(UnresolvedPatternExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n, int nSubPattern | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and + nSubPattern = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfUnresolvedSpecializeExpr(UnresolvedSpecializeExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int bErrorElement, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + bErrorElement = bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfVarargExpansionExpr(VarargExpansionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExpr, int n, int nSubExpr | + b = 0 + and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) + and + n = bExpr + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfAbiSafeConversionExpr(AbiSafeConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyHashableErasureExpr(AnyHashableErasureExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfArchetypeToSuperExpr(ArchetypeToSuperExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { + + exists(int b, int bCollectionExpr, int n, int nElement | + b = 0 + and + bCollectionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) + and + n = bCollectionExpr + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) + or + result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfArrayToPointerExpr(ArrayToPointerExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAutoClosureExpr(AutoClosureExpr e, int index, string partialPredicateCall) { + + exists(int b, int bClosureExpr, int n | + b = 0 + and + bClosureExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) + and + n = bClosureExpr + and ( + none() + or + result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { + + exists(int b, int bIdentityExpr, int n | + b = 0 + and + bIdentityExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) + and + n = bIdentityExpr + and ( + none() + or + result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bApplyExpr, int n | + b = 0 + and + bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) + and + n = bApplyExpr + and ( + none() + or + result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBridgeFromObjCExpr(BridgeFromObjCExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBridgeToObjCExpr(BridgeToObjCExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinLiteralExpr(BuiltinLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLiteralExpr, int n | + b = 0 + and + bLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) + and + n = bLiteralExpr + and ( + none() + or + result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { + + exists(int b, int bApplyExpr, int n | + b = 0 + and + bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) + and + n = bApplyExpr + and ( + none() + or + result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCheckedCastExpr(CheckedCastExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExplicitCastExpr, int n | + b = 0 + and + bExplicitCastExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) + and + n = bExplicitCastExpr + and ( + none() + or + result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfClassMetatypeToObjectExpr(ClassMetatypeToObjectExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCoerceExpr(CoerceExpr e, int index, string partialPredicateCall) { + + exists(int b, int bExplicitCastExpr, int n | + b = 0 + and + bExplicitCastExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) + and + n = bExplicitCastExpr + and ( + none() + or + result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCollectionUpcastConversionExpr(CollectionUpcastConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfConditionalBridgeFromObjCExpr(ConditionalBridgeFromObjCExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCovariantFunctionConversionExpr(CovariantFunctionConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCovariantReturnConversionExpr(CovariantReturnConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDerivedToBaseExpr(DerivedToBaseExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDestructureTupleExpr(DestructureTupleExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDictionaryExpr(DictionaryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bCollectionExpr, int n, int nElement | + b = 0 + and + bCollectionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) + and + n = bCollectionExpr + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) + or + result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfDifferentiableFunctionExpr(DifferentiableFunctionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDifferentiableFunctionExtractOriginalExpr(DifferentiableFunctionExtractOriginalExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDotSelfExpr(DotSelfExpr e, int index, string partialPredicateCall) { + + exists(int b, int bIdentityExpr, int n | + b = 0 + and + bIdentityExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) + and + n = bIdentityExpr + and ( + none() + or + result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDynamicLookupExpr(DynamicLookupExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLookupExpr, int n | + b = 0 + and + bLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) + and + n = bLookupExpr + and ( + none() + or + result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfErasureExpr(ErasureExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExistentialMetatypeToObjectExpr(ExistentialMetatypeToObjectExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExplicitClosureExpr(ExplicitClosureExpr e, int index, string partialPredicateCall) { + + exists(int b, int bClosureExpr, int n | + b = 0 + and + bClosureExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) + and + n = bClosureExpr + and ( + none() + or + result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfForceTryExpr(ForceTryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bAnyTryExpr, int n | + b = 0 + and + bAnyTryExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) + and + n = bAnyTryExpr + and ( + none() + or + result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfForeignObjectConversionExpr(ForeignObjectConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfFunctionConversionExpr(FunctionConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInOutToPointerExpr(InOutToPointerExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInjectIntoOptionalExpr(InjectIntoOptionalExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLiteralExpr, int n, int nAppendingExpr | + b = 0 + and + bLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) + and + n = bLiteralExpr + and + nAppendingExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateAppendingExpr() and partialPredicateCall = "AppendingExpr()" + )) + } + + private Element getImmediateChildOfLinearFunctionExpr(LinearFunctionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLinearFunctionExtractOriginalExpr(LinearFunctionExtractOriginalExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLinearToDifferentiableFunctionExpr(LinearToDifferentiableFunctionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLoadExpr(LoadExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMemberRefExpr(MemberRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLookupExpr, int n | + b = 0 + and + bLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) + and + n = bLookupExpr + and ( + none() + or + result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMetatypeConversionExpr(MetatypeConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMethodLookupExpr(MethodLookupExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLookupExpr, int n, int nMethodRef | + b = 0 + and + bLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) + and + n = bLookupExpr + and + nMethodRef = n + 1 + and ( + none() + or + result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateMethodRef() and partialPredicateCall = "MethodRef()" + )) + } + + private Element getImmediateChildOfNilLiteralExpr(NilLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLiteralExpr, int n | + b = 0 + and + bLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) + and + n = bLiteralExpr + and ( + none() + or + result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfObjectLiteralExpr(ObjectLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLiteralExpr, int n, int nArgument | + b = 0 + and + bLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) + and + n = bLiteralExpr + and + nArgument = n + 1+ max(int i | i = -1 or exists(e.getArgument(i)) | i) + and ( + none() + or + result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + or + result = e.getArgument(index - n) and partialPredicateCall = "Argument(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfOptionalTryExpr(OptionalTryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bAnyTryExpr, int n | + b = 0 + and + bAnyTryExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) + and + n = bAnyTryExpr + and ( + none() + or + result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { + + exists(int b, int bIdentityExpr, int n | + b = 0 + and + bIdentityExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) + and + n = bIdentityExpr + and ( + none() + or + result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPointerToPointerExpr(PointerToPointerExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPostfixUnaryExpr(PostfixUnaryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bApplyExpr, int n | + b = 0 + and + bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) + and + n = bApplyExpr + and ( + none() + or + result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPrefixUnaryExpr(PrefixUnaryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bApplyExpr, int n | + b = 0 + and + bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) + and + n = bApplyExpr + and ( + none() + or + result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfProtocolMetatypeToObjectExpr(ProtocolMetatypeToObjectExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfRegexLiteralExpr(RegexLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLiteralExpr, int n | + b = 0 + and + bLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) + and + n = bLiteralExpr + and ( + none() + or + result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSelfApplyExpr(SelfApplyExpr e, int index, string partialPredicateCall) { + + exists(int b, int bApplyExpr, int n | + b = 0 + and + bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) + and + n = bApplyExpr + and ( + none() + or + result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfStringToPointerExpr(StringToPointerExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSubscriptExpr(SubscriptExpr e, int index, string partialPredicateCall) { + + exists(int b, int bLookupExpr, int n, int nArgument | + b = 0 + and + bLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) + and + n = bLookupExpr + and + nArgument = n + 1+ max(int i | i = -1 or exists(e.getArgument(i)) | i) + and ( + none() + or + result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + or + result = e.getArgument(index - n) and partialPredicateCall = "Argument(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { + + exists(int b, int bAnyTryExpr, int n | + b = 0 + and + bAnyTryExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) + and + n = bAnyTryExpr + and ( + none() + or + result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnderlyingToOpaqueExpr(UnderlyingToOpaqueExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnevaluatedInstanceExpr(UnevaluatedInstanceExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + n = bImplicitConversionExpr + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnresolvedMemberChainResultExpr(UnresolvedMemberChainResultExpr e, int index, string partialPredicateCall) { + + exists(int b, int bIdentityExpr, int bErrorElement, int n | + b = 0 + and + bIdentityExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) + and + bErrorElement = bIdentityExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bIdentityExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnresolvedTypeConversionExpr(UnresolvedTypeConversionExpr e, int index, string partialPredicateCall) { + + exists(int b, int bImplicitConversionExpr, int bErrorElement, int n | + b = 0 + and + bImplicitConversionExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) + and + bErrorElement = bImplicitConversionExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bImplicitConversionExpr, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBooleanLiteralExpr(BooleanLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinLiteralExpr, int n | + b = 0 + and + bBuiltinLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) + and + n = bBuiltinLiteralExpr + and ( + none() + or + result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfConditionalCheckedCastExpr(ConditionalCheckedCastExpr e, int index, string partialPredicateCall) { + + exists(int b, int bCheckedCastExpr, int n | + b = 0 + and + bCheckedCastExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) + and + n = bCheckedCastExpr + and ( + none() + or + result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDotSyntaxCallExpr(DotSyntaxCallExpr e, int index, string partialPredicateCall) { + + exists(int b, int bSelfApplyExpr, int n | + b = 0 + and + bSelfApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) + and + n = bSelfApplyExpr + and ( + none() + or + result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDynamicMemberRefExpr(DynamicMemberRefExpr e, int index, string partialPredicateCall) { + + exists(int b, int bDynamicLookupExpr, int n | + b = 0 + and + bDynamicLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) + and + n = bDynamicLookupExpr + and ( + none() + or + result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDynamicSubscriptExpr(DynamicSubscriptExpr e, int index, string partialPredicateCall) { + + exists(int b, int bDynamicLookupExpr, int n | + b = 0 + and + bDynamicLookupExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) + and + n = bDynamicLookupExpr + and ( + none() + or + result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfForcedCheckedCastExpr(ForcedCheckedCastExpr e, int index, string partialPredicateCall) { + + exists(int b, int bCheckedCastExpr, int n | + b = 0 + and + bCheckedCastExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) + and + n = bCheckedCastExpr + and ( + none() + or + result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInitializerRefCallExpr(InitializerRefCallExpr e, int index, string partialPredicateCall) { + + exists(int b, int bSelfApplyExpr, int n | + b = 0 + and + bSelfApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) + and + n = bSelfApplyExpr + and ( + none() + or + result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfIsExpr(IsExpr e, int index, string partialPredicateCall) { + + exists(int b, int bCheckedCastExpr, int n | + b = 0 + and + bCheckedCastExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) + and + n = bCheckedCastExpr + and ( + none() + or + result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinLiteralExpr, int n | + b = 0 + and + bBuiltinLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) + and + n = bBuiltinLiteralExpr + and ( + none() + or + result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfNumberLiteralExpr(NumberLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinLiteralExpr, int n | + b = 0 + and + bBuiltinLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) + and + n = bBuiltinLiteralExpr + and ( + none() + or + result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfStringLiteralExpr(StringLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinLiteralExpr, int n | + b = 0 + and + bBuiltinLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) + and + n = bBuiltinLiteralExpr + and ( + none() + or + result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfFloatLiteralExpr(FloatLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bNumberLiteralExpr, int n | + b = 0 + and + bNumberLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) + and + n = bNumberLiteralExpr + and ( + none() + or + result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfIntegerLiteralExpr(IntegerLiteralExpr e, int index, string partialPredicateCall) { + + exists(int b, int bNumberLiteralExpr, int n | + b = 0 + and + bNumberLiteralExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) + and + n = bNumberLiteralExpr + and ( + none() + or + result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPattern(Pattern e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyPattern(AnyPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBindingPattern(BindingPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubPattern | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubPattern = n + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfBoolPattern(BoolPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfEnumElementPattern(EnumElementPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubPattern | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubPattern = n + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfExprPattern(ExprPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubExpr | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfIsPattern(IsPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nCastTypeRepr, int nSubPattern | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nCastTypeRepr = n + 1 + and + nSubPattern = nCastTypeRepr + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getCastTypeRepr() and partialPredicateCall = "CastTypeRepr()" + or + index = nCastTypeRepr and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfNamedPattern(NamedPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOptionalSomePattern(OptionalSomePattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubPattern | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubPattern = n + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfParenPattern(ParenPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubPattern | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubPattern = n + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + )) + } + + private Element getImmediateChildOfTuplePattern(TuplePattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nElement | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfTypedPattern(TypedPattern e, int index, string partialPredicateCall) { + + exists(int b, int bPattern, int n, int nSubPattern, int nTypeRepr | + b = 0 + and + bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) + and + n = bPattern + and + nSubPattern = n + 1 + and + nTypeRepr = nSubPattern + 1 + and ( + none() + or + result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" + or + index = nSubPattern and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" + )) + } + + private Element getImmediateChildOfCaseLabelItem(CaseLabelItem e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nPattern, int nGuard | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nPattern = n + 1 + and + nGuard = nPattern + 1 + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" + or + index = nPattern and result = e.getImmediateGuard() and partialPredicateCall = "Guard()" + )) + } + + private Element getImmediateChildOfConditionElement(ConditionElement e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nBoolean, int nPattern, int nInitializer, int nAvailability | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nBoolean = n + 1 + and + nPattern = nBoolean + 1 + and + nInitializer = nPattern + 1 + and + nAvailability = nInitializer + 1 + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateBoolean() and partialPredicateCall = "Boolean()" + or + index = nBoolean and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" + or + index = nPattern and result = e.getImmediateInitializer() and partialPredicateCall = "Initializer()" + or + index = nInitializer and result = e.getAvailability() and partialPredicateCall = "Availability()" + )) + } + + private Element getImmediateChildOfStmt(Stmt e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfStmtCondition(StmtCondition e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n, int nElement | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and + nElement = n + 1+ max(int i | i = -1 or exists(e.getElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + result = e.getElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfBraceStmt(BraceStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nVariable, int nElement | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nVariable = n + 1+ max(int i | i = -1 or exists(e.getVariable(i)) | i) + and + nElement = nVariable + 1+ max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + result = e.getVariable(index - n) and partialPredicateCall = "Variable(" + (index - n).toString() + ")" + or + result = e.getImmediateElement(index - nVariable) and partialPredicateCall = "Element(" + (index - nVariable).toString() + ")" + )) + } + + private Element getImmediateChildOfBreakStmt(BreakStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfCaseStmt(CaseStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nBody, int nLabel | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nBody = n + 1 + and + nLabel = nBody + 1+ max(int i | i = -1 or exists(e.getLabel(i)) | i) + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getLabel(index - nBody) and partialPredicateCall = "Label(" + (index - nBody).toString() + ")" + )) + } + + private Element getImmediateChildOfContinueStmt(ContinueStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDeferStmt(DeferStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nBody | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nBody = n + 1 + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfFailStmt(FailStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfFallthroughStmt(FallthroughStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLabeledStmt(LabeledStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPoundAssertStmt(PoundAssertStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfReturnStmt(ReturnStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nResult | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nResult = n + 1 + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateResult() and partialPredicateCall = "Result()" + )) + } + + private Element getImmediateChildOfThrowStmt(ThrowStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nSubExpr | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nSubExpr = n + 1 + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" + )) + } + + private Element getImmediateChildOfYieldStmt(YieldStmt e, int index, string partialPredicateCall) { + + exists(int b, int bStmt, int n, int nResult | + b = 0 + and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) + and + n = bStmt + and + nResult = n + 1+ max(int i | i = -1 or exists(e.getImmediateResult(i)) | i) + and ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + result = e.getImmediateResult(index - n) and partialPredicateCall = "Result(" + (index - n).toString() + ")" + )) + } + + private Element getImmediateChildOfDoCatchStmt(DoCatchStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nBody, int nCatch | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nBody = n + 1 + and + nCatch = nBody + 1+ max(int i | i = -1 or exists(e.getCatch(i)) | i) + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCatch(index - nBody) and partialPredicateCall = "Catch(" + (index - nBody).toString() + ")" + )) + } + + private Element getImmediateChildOfDoStmt(DoStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nBody | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nBody = n + 1 + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfForEachStmt(ForEachStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nPattern, int nWhere, int nIteratorVar, int nNextCall, int nBody | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nPattern = n + 1 + and + nWhere = nPattern + 1 + and + nIteratorVar = nWhere + 1 + and + nNextCall = nIteratorVar + 1 + and + nBody = nNextCall + 1 + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" + or + index = nPattern and result = e.getImmediateWhere() and partialPredicateCall = "Where()" + or + index = nWhere and result = e.getIteratorVar() and partialPredicateCall = "IteratorVar()" + or + index = nIteratorVar and result = e.getImmediateNextCall() and partialPredicateCall = "NextCall()" + or + index = nNextCall and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfLabeledConditionalStmt(LabeledConditionalStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nCondition | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nCondition = n + 1 + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getCondition() and partialPredicateCall = "Condition()" + )) + } + + private Element getImmediateChildOfRepeatWhileStmt(RepeatWhileStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nCondition, int nBody | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nCondition = n + 1 + and + nBody = nCondition + 1 + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" + or + index = nCondition and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfSwitchStmt(SwitchStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledStmt, int n, int nExpr, int nCase | + b = 0 + and + bLabeledStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) + and + n = bLabeledStmt + and + nExpr = n + 1 + and + nCase = nExpr + 1+ max(int i | i = -1 or exists(e.getCase(i)) | i) + and ( + none() + or + result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" + or + result = e.getCase(index - nExpr) and partialPredicateCall = "Case(" + (index - nExpr).toString() + ")" + )) + } + + private Element getImmediateChildOfGuardStmt(GuardStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledConditionalStmt, int n, int nBody | + b = 0 + and + bLabeledConditionalStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) + and + n = bLabeledConditionalStmt + and + nBody = n + 1 + and ( + none() + or + result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfIfStmt(IfStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledConditionalStmt, int n, int nThen, int nElse | + b = 0 + and + bLabeledConditionalStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) + and + n = bLabeledConditionalStmt + and + nThen = n + 1 + and + nElse = nThen + 1 + and ( + none() + or + result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getThen() and partialPredicateCall = "Then()" + or + index = nThen and result = e.getElse() and partialPredicateCall = "Else()" + )) + } + + private Element getImmediateChildOfWhileStmt(WhileStmt e, int index, string partialPredicateCall) { + + exists(int b, int bLabeledConditionalStmt, int n, int nBody | + b = 0 + and + bLabeledConditionalStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) + and + n = bLabeledConditionalStmt + and + nBody = n + 1 + and ( + none() + or + result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + )) + } + + private Element getImmediateChildOfType(Type e, int index, string partialPredicateCall) { + + exists(int b, int bElement, int n | + b = 0 + and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) + and + n = bElement + and ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTypeRepr(TypeRepr e, int index, string partialPredicateCall) { + + exists(int b, int bAstNode, int n | + b = 0 + and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) + and + n = bAstNode + and ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyFunctionType(AnyFunctionType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyGenericType(AnyGenericType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyMetatypeType(AnyMetatypeType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinType(BuiltinType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDependentMemberType(DependentMemberType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDynamicSelfType(DynamicSelfType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfErrorType(ErrorType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int bErrorElement, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + bErrorElement = bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExistentialType(ExistentialType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfInOutType(InOutType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfLValueType(LValueType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfModuleType(ModuleType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfParameterizedProtocolType(ParameterizedProtocolType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfProtocolCompositionType(ProtocolCompositionType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfReferenceStorageType(ReferenceStorageType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSubstitutableType(SubstitutableType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSugarType(SugarType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTupleType(TupleType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + n = bType + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnresolvedType(UnresolvedType e, int index, string partialPredicateCall) { + + exists(int b, int bType, int bErrorElement, int n | + b = 0 + and + bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) + and + bErrorElement = bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) + and + n = bErrorElement + and ( + none() + or + result = getImmediateChildOfType(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) + )) + } + + private Element getImmediateChildOfAnyBuiltinIntegerType(AnyBuiltinIntegerType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfArchetypeType(ArchetypeType e, int index, string partialPredicateCall) { + + exists(int b, int bSubstitutableType, int n | + b = 0 + and + bSubstitutableType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) + and + n = bSubstitutableType + and ( + none() + or + result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinBridgeObjectType(BuiltinBridgeObjectType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinDefaultActorStorageType(BuiltinDefaultActorStorageType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinExecutorType(BuiltinExecutorType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinFloatType(BuiltinFloatType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinJobType(BuiltinJobType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinNativeObjectType(BuiltinNativeObjectType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinRawPointerType(BuiltinRawPointerType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinRawUnsafeContinuationType(BuiltinRawUnsafeContinuationType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinUnsafeValueBufferType(BuiltinUnsafeValueBufferType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinVectorType(BuiltinVectorType e, int index, string partialPredicateCall) { + + exists(int b, int bBuiltinType, int n | + b = 0 + and + bBuiltinType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) + and + n = bBuiltinType + and ( + none() + or + result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfExistentialMetatypeType(ExistentialMetatypeType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyMetatypeType, int n | + b = 0 + and + bAnyMetatypeType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) + and + n = bAnyMetatypeType + and ( + none() + or + result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfFunctionType(FunctionType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyFunctionType, int n | + b = 0 + and + bAnyFunctionType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) + and + n = bAnyFunctionType + and ( + none() + or + result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfGenericFunctionType(GenericFunctionType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyFunctionType, int n | + b = 0 + and + bAnyFunctionType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) + and + n = bAnyFunctionType + and ( + none() + or + result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfGenericTypeParamType(GenericTypeParamType e, int index, string partialPredicateCall) { + + exists(int b, int bSubstitutableType, int n | + b = 0 + and + bSubstitutableType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) + and + n = bSubstitutableType + and ( + none() + or + result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfMetatypeType(MetatypeType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyMetatypeType, int n | + b = 0 + and + bAnyMetatypeType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) + and + n = bAnyMetatypeType + and ( + none() + or + result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfNominalOrBoundGenericNominalType(NominalOrBoundGenericNominalType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyGenericType, int n | + b = 0 + and + bAnyGenericType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) + and + n = bAnyGenericType + and ( + none() + or + result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfParenType(ParenType e, int index, string partialPredicateCall) { + + exists(int b, int bSugarType, int n | + b = 0 + and + bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) + and + n = bSugarType + and ( + none() + or + result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfSyntaxSugarType(SyntaxSugarType e, int index, string partialPredicateCall) { + + exists(int b, int bSugarType, int n | + b = 0 + and + bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) + and + n = bSugarType + and ( + none() + or + result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfTypeAliasType(TypeAliasType e, int index, string partialPredicateCall) { + + exists(int b, int bSugarType, int n | + b = 0 + and + bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) + and + n = bSugarType + and ( + none() + or + result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnboundGenericType(UnboundGenericType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyGenericType, int n | + b = 0 + and + bAnyGenericType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) + and + n = bAnyGenericType + and ( + none() + or + result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnmanagedStorageType(UnmanagedStorageType e, int index, string partialPredicateCall) { + + exists(int b, int bReferenceStorageType, int n | + b = 0 + and + bReferenceStorageType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) + and + n = bReferenceStorageType + and ( + none() + or + result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnownedStorageType(UnownedStorageType e, int index, string partialPredicateCall) { + + exists(int b, int bReferenceStorageType, int n | + b = 0 + and + bReferenceStorageType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) + and + n = bReferenceStorageType + and ( + none() + or + result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfWeakStorageType(WeakStorageType e, int index, string partialPredicateCall) { + + exists(int b, int bReferenceStorageType, int n | + b = 0 + and + bReferenceStorageType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) + and + n = bReferenceStorageType + and ( + none() + or + result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBoundGenericType(BoundGenericType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalOrBoundGenericNominalType, int n | + b = 0 + and + bNominalOrBoundGenericNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) | i) + and + n = bNominalOrBoundGenericNominalType + and ( + none() + or + result = getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinIntegerLiteralType(BuiltinIntegerLiteralType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyBuiltinIntegerType, int n | + b = 0 + and + bAnyBuiltinIntegerType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) + and + n = bAnyBuiltinIntegerType + and ( + none() + or + result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBuiltinIntegerType(BuiltinIntegerType e, int index, string partialPredicateCall) { + + exists(int b, int bAnyBuiltinIntegerType, int n | + b = 0 + and + bAnyBuiltinIntegerType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) + and + n = bAnyBuiltinIntegerType + and ( + none() + or + result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfDictionaryType(DictionaryType e, int index, string partialPredicateCall) { + + exists(int b, int bSyntaxSugarType, int n | + b = 0 + and + bSyntaxSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) + and + n = bSyntaxSugarType + and ( + none() + or + result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfNominalType(NominalType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalOrBoundGenericNominalType, int n | + b = 0 + and + bNominalOrBoundGenericNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) | i) + and + n = bNominalOrBoundGenericNominalType + and ( + none() + or + result = getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOpaqueTypeArchetypeType(OpaqueTypeArchetypeType e, int index, string partialPredicateCall) { + + exists(int b, int bArchetypeType, int n | + b = 0 + and + bArchetypeType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) + and + n = bArchetypeType + and ( + none() + or + result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOpenedArchetypeType(OpenedArchetypeType e, int index, string partialPredicateCall) { + + exists(int b, int bArchetypeType, int n | + b = 0 + and + bArchetypeType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) + and + n = bArchetypeType + and ( + none() + or + result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfPrimaryArchetypeType(PrimaryArchetypeType e, int index, string partialPredicateCall) { + + exists(int b, int bArchetypeType, int n | + b = 0 + and + bArchetypeType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) + and + n = bArchetypeType + and ( + none() + or + result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfUnarySyntaxSugarType(UnarySyntaxSugarType e, int index, string partialPredicateCall) { + + exists(int b, int bSyntaxSugarType, int n | + b = 0 + and + bSyntaxSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) + and + n = bSyntaxSugarType + and ( + none() + or + result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfArraySliceType(ArraySliceType e, int index, string partialPredicateCall) { + + exists(int b, int bUnarySyntaxSugarType, int n | + b = 0 + and + bUnarySyntaxSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) + and + n = bUnarySyntaxSugarType + and ( + none() + or + result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBoundGenericClassType(BoundGenericClassType e, int index, string partialPredicateCall) { + + exists(int b, int bBoundGenericType, int n | + b = 0 + and + bBoundGenericType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) + and + n = bBoundGenericType + and ( + none() + or + result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBoundGenericEnumType(BoundGenericEnumType e, int index, string partialPredicateCall) { + + exists(int b, int bBoundGenericType, int n | + b = 0 + and + bBoundGenericType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) + and + n = bBoundGenericType + and ( + none() + or + result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfBoundGenericStructType(BoundGenericStructType e, int index, string partialPredicateCall) { + + exists(int b, int bBoundGenericType, int n | + b = 0 + and + bBoundGenericType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) + and + n = bBoundGenericType + and ( + none() + or + result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfClassType(ClassType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalType, int n | + b = 0 + and + bNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) + and + n = bNominalType + and ( + none() + or + result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfEnumType(EnumType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalType, int n | + b = 0 + and + bNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) + and + n = bNominalType + and ( + none() + or + result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfOptionalType(OptionalType e, int index, string partialPredicateCall) { + + exists(int b, int bUnarySyntaxSugarType, int n | + b = 0 + and + bUnarySyntaxSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) + and + n = bUnarySyntaxSugarType + and ( + none() + or + result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfProtocolType(ProtocolType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalType, int n | + b = 0 + and + bNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) + and + n = bNominalType + and ( + none() + or + result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) + )) + } - private Element getImmediateChildOfCallable(Callable e, int index, string partialPredicateCall) { - exists(int b, int bElement, int n, int nSelfParam, int nParam, int nBody, int nCapture | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - nSelfParam = n + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and - nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - or - index = n and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" - or - result = e.getParam(index - nSelfParam) and - partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" - or - index = nParam and result = e.getBody() and partialPredicateCall = "Body()" - or - result = e.getCapture(index - nBody) and - partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfFile(File e, int index, string partialPredicateCall) { - exists(int b, int bElement, int n | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLocatable(Locatable e, int index, string partialPredicateCall) { - exists(int b, int bElement, int n | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLocation(Location e, int index, string partialPredicateCall) { - exists(int b, int bElement, int n | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAstNode(AstNode e, int index, string partialPredicateCall) { - exists(int b, int bLocatable, int n | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and - ( - none() - or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfComment(Comment e, int index, string partialPredicateCall) { - exists(int b, int bLocatable, int n | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and - ( - none() - or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDbFile(DbFile e, int index, string partialPredicateCall) { - exists(int b, int bFile, int n | - b = 0 and - bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) and - n = bFile and - ( - none() - or - result = getImmediateChildOfFile(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDbLocation(DbLocation e, int index, string partialPredicateCall) { - exists(int b, int bLocation, int n | - b = 0 and - bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) and - n = bLocation and - ( - none() - or - result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDiagnostics( - Diagnostics e, int index, string partialPredicateCall - ) { - exists(int b, int bLocatable, int n | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and - ( - none() - or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfErrorElement( - ErrorElement e, int index, string partialPredicateCall - ) { - exists(int b, int bLocatable, int n | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and - ( - none() - or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnknownFile( - UnknownFile e, int index, string partialPredicateCall - ) { - exists(int b, int bFile, int n | - b = 0 and - bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) and - n = bFile and - ( - none() - or - result = getImmediateChildOfFile(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnknownLocation( - UnknownLocation e, int index, string partialPredicateCall - ) { - exists(int b, int bLocation, int n | - b = 0 and - bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) and - n = bLocation and - ( - none() - or - result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAvailabilityInfo( - AvailabilityInfo e, int index, string partialPredicateCall - ) { - exists(int b, int bAstNode, int n, int nSpec | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nSpec = n + 1 + max(int i | i = -1 or exists(e.getSpec(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getSpec(index - n) and - partialPredicateCall = "Spec(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfAvailabilitySpec( - AvailabilitySpec e, int index, string partialPredicateCall - ) { - exists(int b, int bAstNode, int n | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfKeyPathComponent( - KeyPathComponent e, int index, string partialPredicateCall - ) { - exists(int b, int bAstNode, int n, int nSubscriptArgument | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nSubscriptArgument = n + 1 + max(int i | i = -1 or exists(e.getSubscriptArgument(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getSubscriptArgument(index - n) and - partialPredicateCall = "SubscriptArgument(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfUnspecifiedElement( - UnspecifiedElement e, int index, string partialPredicateCall - ) { - exists(int b, int bErrorElement, int n | - b = 0 and - bErrorElement = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfErrorElement(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOtherAvailabilitySpec( - OtherAvailabilitySpec e, int index, string partialPredicateCall - ) { - exists(int b, int bAvailabilitySpec, int n | - b = 0 and - bAvailabilitySpec = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) and - n = bAvailabilitySpec and - ( - none() - or - result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPlatformVersionAvailabilitySpec( - PlatformVersionAvailabilitySpec e, int index, string partialPredicateCall - ) { - exists(int b, int bAvailabilitySpec, int n | - b = 0 and - bAvailabilitySpec = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) and - n = bAvailabilitySpec and - ( - none() - or - result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDecl(Decl e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nMember | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getMember(index - n) and - partialPredicateCall = "Member(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfGenericContext( - GenericContext e, int index, string partialPredicateCall - ) { - exists(int b, int bElement, int n, int nGenericTypeParam | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - or - result = e.getGenericTypeParam(index - n) and - partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfCapturedDecl( - CapturedDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfEnumCaseDecl( - EnumCaseDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExtensionDecl( - ExtensionDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericContext, int bDecl, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bDecl = - bGenericContext + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfDecl(e, index - bGenericContext, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfIfConfigDecl( - IfConfigDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfImportDecl(ImportDecl e, int index, string partialPredicateCall) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMissingMemberDecl( - MissingMemberDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOperatorDecl( - OperatorDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPatternBindingDecl( - PatternBindingDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n, int nInit, int nPattern | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nInit = n + 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 - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - or - result = e.getImmediateInit(index - n) and - partialPredicateCall = "Init(" + (index - n).toString() + ")" - or - result = e.getImmediatePattern(index - nInit) and - partialPredicateCall = "Pattern(" + (index - nInit).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfPoundDiagnosticDecl( - PoundDiagnosticDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n, int nMessage | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nMessage = n + 1 and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateMessage() and partialPredicateCall = "Message()" - ) - ) - } - - private Element getImmediateChildOfPrecedenceGroupDecl( - PrecedenceGroupDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTopLevelCodeDecl( - TopLevelCodeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n, int nBody | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfValueDecl(ValueDecl e, int index, string partialPredicateCall) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAbstractStorageDecl( - AbstractStorageDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bValueDecl, int n, int nAccessor | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and - nAccessor = n + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and - ( - none() - or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) - or - result = e.getAccessor(index - n) and - partialPredicateCall = "Accessor(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfEnumElementDecl( - EnumElementDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bValueDecl, int n, int nParam | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and - nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and - ( - none() - or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) - or - result = e.getParam(index - n) and - partialPredicateCall = "Param(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) { - exists(int b, int bGenericContext, int bValueDecl, int bCallable, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bValueDecl = - bGenericContext + 1 + - max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - bCallable = - bValueDecl + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and - ( - none() - or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfValueDecl(e, index - bGenericContext, partialPredicateCall) - or - result = getImmediateChildOfCallable(e, index - bValueDecl, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInfixOperatorDecl( - InfixOperatorDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and - ( - none() - or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPostfixOperatorDecl( - PostfixOperatorDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and - ( - none() - or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPrefixOperatorDecl( - PrefixOperatorDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and - ( - none() - or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTypeDecl(TypeDecl e, int index, string partialPredicateCall) { - exists(int b, int bValueDecl, int n | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and - ( - none() - or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAbstractTypeParamDecl( - AbstractTypeParamDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bTypeDecl, int n | - b = 0 and - bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and - ( - none() - or - result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAccessorOrNamedFunction( - AccessorOrNamedFunction e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and - ( - none() - or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDeinitializer( - Deinitializer e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and - ( - none() - or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfGenericTypeDecl( - GenericTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericContext, int bTypeDecl, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bTypeDecl = - bGenericContext + 1 + - max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and - ( - none() - or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfTypeDecl(e, index - bGenericContext, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInitializer( - Initializer e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and - ( - none() - or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index, string partialPredicateCall) { - exists(int b, int bTypeDecl, int n | - b = 0 and - bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and - ( - none() - or - result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSubscriptDecl( - SubscriptDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bAbstractStorageDecl, int bGenericContext, int n, int nParam | - b = 0 and - bAbstractStorageDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) and - bGenericContext = - bAbstractStorageDecl + 1 + - max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - n = bGenericContext and - nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and - ( - none() - or - result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) - or - result = - getImmediateChildOfGenericContext(e, index - bAbstractStorageDecl, partialPredicateCall) - or - result = e.getParam(index - n) and - partialPredicateCall = "Param(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfVarDecl(VarDecl e, int index, string partialPredicateCall) { - exists( - int b, int bAbstractStorageDecl, int n, int nPropertyWrapperBackingVarBinding, - int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, - int nPropertyWrapperProjectionVar - | - b = 0 and - bAbstractStorageDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) and - n = bAbstractStorageDecl and - nPropertyWrapperBackingVarBinding = n + 1 and - nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and - nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and - nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 and - ( - none() - or - result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) - or - index = n and - result = e.getPropertyWrapperBackingVarBinding() and - partialPredicateCall = "PropertyWrapperBackingVarBinding()" - or - index = nPropertyWrapperBackingVarBinding and - result = e.getPropertyWrapperBackingVar() and - partialPredicateCall = "PropertyWrapperBackingVar()" - or - index = nPropertyWrapperBackingVar and - result = e.getPropertyWrapperProjectionVarBinding() and - partialPredicateCall = "PropertyWrapperProjectionVarBinding()" - or - index = nPropertyWrapperProjectionVarBinding and - result = e.getPropertyWrapperProjectionVar() and - partialPredicateCall = "PropertyWrapperProjectionVar()" - ) - ) - } - - private Element getImmediateChildOfAccessor(Accessor e, int index, string partialPredicateCall) { - exists(int b, int bAccessorOrNamedFunction, int n | - b = 0 and - bAccessorOrNamedFunction = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) and - n = bAccessorOrNamedFunction and - ( - none() - or - result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAssociatedTypeDecl( - AssociatedTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bAbstractTypeParamDecl, int n | - b = 0 and - bAbstractTypeParamDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) and - n = bAbstractTypeParamDecl and - ( - none() - or - result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfConcreteVarDecl( - ConcreteVarDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bVarDecl, int n | - b = 0 and - bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) and - n = bVarDecl and - ( - none() - or - result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfGenericTypeParamDecl( - GenericTypeParamDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bAbstractTypeParamDecl, int n | - b = 0 and - bAbstractTypeParamDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) and - n = bAbstractTypeParamDecl and - ( - none() - or - result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNamedFunction( - NamedFunction e, int index, string partialPredicateCall - ) { - exists(int b, int bAccessorOrNamedFunction, int n | - b = 0 and - bAccessorOrNamedFunction = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) and - n = bAccessorOrNamedFunction and - ( - none() - or - result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalTypeDecl( - NominalTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and - ( - none() - or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOpaqueTypeDecl( - OpaqueTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and - ( - none() - or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfParamDecl(ParamDecl e, int index, string partialPredicateCall) { - exists( - int b, int bVarDecl, int n, int nPropertyWrapperLocalWrappedVarBinding, - int nPropertyWrapperLocalWrappedVar - | - b = 0 and - bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) and - n = bVarDecl and - nPropertyWrapperLocalWrappedVarBinding = n + 1 and - nPropertyWrapperLocalWrappedVar = nPropertyWrapperLocalWrappedVarBinding + 1 and - ( - none() - or - result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) - or - index = n and - result = e.getPropertyWrapperLocalWrappedVarBinding() and - partialPredicateCall = "PropertyWrapperLocalWrappedVarBinding()" - or - index = nPropertyWrapperLocalWrappedVarBinding and - result = e.getPropertyWrapperLocalWrappedVar() and - partialPredicateCall = "PropertyWrapperLocalWrappedVar()" - ) - ) - } - - private Element getImmediateChildOfTypeAliasDecl( - TypeAliasDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and - ( - none() - or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfClassDecl(ClassDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and - ( - none() - or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfEnumDecl(EnumDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and - ( - none() - or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfProtocolDecl( - ProtocolDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and - ( - none() - or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfStructDecl(StructDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and - ( - none() - or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArgument(Argument e, int index, string partialPredicateCall) { - exists(int b, int bLocatable, int n, int nExpr | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and - nExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" - ) - ) - } - - private Element getImmediateChildOfExpr(Expr e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyTryExpr(AnyTryExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfAppliedPropertyWrapperExpr( - AppliedPropertyWrapperExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nValue | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nValue = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateValue() and partialPredicateCall = "Value()" - ) - ) - } - - private Element getImmediateChildOfApplyExpr(ApplyExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nFunction, int nArgument | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" - or - result = e.getArgument(index - nFunction) and - partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfAssignExpr(AssignExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nDest, int nSource | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nDest = n + 1 and - nSource = nDest + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateDest() and partialPredicateCall = "Dest()" - or - index = nDest and result = e.getImmediateSource() and partialPredicateCall = "Source()" - ) - ) - } - - private Element getImmediateChildOfBindOptionalExpr( - BindOptionalExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfCaptureListExpr( - CaptureListExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nBindingDecl, int nClosureBody | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nBindingDecl = n + 1 + max(int i | i = -1 or exists(e.getBindingDecl(i)) | i) and - nClosureBody = nBindingDecl + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = e.getBindingDecl(index - n) and - partialPredicateCall = "BindingDecl(" + (index - n).toString() + ")" - or - index = nBindingDecl and - result = e.getImmediateClosureBody() and - partialPredicateCall = "ClosureBody()" - ) - ) - } - - private Element getImmediateChildOfClosureExpr( - ClosureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bCallable, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bCallable = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfCallable(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCollectionExpr( - CollectionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDeclRefExpr( - DeclRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDefaultArgumentExpr( - DefaultArgumentExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDiscardAssignmentExpr( - DiscardAssignmentExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDotSyntaxBaseIgnoredExpr( - DotSyntaxBaseIgnoredExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nQualifier, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nQualifier = n + 1 and - nSubExpr = nQualifier + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateQualifier() and partialPredicateCall = "Qualifier()" - or - index = nQualifier and - result = e.getImmediateSubExpr() and - partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfDynamicTypeExpr( - DynamicTypeExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nBase | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nBase = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" - ) - ) - } - - private Element getImmediateChildOfEnumIsCaseExpr( - EnumIsCaseExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfErrorExpr(ErrorExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExplicitCastExpr( - ExplicitCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfForceValueExpr( - ForceValueExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfIdentityExpr( - IdentityExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nCondition, int nThenExpr, int nElseExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nCondition = n + 1 and - nThenExpr = nCondition + 1 and - nElseExpr = nThenExpr + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" - or - index = nCondition and - result = e.getImmediateThenExpr() and - partialPredicateCall = "ThenExpr()" - or - index = nThenExpr and - result = e.getImmediateElseExpr() and - partialPredicateCall = "ElseExpr()" - ) - ) - } - - private Element getImmediateChildOfImplicitConversionExpr( - ImplicitConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfInOutExpr(InOutExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfKeyPathApplicationExpr( - KeyPathApplicationExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nBase, int nKeyPath | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nBase = n + 1 and - nKeyPath = nBase + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" - or - index = nBase and result = e.getImmediateKeyPath() and partialPredicateCall = "KeyPath()" - ) - ) - } - - private Element getImmediateChildOfKeyPathDotExpr( - KeyPathDotExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfKeyPathExpr( - KeyPathExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nRoot, int nComponent | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nRoot = n + 1 and - nComponent = nRoot + 1 + max(int i | i = -1 or exists(e.getComponent(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getRoot() and partialPredicateCall = "Root()" - or - result = e.getComponent(index - nRoot) and - partialPredicateCall = "Component(" + (index - nRoot).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfLazyInitializationExpr( - LazyInitializationExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfLiteralExpr( - LiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLookupExpr(LookupExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nBase | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nBase = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" - ) - ) - } - - private Element getImmediateChildOfMakeTemporarilyEscapableExpr( - MakeTemporarilyEscapableExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nEscapingClosure, int nNonescapingClosure, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nEscapingClosure = n + 1 and - nNonescapingClosure = nEscapingClosure + 1 and - nSubExpr = nNonescapingClosure + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and - result = e.getImmediateEscapingClosure() and - partialPredicateCall = "EscapingClosure()" - or - index = nEscapingClosure and - result = e.getImmediateNonescapingClosure() and - partialPredicateCall = "NonescapingClosure()" - or - index = nNonescapingClosure and - result = e.getImmediateSubExpr() and - partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfObjCSelectorExpr( - ObjCSelectorExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfOneWayExpr(OneWayExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfOpaqueValueExpr( - OpaqueValueExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOpenExistentialExpr( - OpenExistentialExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr, int nExistential | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - nExistential = nSubExpr + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - or - index = nSubExpr and - result = e.getImmediateExistential() and - partialPredicateCall = "Existential()" - ) - ) - } - - private Element getImmediateChildOfOptionalEvaluationExpr( - OptionalEvaluationExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfOtherInitializerRefExpr( - OtherInitializerRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOverloadedDeclRefExpr( - OverloadedDeclRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPropertyWrapperValuePlaceholderExpr( - PropertyWrapperValuePlaceholderExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfRebindSelfInInitializerExpr( - RebindSelfInInitializerExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfSequenceExpr( - SequenceExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nElement | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = e.getImmediateElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfSuperRefExpr( - SuperRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTapExpr(TapExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr, int nBody | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - nBody = nSubExpr + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - or - index = nSubExpr and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfTupleElementExpr( - TupleElementExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nElement | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = e.getImmediateElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfTypeExpr(TypeExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nTypeRepr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nTypeRepr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" - ) - ) - } - - private Element getImmediateChildOfUnresolvedDeclRefExpr( - UnresolvedDeclRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnresolvedDotExpr( - UnresolvedDotExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n, int nBase | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - nBase = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or - index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" - ) - ) - } - - private Element getImmediateChildOfUnresolvedMemberExpr( - UnresolvedMemberExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnresolvedPatternExpr( - UnresolvedPatternExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n, int nSubPattern | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - nSubPattern = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfUnresolvedSpecializeExpr( - UnresolvedSpecializeExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bErrorElement, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfVarargExpansionExpr( - VarargExpansionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfAbiSafeConversionExpr( - AbiSafeConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyHashableErasureExpr( - AnyHashableErasureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArchetypeToSuperExpr( - ArchetypeToSuperExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { - exists(int b, int bCollectionExpr, int n, int nElement | - b = 0 and - bCollectionExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) and - n = bCollectionExpr and - nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) - or - result = e.getImmediateElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfArrayToPointerExpr( - ArrayToPointerExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAutoClosureExpr( - AutoClosureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bClosureExpr, int n | - b = 0 and - bClosureExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) and - n = bClosureExpr and - ( - none() - or - result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and - ( - none() - or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index, string partialPredicateCall) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBridgeFromObjCExpr( - BridgeFromObjCExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBridgeToObjCExpr( - BridgeToObjCExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinLiteralExpr( - BuiltinLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCheckedCastExpr( - CheckedCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExplicitCastExpr, int n | - b = 0 and - bExplicitCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) and - n = bExplicitCastExpr and - ( - none() - or - result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfClassMetatypeToObjectExpr( - ClassMetatypeToObjectExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCoerceExpr(CoerceExpr e, int index, string partialPredicateCall) { - exists(int b, int bExplicitCastExpr, int n | - b = 0 and - bExplicitCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) and - n = bExplicitCastExpr and - ( - none() - or - result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCollectionUpcastConversionExpr( - CollectionUpcastConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfConditionalBridgeFromObjCExpr( - ConditionalBridgeFromObjCExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCovariantFunctionConversionExpr( - CovariantFunctionConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCovariantReturnConversionExpr( - CovariantReturnConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDerivedToBaseExpr( - DerivedToBaseExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDestructureTupleExpr( - DestructureTupleExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDictionaryExpr( - DictionaryExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bCollectionExpr, int n, int nElement | - b = 0 and - bCollectionExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) and - n = bCollectionExpr and - nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) - or - result = e.getImmediateElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfDifferentiableFunctionExpr( - DifferentiableFunctionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDifferentiableFunctionExtractOriginalExpr( - DifferentiableFunctionExtractOriginalExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDotSelfExpr( - DotSelfExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and - ( - none() - or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDynamicLookupExpr( - DynamicLookupExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLookupExpr, int n | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - ( - none() - or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfErasureExpr( - ErasureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExistentialMetatypeToObjectExpr( - ExistentialMetatypeToObjectExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExplicitClosureExpr( - ExplicitClosureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bClosureExpr, int n | - b = 0 and - bClosureExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) and - n = bClosureExpr and - ( - none() - or - result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfForceTryExpr( - ForceTryExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and - ( - none() - or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfForeignObjectConversionExpr( - ForeignObjectConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfFunctionConversionExpr( - FunctionConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInOutToPointerExpr( - InOutToPointerExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInjectIntoOptionalExpr( - InjectIntoOptionalExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInterpolatedStringLiteralExpr( - InterpolatedStringLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n, int nAppendingExpr | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - nAppendingExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - or - index = n and - result = e.getImmediateAppendingExpr() and - partialPredicateCall = "AppendingExpr()" - ) - ) - } - - private Element getImmediateChildOfLinearFunctionExpr( - LinearFunctionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLinearFunctionExtractOriginalExpr( - LinearFunctionExtractOriginalExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLinearToDifferentiableFunctionExpr( - LinearToDifferentiableFunctionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLoadExpr(LoadExpr e, int index, string partialPredicateCall) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMemberRefExpr( - MemberRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLookupExpr, int n | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - ( - none() - or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMetatypeConversionExpr( - MetatypeConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMethodLookupExpr( - MethodLookupExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLookupExpr, int n, int nMethodRef | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - nMethodRef = n + 1 and - ( - none() - or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateMethodRef() and partialPredicateCall = "MethodRef()" - ) - ) - } - - private Element getImmediateChildOfNilLiteralExpr( - NilLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfObjectLiteralExpr( - ObjectLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n, int nArgument | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - nArgument = n + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - or - result = e.getArgument(index - n) and - partialPredicateCall = "Argument(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfOptionalTryExpr( - OptionalTryExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and - ( - none() - or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and - ( - none() - or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPointerToPointerExpr( - PointerToPointerExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPostfixUnaryExpr( - PostfixUnaryExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPrefixUnaryExpr( - PrefixUnaryExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfProtocolMetatypeToObjectExpr( - ProtocolMetatypeToObjectExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfRegexLiteralExpr( - RegexLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSelfApplyExpr( - SelfApplyExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfStringToPointerExpr( - StringToPointerExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSubscriptExpr( - SubscriptExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLookupExpr, int n, int nArgument | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - nArgument = n + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and - ( - none() - or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) - or - result = e.getArgument(index - n) and - partialPredicateCall = "Argument(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and - ( - none() - or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnderlyingToOpaqueExpr( - UnderlyingToOpaqueExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnevaluatedInstanceExpr( - UnevaluatedInstanceExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnresolvedMemberChainResultExpr( - UnresolvedMemberChainResultExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bIdentityExpr, int bErrorElement, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - bErrorElement = - bIdentityExpr + 1 + - max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bIdentityExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnresolvedTypeConversionExpr( - UnresolvedTypeConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bImplicitConversionExpr, int bErrorElement, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - bErrorElement = - bImplicitConversionExpr + 1 + - max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - or - result = - getImmediateChildOfErrorElement(e, index - bImplicitConversionExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBooleanLiteralExpr( - BooleanLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfConditionalCheckedCastExpr( - ConditionalCheckedCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and - ( - none() - or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDotSyntaxCallExpr( - DotSyntaxCallExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bSelfApplyExpr, int n | - b = 0 and - bSelfApplyExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) and - n = bSelfApplyExpr and - ( - none() - or - result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDynamicMemberRefExpr( - DynamicMemberRefExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bDynamicLookupExpr, int n | - b = 0 and - bDynamicLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) and - n = bDynamicLookupExpr and - ( - none() - or - result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDynamicSubscriptExpr( - DynamicSubscriptExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bDynamicLookupExpr, int n | - b = 0 and - bDynamicLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) and - n = bDynamicLookupExpr and - ( - none() - or - result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfForcedCheckedCastExpr( - ForcedCheckedCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and - ( - none() - or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInitializerRefCallExpr( - InitializerRefCallExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bSelfApplyExpr, int n | - b = 0 and - bSelfApplyExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) and - n = bSelfApplyExpr and - ( - none() - or - result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfIsExpr(IsExpr e, int index, string partialPredicateCall) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and - ( - none() - or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMagicIdentifierLiteralExpr( - MagicIdentifierLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNumberLiteralExpr( - NumberLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfStringLiteralExpr( - StringLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfFloatLiteralExpr( - FloatLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bNumberLiteralExpr, int n | - b = 0 and - bNumberLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) and - n = bNumberLiteralExpr and - ( - none() - or - result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfIntegerLiteralExpr( - IntegerLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bNumberLiteralExpr, int n | - b = 0 and - bNumberLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) and - n = bNumberLiteralExpr and - ( - none() - or - result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPattern(Pattern e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyPattern(AnyPattern e, int index, string partialPredicateCall) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBindingPattern( - BindingPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubPattern = n + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfBoolPattern( - BoolPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfEnumElementPattern( - EnumElementPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubPattern = n + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfExprPattern( - ExprPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubExpr | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfIsPattern(IsPattern e, int index, string partialPredicateCall) { - exists(int b, int bPattern, int n, int nCastTypeRepr, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nCastTypeRepr = n + 1 and - nSubPattern = nCastTypeRepr + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getCastTypeRepr() and partialPredicateCall = "CastTypeRepr()" - or - index = nCastTypeRepr and - result = e.getImmediateSubPattern() and - partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfNamedPattern( - NamedPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOptionalSomePattern( - OptionalSomePattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubPattern = n + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfParenPattern( - ParenPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubPattern = n + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - ) - ) - } - - private Element getImmediateChildOfTuplePattern( - TuplePattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nElement | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - result = e.getImmediateElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfTypedPattern( - TypedPattern e, int index, string partialPredicateCall - ) { - exists(int b, int bPattern, int n, int nSubPattern, int nTypeRepr | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - nSubPattern = n + 1 and - nTypeRepr = nSubPattern + 1 and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" - or - index = nSubPattern and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" - ) - ) - } - - private Element getImmediateChildOfCaseLabelItem( - CaseLabelItem e, int index, string partialPredicateCall - ) { - exists(int b, int bAstNode, int n, int nPattern, int nGuard | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nPattern = n + 1 and - nGuard = nPattern + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" - or - index = nPattern and result = e.getImmediateGuard() and partialPredicateCall = "Guard()" - ) - ) - } - - private Element getImmediateChildOfConditionElement( - ConditionElement e, int index, string partialPredicateCall - ) { - exists( - int b, int bAstNode, int n, int nBoolean, int nPattern, int nInitializer, int nAvailability - | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nBoolean = n + 1 and - nPattern = nBoolean + 1 and - nInitializer = nPattern + 1 and - nAvailability = nInitializer + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateBoolean() and partialPredicateCall = "Boolean()" - or - index = nBoolean and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" - or - index = nPattern and - result = e.getImmediateInitializer() and - partialPredicateCall = "Initializer()" - or - index = nInitializer and - result = e.getAvailability() and - partialPredicateCall = "Availability()" - ) - ) - } - - private Element getImmediateChildOfStmt(Stmt e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfStmtCondition( - StmtCondition e, int index, string partialPredicateCall - ) { - exists(int b, int bAstNode, int n, int nElement | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nElement = n + 1 + max(int i | i = -1 or exists(e.getElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getElement(index - n) and - partialPredicateCall = "Element(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfBraceStmt(BraceStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nVariable, int nElement | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and - nElement = nVariable + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - result = e.getVariable(index - n) and - partialPredicateCall = "Variable(" + (index - n).toString() + ")" - or - result = e.getImmediateElement(index - nVariable) and - partialPredicateCall = "Element(" + (index - nVariable).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfBreakStmt(BreakStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCaseStmt(CaseStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nBody, int nLabel | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nBody = n + 1 and - nLabel = nBody + 1 + max(int i | i = -1 or exists(e.getLabel(i)) | i) and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - or - result = e.getLabel(index - nBody) and - partialPredicateCall = "Label(" + (index - nBody).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfContinueStmt( - ContinueStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDeferStmt(DeferStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nBody | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfFailStmt(FailStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfFallthroughStmt( - FallthroughStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLabeledStmt( - LabeledStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPoundAssertStmt( - PoundAssertStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bStmt, int n | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfReturnStmt(ReturnStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nResult | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nResult = n + 1 and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateResult() and partialPredicateCall = "Result()" - ) - ) - } - - private Element getImmediateChildOfThrowStmt(ThrowStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nSubExpr | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfYieldStmt(YieldStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nResult | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and - nResult = n + 1 + max(int i | i = -1 or exists(e.getImmediateResult(i)) | i) and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - result = e.getImmediateResult(index - n) and - partialPredicateCall = "Result(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfDoCatchStmt( - DoCatchStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bLabeledStmt, int n, int nBody, int nCatch | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nBody = n + 1 and - nCatch = nBody + 1 + max(int i | i = -1 or exists(e.getCatch(i)) | i) and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - or - result = e.getCatch(index - nBody) and - partialPredicateCall = "Catch(" + (index - nBody).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfDoStmt(DoStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledStmt, int n, int nBody | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfForEachStmt( - ForEachStmt e, int index, string partialPredicateCall - ) { - exists( - int b, int bLabeledStmt, int n, int nPattern, int nSequence, int nWhere, int nNextCall, - int nBody - | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nPattern = n + 1 and - nSequence = nPattern + 1 and - nWhere = nSequence + 1 and - nNextCall = nWhere + 1 and - nBody = nNextCall + 1 and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" - or - index = nPattern and - result = e.getImmediateSequence() and - partialPredicateCall = "Sequence()" - or - index = nSequence and result = e.getImmediateWhere() and partialPredicateCall = "Where()" - or - index = nWhere and result = e.getImmediateNextCall() and partialPredicateCall = "NextCall()" - or - index = nNextCall and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfLabeledConditionalStmt( - LabeledConditionalStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bLabeledStmt, int n, int nCondition | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nCondition = n + 1 and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getCondition() and partialPredicateCall = "Condition()" - ) - ) - } - - private Element getImmediateChildOfRepeatWhileStmt( - RepeatWhileStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bLabeledStmt, int n, int nCondition, int nBody | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nCondition = n + 1 and - nBody = nCondition + 1 and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" - or - index = nCondition and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfSwitchStmt(SwitchStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledStmt, int n, int nExpr, int nCase | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nExpr = n + 1 and - nCase = nExpr + 1 + max(int i | i = -1 or exists(e.getCase(i)) | i) and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" - or - result = e.getCase(index - nExpr) and - partialPredicateCall = "Case(" + (index - nExpr).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfGuardStmt(GuardStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nBody | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfIfStmt(IfStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nThen, int nElse | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nThen = n + 1 and - nElse = nThen + 1 and - ( - none() - or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getThen() and partialPredicateCall = "Then()" - or - index = nThen and result = e.getElse() and partialPredicateCall = "Else()" - ) - ) - } - - private Element getImmediateChildOfWhileStmt(WhileStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nBody | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfType(Type e, int index, string partialPredicateCall) { - exists(int b, int bElement, int n | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTypeRepr(TypeRepr e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyFunctionType( - AnyFunctionType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyGenericType( - AnyGenericType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyMetatypeType( - AnyMetatypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinType( - BuiltinType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDependentMemberType( - DependentMemberType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDynamicSelfType( - DynamicSelfType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfErrorType(ErrorType e, int index, string partialPredicateCall) { - exists(int b, int bType, int bErrorElement, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - bErrorElement = - bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExistentialType( - ExistentialType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInOutType(InOutType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLValueType(LValueType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfModuleType(ModuleType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfParameterizedProtocolType( - ParameterizedProtocolType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfProtocolCompositionType( - ProtocolCompositionType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfReferenceStorageType( - ReferenceStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSubstitutableType( - SubstitutableType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSugarType(SugarType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTupleType(TupleType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnresolvedType( - UnresolvedType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int bErrorElement, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - bErrorElement = - bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyBuiltinIntegerType( - AnyBuiltinIntegerType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArchetypeType( - ArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bSubstitutableType, int n | - b = 0 and - bSubstitutableType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) and - n = bSubstitutableType and - ( - none() - or - result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinBridgeObjectType( - BuiltinBridgeObjectType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinDefaultActorStorageType( - BuiltinDefaultActorStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinExecutorType( - BuiltinExecutorType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinFloatType( - BuiltinFloatType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinJobType( - BuiltinJobType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinNativeObjectType( - BuiltinNativeObjectType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinRawPointerType( - BuiltinRawPointerType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinRawUnsafeContinuationType( - BuiltinRawUnsafeContinuationType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinUnsafeValueBufferType( - BuiltinUnsafeValueBufferType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinVectorType( - BuiltinVectorType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExistentialMetatypeType( - ExistentialMetatypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyMetatypeType, int n | - b = 0 and - bAnyMetatypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) and - n = bAnyMetatypeType and - ( - none() - or - result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfFunctionType( - FunctionType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyFunctionType, int n | - b = 0 and - bAnyFunctionType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) and - n = bAnyFunctionType and - ( - none() - or - result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfGenericFunctionType( - GenericFunctionType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyFunctionType, int n | - b = 0 and - bAnyFunctionType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) and - n = bAnyFunctionType and - ( - none() - or - result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfGenericTypeParamType( - GenericTypeParamType e, int index, string partialPredicateCall - ) { - exists(int b, int bSubstitutableType, int n | - b = 0 and - bSubstitutableType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) and - n = bSubstitutableType and - ( - none() - or - result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfMetatypeType( - MetatypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyMetatypeType, int n | - b = 0 and - bAnyMetatypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) and - n = bAnyMetatypeType and - ( - none() - or - result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalOrBoundGenericNominalType( - NominalOrBoundGenericNominalType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyGenericType, int n | - b = 0 and - bAnyGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) and - n = bAnyGenericType and - ( - none() - or - result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfParenType(ParenType e, int index, string partialPredicateCall) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSyntaxSugarType( - SyntaxSugarType e, int index, string partialPredicateCall - ) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTypeAliasType( - TypeAliasType e, int index, string partialPredicateCall - ) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnboundGenericType( - UnboundGenericType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyGenericType, int n | - b = 0 and - bAnyGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) and - n = bAnyGenericType and - ( - none() - or - result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnmanagedStorageType( - UnmanagedStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnownedStorageType( - UnownedStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfWeakStorageType( - WeakStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBoundGenericType( - BoundGenericType e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalOrBoundGenericNominalType, int n | - b = 0 and - bNominalOrBoundGenericNominalType = - b + 1 + - max(int i | - i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) - | - i - ) and - n = bNominalOrBoundGenericNominalType and - ( - none() - or - result = - getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinIntegerLiteralType( - BuiltinIntegerLiteralType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyBuiltinIntegerType, int n | - b = 0 and - bAnyBuiltinIntegerType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) and - n = bAnyBuiltinIntegerType and - ( - none() - or - result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinIntegerType( - BuiltinIntegerType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyBuiltinIntegerType, int n | - b = 0 and - bAnyBuiltinIntegerType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) and - n = bAnyBuiltinIntegerType and - ( - none() - or - result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDictionaryType( - DictionaryType e, int index, string partialPredicateCall - ) { - exists(int b, int bSyntaxSugarType, int n | - b = 0 and - bSyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) and - n = bSyntaxSugarType and - ( - none() - or - result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalType( - NominalType e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalOrBoundGenericNominalType, int n | - b = 0 and - bNominalOrBoundGenericNominalType = - b + 1 + - max(int i | - i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) - | - i - ) and - n = bNominalOrBoundGenericNominalType and - ( - none() - or - result = - getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOpaqueTypeArchetypeType( - OpaqueTypeArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOpenedArchetypeType( - OpenedArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPrimaryArchetypeType( - PrimaryArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnarySyntaxSugarType( - UnarySyntaxSugarType e, int index, string partialPredicateCall - ) { - exists(int b, int bSyntaxSugarType, int n | - b = 0 and - bSyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) and - n = bSyntaxSugarType and - ( - none() - or - result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArraySliceType( - ArraySliceType e, int index, string partialPredicateCall - ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBoundGenericClassType( - BoundGenericClassType e, int index, string partialPredicateCall - ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBoundGenericEnumType( - BoundGenericEnumType e, int index, string partialPredicateCall - ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBoundGenericStructType( - BoundGenericStructType e, int index, string partialPredicateCall - ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfClassType(ClassType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfEnumType(EnumType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOptionalType( - OptionalType e, int index, string partialPredicateCall - ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfProtocolType( - ProtocolType e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfStructType(StructType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfVariadicSequenceType( - VariadicSequenceType e, int index, string partialPredicateCall - ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - cached - Element getImmediateChild(Element e, int index, string partialAccessor) { - // 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, partialAccessor) - or - result = getImmediateChildOfDbFile(e, index, partialAccessor) - or - result = getImmediateChildOfDbLocation(e, index, partialAccessor) - or - result = getImmediateChildOfDiagnostics(e, index, partialAccessor) - or - result = getImmediateChildOfUnknownFile(e, index, partialAccessor) - or - result = getImmediateChildOfUnknownLocation(e, index, partialAccessor) - or - result = getImmediateChildOfAvailabilityInfo(e, index, partialAccessor) - or - result = getImmediateChildOfKeyPathComponent(e, index, partialAccessor) - or - result = getImmediateChildOfUnspecifiedElement(e, index, partialAccessor) - or - result = getImmediateChildOfOtherAvailabilitySpec(e, index, partialAccessor) - or - result = getImmediateChildOfPlatformVersionAvailabilitySpec(e, index, partialAccessor) - or - result = getImmediateChildOfCapturedDecl(e, index, partialAccessor) - or - result = getImmediateChildOfEnumCaseDecl(e, index, partialAccessor) - or - result = getImmediateChildOfExtensionDecl(e, index, partialAccessor) - or - result = getImmediateChildOfIfConfigDecl(e, index, partialAccessor) - or - result = getImmediateChildOfImportDecl(e, index, partialAccessor) - or - result = getImmediateChildOfMissingMemberDecl(e, index, partialAccessor) - or - result = getImmediateChildOfPatternBindingDecl(e, index, partialAccessor) - or - result = getImmediateChildOfPoundDiagnosticDecl(e, index, partialAccessor) - or - result = getImmediateChildOfPrecedenceGroupDecl(e, index, partialAccessor) - or - result = getImmediateChildOfTopLevelCodeDecl(e, index, partialAccessor) - or - result = getImmediateChildOfEnumElementDecl(e, index, partialAccessor) - or - result = getImmediateChildOfInfixOperatorDecl(e, index, partialAccessor) - or - result = getImmediateChildOfPostfixOperatorDecl(e, index, partialAccessor) - or - result = getImmediateChildOfPrefixOperatorDecl(e, index, partialAccessor) - or - result = getImmediateChildOfDeinitializer(e, index, partialAccessor) - or - result = getImmediateChildOfInitializer(e, index, partialAccessor) - or - result = getImmediateChildOfModuleDecl(e, index, partialAccessor) - or - result = getImmediateChildOfSubscriptDecl(e, index, partialAccessor) - or - result = getImmediateChildOfAccessor(e, index, partialAccessor) - or - result = getImmediateChildOfAssociatedTypeDecl(e, index, partialAccessor) - or - result = getImmediateChildOfConcreteVarDecl(e, index, partialAccessor) - or - result = getImmediateChildOfGenericTypeParamDecl(e, index, partialAccessor) - or - result = getImmediateChildOfNamedFunction(e, index, partialAccessor) - or - result = getImmediateChildOfOpaqueTypeDecl(e, index, partialAccessor) - or - result = getImmediateChildOfParamDecl(e, index, partialAccessor) - or - result = getImmediateChildOfTypeAliasDecl(e, index, partialAccessor) - or - result = getImmediateChildOfClassDecl(e, index, partialAccessor) - or - result = getImmediateChildOfEnumDecl(e, index, partialAccessor) - or - result = getImmediateChildOfProtocolDecl(e, index, partialAccessor) - or - result = getImmediateChildOfStructDecl(e, index, partialAccessor) - or - result = getImmediateChildOfArgument(e, index, partialAccessor) - or - result = getImmediateChildOfAppliedPropertyWrapperExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAssignExpr(e, index, partialAccessor) - or - result = getImmediateChildOfBindOptionalExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCaptureListExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDeclRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDefaultArgumentExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDiscardAssignmentExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDotSyntaxBaseIgnoredExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDynamicTypeExpr(e, index, partialAccessor) - or - result = getImmediateChildOfEnumIsCaseExpr(e, index, partialAccessor) - or - result = getImmediateChildOfErrorExpr(e, index, partialAccessor) - or - result = getImmediateChildOfForceValueExpr(e, index, partialAccessor) - or - result = getImmediateChildOfIfExpr(e, index, partialAccessor) - or - result = getImmediateChildOfInOutExpr(e, index, partialAccessor) - or - result = getImmediateChildOfKeyPathApplicationExpr(e, index, partialAccessor) - or - result = getImmediateChildOfKeyPathDotExpr(e, index, partialAccessor) - or - result = getImmediateChildOfKeyPathExpr(e, index, partialAccessor) - or - result = getImmediateChildOfLazyInitializationExpr(e, index, partialAccessor) - or - result = getImmediateChildOfMakeTemporarilyEscapableExpr(e, index, partialAccessor) - or - result = getImmediateChildOfObjCSelectorExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOneWayExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOpaqueValueExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOpenExistentialExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOptionalEvaluationExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOtherInitializerRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOverloadedDeclRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfPropertyWrapperValuePlaceholderExpr(e, index, partialAccessor) - or - result = getImmediateChildOfRebindSelfInInitializerExpr(e, index, partialAccessor) - or - result = getImmediateChildOfSequenceExpr(e, index, partialAccessor) - or - result = getImmediateChildOfSuperRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfTapExpr(e, index, partialAccessor) - or - result = getImmediateChildOfTupleElementExpr(e, index, partialAccessor) - or - result = getImmediateChildOfTupleExpr(e, index, partialAccessor) - or - result = getImmediateChildOfTypeExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedDeclRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedDotExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedMemberExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedPatternExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedSpecializeExpr(e, index, partialAccessor) - or - result = getImmediateChildOfVarargExpansionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAbiSafeConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAnyHashableErasureExpr(e, index, partialAccessor) - or - result = getImmediateChildOfArchetypeToSuperExpr(e, index, partialAccessor) - or - result = getImmediateChildOfArrayExpr(e, index, partialAccessor) - or - result = getImmediateChildOfArrayToPointerExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAutoClosureExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAwaitExpr(e, index, partialAccessor) - or - result = getImmediateChildOfBinaryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfBridgeFromObjCExpr(e, index, partialAccessor) - or - result = getImmediateChildOfBridgeToObjCExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCallExpr(e, index, partialAccessor) - or - result = getImmediateChildOfClassMetatypeToObjectExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCoerceExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCollectionUpcastConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfConditionalBridgeFromObjCExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCovariantFunctionConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfCovariantReturnConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDerivedToBaseExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDestructureTupleExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDictionaryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDifferentiableFunctionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDifferentiableFunctionExtractOriginalExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDotSelfExpr(e, index, partialAccessor) - or - result = getImmediateChildOfErasureExpr(e, index, partialAccessor) - or - result = getImmediateChildOfExistentialMetatypeToObjectExpr(e, index, partialAccessor) - or - result = getImmediateChildOfExplicitClosureExpr(e, index, partialAccessor) - or - result = getImmediateChildOfForceTryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfForeignObjectConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfFunctionConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfInOutToPointerExpr(e, index, partialAccessor) - or - result = getImmediateChildOfInjectIntoOptionalExpr(e, index, partialAccessor) - or - result = getImmediateChildOfInterpolatedStringLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfLinearFunctionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfLinearFunctionExtractOriginalExpr(e, index, partialAccessor) - or - result = getImmediateChildOfLinearToDifferentiableFunctionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfLoadExpr(e, index, partialAccessor) - or - result = getImmediateChildOfMemberRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfMetatypeConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfMethodLookupExpr(e, index, partialAccessor) - or - result = getImmediateChildOfNilLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfObjectLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfOptionalTryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfParenExpr(e, index, partialAccessor) - or - result = getImmediateChildOfPointerToPointerExpr(e, index, partialAccessor) - or - result = getImmediateChildOfPostfixUnaryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfPrefixUnaryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfProtocolMetatypeToObjectExpr(e, index, partialAccessor) - or - result = getImmediateChildOfRegexLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfStringToPointerExpr(e, index, partialAccessor) - or - result = getImmediateChildOfSubscriptExpr(e, index, partialAccessor) - or - result = getImmediateChildOfTryExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnderlyingToOpaqueExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnevaluatedInstanceExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedMemberChainResultExpr(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedTypeConversionExpr(e, index, partialAccessor) - or - result = getImmediateChildOfBooleanLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfConditionalCheckedCastExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDotSyntaxCallExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDynamicMemberRefExpr(e, index, partialAccessor) - or - result = getImmediateChildOfDynamicSubscriptExpr(e, index, partialAccessor) - or - result = getImmediateChildOfForcedCheckedCastExpr(e, index, partialAccessor) - or - result = getImmediateChildOfInitializerRefCallExpr(e, index, partialAccessor) - or - result = getImmediateChildOfIsExpr(e, index, partialAccessor) - or - result = getImmediateChildOfMagicIdentifierLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfStringLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfFloatLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfIntegerLiteralExpr(e, index, partialAccessor) - or - result = getImmediateChildOfAnyPattern(e, index, partialAccessor) - or - result = getImmediateChildOfBindingPattern(e, index, partialAccessor) - or - result = getImmediateChildOfBoolPattern(e, index, partialAccessor) - or - result = getImmediateChildOfEnumElementPattern(e, index, partialAccessor) - or - result = getImmediateChildOfExprPattern(e, index, partialAccessor) - or - result = getImmediateChildOfIsPattern(e, index, partialAccessor) - or - result = getImmediateChildOfNamedPattern(e, index, partialAccessor) - or - result = getImmediateChildOfOptionalSomePattern(e, index, partialAccessor) - or - result = getImmediateChildOfParenPattern(e, index, partialAccessor) - or - result = getImmediateChildOfTuplePattern(e, index, partialAccessor) - or - result = getImmediateChildOfTypedPattern(e, index, partialAccessor) - or - result = getImmediateChildOfCaseLabelItem(e, index, partialAccessor) - or - result = getImmediateChildOfConditionElement(e, index, partialAccessor) - or - result = getImmediateChildOfStmtCondition(e, index, partialAccessor) - or - result = getImmediateChildOfBraceStmt(e, index, partialAccessor) - or - result = getImmediateChildOfBreakStmt(e, index, partialAccessor) - or - result = getImmediateChildOfCaseStmt(e, index, partialAccessor) - or - result = getImmediateChildOfContinueStmt(e, index, partialAccessor) - or - result = getImmediateChildOfDeferStmt(e, index, partialAccessor) - or - result = getImmediateChildOfFailStmt(e, index, partialAccessor) - or - result = getImmediateChildOfFallthroughStmt(e, index, partialAccessor) - or - result = getImmediateChildOfPoundAssertStmt(e, index, partialAccessor) - or - result = getImmediateChildOfReturnStmt(e, index, partialAccessor) - or - result = getImmediateChildOfThrowStmt(e, index, partialAccessor) - or - result = getImmediateChildOfYieldStmt(e, index, partialAccessor) - or - result = getImmediateChildOfDoCatchStmt(e, index, partialAccessor) - or - result = getImmediateChildOfDoStmt(e, index, partialAccessor) - or - result = getImmediateChildOfForEachStmt(e, index, partialAccessor) - or - result = getImmediateChildOfRepeatWhileStmt(e, index, partialAccessor) - or - result = getImmediateChildOfSwitchStmt(e, index, partialAccessor) - or - result = getImmediateChildOfGuardStmt(e, index, partialAccessor) - or - result = getImmediateChildOfIfStmt(e, index, partialAccessor) - or - result = getImmediateChildOfWhileStmt(e, index, partialAccessor) - or - result = getImmediateChildOfTypeRepr(e, index, partialAccessor) - or - result = getImmediateChildOfDependentMemberType(e, index, partialAccessor) - or - result = getImmediateChildOfDynamicSelfType(e, index, partialAccessor) - or - result = getImmediateChildOfErrorType(e, index, partialAccessor) - or - result = getImmediateChildOfExistentialType(e, index, partialAccessor) - or - result = getImmediateChildOfInOutType(e, index, partialAccessor) - or - result = getImmediateChildOfLValueType(e, index, partialAccessor) - or - result = getImmediateChildOfModuleType(e, index, partialAccessor) - or - result = getImmediateChildOfParameterizedProtocolType(e, index, partialAccessor) - or - result = getImmediateChildOfProtocolCompositionType(e, index, partialAccessor) - or - result = getImmediateChildOfTupleType(e, index, partialAccessor) - or - result = getImmediateChildOfUnresolvedType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinBridgeObjectType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinDefaultActorStorageType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinExecutorType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinFloatType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinJobType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinNativeObjectType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinRawPointerType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinRawUnsafeContinuationType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinUnsafeValueBufferType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinVectorType(e, index, partialAccessor) - or - result = getImmediateChildOfExistentialMetatypeType(e, index, partialAccessor) - or - result = getImmediateChildOfFunctionType(e, index, partialAccessor) - or - result = getImmediateChildOfGenericFunctionType(e, index, partialAccessor) - or - result = getImmediateChildOfGenericTypeParamType(e, index, partialAccessor) - or - result = getImmediateChildOfMetatypeType(e, index, partialAccessor) - or - result = getImmediateChildOfParenType(e, index, partialAccessor) - or - result = getImmediateChildOfTypeAliasType(e, index, partialAccessor) - or - result = getImmediateChildOfUnboundGenericType(e, index, partialAccessor) - or - result = getImmediateChildOfUnmanagedStorageType(e, index, partialAccessor) - or - result = getImmediateChildOfUnownedStorageType(e, index, partialAccessor) - or - result = getImmediateChildOfWeakStorageType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinIntegerLiteralType(e, index, partialAccessor) - or - result = getImmediateChildOfBuiltinIntegerType(e, index, partialAccessor) - or - result = getImmediateChildOfDictionaryType(e, index, partialAccessor) - or - result = getImmediateChildOfOpaqueTypeArchetypeType(e, index, partialAccessor) - or - result = getImmediateChildOfOpenedArchetypeType(e, index, partialAccessor) - or - result = getImmediateChildOfPrimaryArchetypeType(e, index, partialAccessor) - or - result = getImmediateChildOfArraySliceType(e, index, partialAccessor) - or - result = getImmediateChildOfBoundGenericClassType(e, index, partialAccessor) - or - result = getImmediateChildOfBoundGenericEnumType(e, index, partialAccessor) - or - result = getImmediateChildOfBoundGenericStructType(e, index, partialAccessor) - or - result = getImmediateChildOfClassType(e, index, partialAccessor) - or - result = getImmediateChildOfEnumType(e, index, partialAccessor) - or - result = getImmediateChildOfOptionalType(e, index, partialAccessor) - or - result = getImmediateChildOfProtocolType(e, index, partialAccessor) - or - result = getImmediateChildOfStructType(e, index, partialAccessor) - or - result = getImmediateChildOfVariadicSequenceType(e, index, partialAccessor) - } + private Element getImmediateChildOfStructType(StructType e, int index, string partialPredicateCall) { + + exists(int b, int bNominalType, int n | + b = 0 + and + bNominalType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) + and + n = bNominalType + and ( + none() + or + result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) + )) + } + + private Element getImmediateChildOfVariadicSequenceType(VariadicSequenceType e, int index, string partialPredicateCall) { + + exists(int b, int bUnarySyntaxSugarType, int n | + b = 0 + and + bUnarySyntaxSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) + and + n = bUnarySyntaxSugarType + and ( + none() + or + result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) + )) + } + +cached +Element getImmediateChild(Element e, int index, string partialAccessor) { +// 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, partialAccessor) + or + result = getImmediateChildOfDbFile(e, index, partialAccessor) + or + result = getImmediateChildOfDbLocation(e, index, partialAccessor) + or + result = getImmediateChildOfDiagnostics(e, index, partialAccessor) + or + result = getImmediateChildOfUnknownFile(e, index, partialAccessor) + or + result = getImmediateChildOfUnknownLocation(e, index, partialAccessor) + or + result = getImmediateChildOfAvailabilityInfo(e, index, partialAccessor) + or + result = getImmediateChildOfKeyPathComponent(e, index, partialAccessor) + or + result = getImmediateChildOfUnspecifiedElement(e, index, partialAccessor) + or + result = getImmediateChildOfOtherAvailabilitySpec(e, index, partialAccessor) + or + result = getImmediateChildOfPlatformVersionAvailabilitySpec(e, index, partialAccessor) + or + result = getImmediateChildOfCapturedDecl(e, index, partialAccessor) + or + result = getImmediateChildOfEnumCaseDecl(e, index, partialAccessor) + or + result = getImmediateChildOfExtensionDecl(e, index, partialAccessor) + or + result = getImmediateChildOfIfConfigDecl(e, index, partialAccessor) + or + result = getImmediateChildOfImportDecl(e, index, partialAccessor) + or + result = getImmediateChildOfMissingMemberDecl(e, index, partialAccessor) + or + result = getImmediateChildOfPatternBindingDecl(e, index, partialAccessor) + or + result = getImmediateChildOfPoundDiagnosticDecl(e, index, partialAccessor) + or + result = getImmediateChildOfPrecedenceGroupDecl(e, index, partialAccessor) + or + result = getImmediateChildOfTopLevelCodeDecl(e, index, partialAccessor) + or + result = getImmediateChildOfEnumElementDecl(e, index, partialAccessor) + or + result = getImmediateChildOfInfixOperatorDecl(e, index, partialAccessor) + or + result = getImmediateChildOfPostfixOperatorDecl(e, index, partialAccessor) + or + result = getImmediateChildOfPrefixOperatorDecl(e, index, partialAccessor) + or + result = getImmediateChildOfDeinitializer(e, index, partialAccessor) + or + result = getImmediateChildOfInitializer(e, index, partialAccessor) + or + result = getImmediateChildOfModuleDecl(e, index, partialAccessor) + or + result = getImmediateChildOfSubscriptDecl(e, index, partialAccessor) + or + result = getImmediateChildOfAccessor(e, index, partialAccessor) + or + result = getImmediateChildOfAssociatedTypeDecl(e, index, partialAccessor) + or + result = getImmediateChildOfConcreteVarDecl(e, index, partialAccessor) + or + result = getImmediateChildOfGenericTypeParamDecl(e, index, partialAccessor) + or + result = getImmediateChildOfNamedFunction(e, index, partialAccessor) + or + result = getImmediateChildOfOpaqueTypeDecl(e, index, partialAccessor) + or + result = getImmediateChildOfParamDecl(e, index, partialAccessor) + or + result = getImmediateChildOfTypeAliasDecl(e, index, partialAccessor) + or + result = getImmediateChildOfClassDecl(e, index, partialAccessor) + or + result = getImmediateChildOfEnumDecl(e, index, partialAccessor) + or + result = getImmediateChildOfProtocolDecl(e, index, partialAccessor) + or + result = getImmediateChildOfStructDecl(e, index, partialAccessor) + or + result = getImmediateChildOfArgument(e, index, partialAccessor) + or + result = getImmediateChildOfAppliedPropertyWrapperExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAssignExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBindOptionalExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCaptureListExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDeclRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDefaultArgumentExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDiscardAssignmentExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDotSyntaxBaseIgnoredExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDynamicTypeExpr(e, index, partialAccessor) + or + result = getImmediateChildOfEnumIsCaseExpr(e, index, partialAccessor) + or + result = getImmediateChildOfErrorExpr(e, index, partialAccessor) + or + result = getImmediateChildOfForceValueExpr(e, index, partialAccessor) + or + result = getImmediateChildOfIfExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInOutExpr(e, index, partialAccessor) + or + result = getImmediateChildOfKeyPathApplicationExpr(e, index, partialAccessor) + or + result = getImmediateChildOfKeyPathDotExpr(e, index, partialAccessor) + or + result = getImmediateChildOfKeyPathExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLazyInitializationExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMakeTemporarilyEscapableExpr(e, index, partialAccessor) + or + result = getImmediateChildOfObjCSelectorExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOneWayExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOpaqueValueExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOpenExistentialExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOptionalEvaluationExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOtherInitializerRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOverloadedDeclRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfPropertyWrapperValuePlaceholderExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRebindSelfInInitializerExpr(e, index, partialAccessor) + or + result = getImmediateChildOfSequenceExpr(e, index, partialAccessor) + or + result = getImmediateChildOfSuperRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTapExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTupleElementExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTupleExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTypeExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedDeclRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedDotExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedMemberExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedPatternExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedSpecializeExpr(e, index, partialAccessor) + or + result = getImmediateChildOfVarargExpansionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAbiSafeConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAnyHashableErasureExpr(e, index, partialAccessor) + or + result = getImmediateChildOfArchetypeToSuperExpr(e, index, partialAccessor) + or + result = getImmediateChildOfArrayExpr(e, index, partialAccessor) + or + result = getImmediateChildOfArrayToPointerExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAutoClosureExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAwaitExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBinaryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBridgeFromObjCExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBridgeToObjCExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCallExpr(e, index, partialAccessor) + or + result = getImmediateChildOfClassMetatypeToObjectExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCoerceExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCollectionUpcastConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfConditionalBridgeFromObjCExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCovariantFunctionConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCovariantReturnConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDerivedToBaseExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDestructureTupleExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDictionaryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDifferentiableFunctionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDifferentiableFunctionExtractOriginalExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDotSelfExpr(e, index, partialAccessor) + or + result = getImmediateChildOfErasureExpr(e, index, partialAccessor) + or + result = getImmediateChildOfExistentialMetatypeToObjectExpr(e, index, partialAccessor) + or + result = getImmediateChildOfExplicitClosureExpr(e, index, partialAccessor) + or + result = getImmediateChildOfForceTryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfForeignObjectConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfFunctionConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInOutToPointerExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInjectIntoOptionalExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInterpolatedStringLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLinearFunctionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLinearFunctionExtractOriginalExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLinearToDifferentiableFunctionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLoadExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMemberRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMetatypeConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMethodLookupExpr(e, index, partialAccessor) + or + result = getImmediateChildOfNilLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfObjectLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOptionalTryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfParenExpr(e, index, partialAccessor) + or + result = getImmediateChildOfPointerToPointerExpr(e, index, partialAccessor) + or + result = getImmediateChildOfPostfixUnaryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfPrefixUnaryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfProtocolMetatypeToObjectExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRegexLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfStringToPointerExpr(e, index, partialAccessor) + or + result = getImmediateChildOfSubscriptExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTryExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnderlyingToOpaqueExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnevaluatedInstanceExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedMemberChainResultExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedTypeConversionExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBooleanLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfConditionalCheckedCastExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDotSyntaxCallExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDynamicMemberRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfDynamicSubscriptExpr(e, index, partialAccessor) + or + result = getImmediateChildOfForcedCheckedCastExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInitializerRefCallExpr(e, index, partialAccessor) + or + result = getImmediateChildOfIsExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMagicIdentifierLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfStringLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfFloatLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfIntegerLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAnyPattern(e, index, partialAccessor) + or + result = getImmediateChildOfBindingPattern(e, index, partialAccessor) + or + result = getImmediateChildOfBoolPattern(e, index, partialAccessor) + or + result = getImmediateChildOfEnumElementPattern(e, index, partialAccessor) + or + result = getImmediateChildOfExprPattern(e, index, partialAccessor) + or + result = getImmediateChildOfIsPattern(e, index, partialAccessor) + or + result = getImmediateChildOfNamedPattern(e, index, partialAccessor) + or + result = getImmediateChildOfOptionalSomePattern(e, index, partialAccessor) + or + result = getImmediateChildOfParenPattern(e, index, partialAccessor) + or + result = getImmediateChildOfTuplePattern(e, index, partialAccessor) + or + result = getImmediateChildOfTypedPattern(e, index, partialAccessor) + or + result = getImmediateChildOfCaseLabelItem(e, index, partialAccessor) + or + result = getImmediateChildOfConditionElement(e, index, partialAccessor) + or + result = getImmediateChildOfStmtCondition(e, index, partialAccessor) + or + result = getImmediateChildOfBraceStmt(e, index, partialAccessor) + or + result = getImmediateChildOfBreakStmt(e, index, partialAccessor) + or + result = getImmediateChildOfCaseStmt(e, index, partialAccessor) + or + result = getImmediateChildOfContinueStmt(e, index, partialAccessor) + or + result = getImmediateChildOfDeferStmt(e, index, partialAccessor) + or + result = getImmediateChildOfFailStmt(e, index, partialAccessor) + or + result = getImmediateChildOfFallthroughStmt(e, index, partialAccessor) + or + result = getImmediateChildOfPoundAssertStmt(e, index, partialAccessor) + or + result = getImmediateChildOfReturnStmt(e, index, partialAccessor) + or + result = getImmediateChildOfThrowStmt(e, index, partialAccessor) + or + result = getImmediateChildOfYieldStmt(e, index, partialAccessor) + or + result = getImmediateChildOfDoCatchStmt(e, index, partialAccessor) + or + result = getImmediateChildOfDoStmt(e, index, partialAccessor) + or + result = getImmediateChildOfForEachStmt(e, index, partialAccessor) + or + result = getImmediateChildOfRepeatWhileStmt(e, index, partialAccessor) + or + result = getImmediateChildOfSwitchStmt(e, index, partialAccessor) + or + result = getImmediateChildOfGuardStmt(e, index, partialAccessor) + or + result = getImmediateChildOfIfStmt(e, index, partialAccessor) + or + result = getImmediateChildOfWhileStmt(e, index, partialAccessor) + or + result = getImmediateChildOfTypeRepr(e, index, partialAccessor) + or + result = getImmediateChildOfDependentMemberType(e, index, partialAccessor) + or + result = getImmediateChildOfDynamicSelfType(e, index, partialAccessor) + or + result = getImmediateChildOfErrorType(e, index, partialAccessor) + or + result = getImmediateChildOfExistentialType(e, index, partialAccessor) + or + result = getImmediateChildOfInOutType(e, index, partialAccessor) + or + result = getImmediateChildOfLValueType(e, index, partialAccessor) + or + result = getImmediateChildOfModuleType(e, index, partialAccessor) + or + result = getImmediateChildOfParameterizedProtocolType(e, index, partialAccessor) + or + result = getImmediateChildOfProtocolCompositionType(e, index, partialAccessor) + or + result = getImmediateChildOfTupleType(e, index, partialAccessor) + or + result = getImmediateChildOfUnresolvedType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinBridgeObjectType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinDefaultActorStorageType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinExecutorType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinFloatType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinJobType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinNativeObjectType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinRawPointerType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinRawUnsafeContinuationType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinUnsafeValueBufferType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinVectorType(e, index, partialAccessor) + or + result = getImmediateChildOfExistentialMetatypeType(e, index, partialAccessor) + or + result = getImmediateChildOfFunctionType(e, index, partialAccessor) + or + result = getImmediateChildOfGenericFunctionType(e, index, partialAccessor) + or + result = getImmediateChildOfGenericTypeParamType(e, index, partialAccessor) + or + result = getImmediateChildOfMetatypeType(e, index, partialAccessor) + or + result = getImmediateChildOfParenType(e, index, partialAccessor) + or + result = getImmediateChildOfTypeAliasType(e, index, partialAccessor) + or + result = getImmediateChildOfUnboundGenericType(e, index, partialAccessor) + or + result = getImmediateChildOfUnmanagedStorageType(e, index, partialAccessor) + or + result = getImmediateChildOfUnownedStorageType(e, index, partialAccessor) + or + result = getImmediateChildOfWeakStorageType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinIntegerLiteralType(e, index, partialAccessor) + or + result = getImmediateChildOfBuiltinIntegerType(e, index, partialAccessor) + or + result = getImmediateChildOfDictionaryType(e, index, partialAccessor) + or + result = getImmediateChildOfOpaqueTypeArchetypeType(e, index, partialAccessor) + or + result = getImmediateChildOfOpenedArchetypeType(e, index, partialAccessor) + or + result = getImmediateChildOfPrimaryArchetypeType(e, index, partialAccessor) + or + result = getImmediateChildOfArraySliceType(e, index, partialAccessor) + or + result = getImmediateChildOfBoundGenericClassType(e, index, partialAccessor) + or + result = getImmediateChildOfBoundGenericEnumType(e, index, partialAccessor) + or + result = getImmediateChildOfBoundGenericStructType(e, index, partialAccessor) + or + result = getImmediateChildOfClassType(e, index, partialAccessor) + or + result = getImmediateChildOfEnumType(e, index, partialAccessor) + or + result = getImmediateChildOfOptionalType(e, index, partialAccessor) + or + result = getImmediateChildOfProtocolType(e, index, partialAccessor) + or + result = getImmediateChildOfStructType(e, index, partialAccessor) + or + result = getImmediateChildOfVariadicSequenceType(e, index, partialAccessor) +} } /** - * Gets the "immediate" parent of `e`. "Immediate" means not taking into account node resolution: for example - * if `e` has conversions, `getImmediateParent(e)` will give the innermost conversion in the hidden AST. - */ +* Gets the "immediate" parent of `e`. "Immediate" means not taking into account node resolution: for example +* if `e` has conversions, `getImmediateParent(e)` will give the innermost conversion in the hidden AST. +*/ Element getImmediateParent(Element e) { - // `unique` is used here to tell the optimizer that there is in fact only one result - // this is tested by the `library-tests/parent/no_double_parents.ql` test - result = unique(Element x | e = Impl::getImmediateChild(x, _, _) | x) + // `unique` is used here to tell the optimizer that there is in fact only one result + // this is tested by the `library-tests/parent/no_double_parents.ql` test + result = unique(Element x | e = Impl::getImmediateChild(x, _, _) | x) } /** - * Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. - */ +* Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. +*/ Element getImmediateChildAndAccessor(Element e, int index, string accessor) { - exists(string partialAccessor | - result = Impl::getImmediateChild(e, index, partialAccessor) and - accessor = "get" + partialAccessor - ) + exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor) and accessor = "get" + partialAccessor) } /** - * Gets the child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. - */ +* Gets the child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. +*/ Element getChildAndAccessor(Element e, int index, string accessor) { - exists(string partialAccessor | - result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and - accessor = "get" + partialAccessor - ) + exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and accessor = "get" + partialAccessor) } diff --git a/swift/ql/lib/codeql/swift/generated/Raw.qll b/swift/ql/lib/codeql/swift/generated/Raw.qll index b7d3cd12bbc..a2880f379ca 100644 --- a/swift/ql/lib/codeql/swift/generated/Raw.qll +++ b/swift/ql/lib/codeql/swift/generated/Raw.qll @@ -8,160 +8,226 @@ module Raw { */ class Element extends @element { string toString() { none() } + /** * Holds if this element is unknown. + * */ - predicate isUnknown() { element_is_unknown(this) } + predicate isUnknown() { + element_is_unknown(this) + } } /** * INTERNAL: Do not use. */ class Callable extends @callable, Element { + + + /** * Gets the name of this callable, if it exists. * * The name includes argument labels of the callable, for example `myFunction(arg:)`. */ - string getName() { callable_names(this, result) } - + string getName() { + callable_names(this, result) + } /** * Gets the self parameter of this callable, if it exists. + * */ - ParamDecl getSelfParam() { callable_self_params(this, result) } - + ParamDecl getSelfParam() { + callable_self_params(this, result) + } /** * Gets the `index`th parameter of this callable (0-based). + * */ - ParamDecl getParam(int index) { callable_params(this, index, result) } - + ParamDecl getParam(int index) { + callable_params(this, index, result) + } /** * Gets the body of this callable, if it exists. * * The body is absent within protocol declarations. */ - BraceStmt getBody() { callable_bodies(this, result) } - + BraceStmt getBody() { + callable_bodies(this, result) + } /** * Gets the `index`th capture of this callable (0-based). + * */ - CapturedDecl getCapture(int index) { callable_captures(this, index, result) } + CapturedDecl getCapture(int index) { + callable_captures(this, index, result) + } } /** * INTERNAL: Do not use. */ class File extends @file, Element { - /** - * Gets the name of this file. - */ - string getName() { files(this, result) } + + /** - * Holds if this file is successfully extracted. + * Gets the name of this file. + * */ - predicate isSuccessfullyExtracted() { file_is_successfully_extracted(this) } + string getName() { + files(this, result) + } + /** + * Holds if this file is successfully extracted. + * + */ + predicate isSuccessfullyExtracted() { + file_is_successfully_extracted(this) + } } /** * INTERNAL: Do not use. */ class Locatable extends @locatable, Element { + + + /** * Gets the location associated with this element in the code, if it exists. + * */ - Location getLocation() { locatable_locations(this, result) } + Location getLocation() { + locatable_locations(this, result) + } } /** * INTERNAL: Do not use. */ class Location extends @location, Element { + + + /** * Gets the file of this location. + * */ - File getFile() { locations(this, result, _, _, _, _) } - + File getFile() { + locations(this, result, _, _, _, _) + } /** * Gets the start line of this location. + * */ - int getStartLine() { locations(this, _, result, _, _, _) } - + int getStartLine() { + locations(this, _, result, _, _, _) + } /** * Gets the start column of this location. + * */ - int getStartColumn() { locations(this, _, _, result, _, _) } - + int getStartColumn() { + locations(this, _, _, result, _, _) + } /** * Gets the end line of this location. + * */ - int getEndLine() { locations(this, _, _, _, result, _) } - + int getEndLine() { + locations(this, _, _, _, result, _) + } /** * Gets the end column of this location. + * */ - int getEndColumn() { locations(this, _, _, _, _, result) } + int getEndColumn() { + locations(this, _, _, _, _, result) + } } /** * INTERNAL: Do not use. */ - class AstNode extends @ast_node, Locatable { } + class AstNode extends @ast_node, Locatable { + + + + } /** * INTERNAL: Do not use. */ class Comment extends @comment, Locatable { + override string toString() { result = "Comment" } /** * Gets the text of this comment. + * */ - string getText() { comments(this, result) } + string getText() { + comments(this, result) + } } /** * INTERNAL: Do not use. */ class DbFile extends @db_file, File { + override string toString() { result = "DbFile" } + } /** * INTERNAL: Do not use. */ class DbLocation extends @db_location, Location { + override string toString() { result = "DbLocation" } + } /** * INTERNAL: Do not use. */ class Diagnostics extends @diagnostics, Locatable { + override string toString() { result = "Diagnostics" } /** * Gets the text of this diagnostics. + * */ - string getText() { diagnostics(this, result, _) } - + string getText() { + diagnostics(this, result, _) + } /** * Gets the kind of this diagnostics. + * */ - int getKind() { diagnostics(this, _, result) } + int getKind() { + diagnostics(this, _, result) + } } /** * INTERNAL: Do not use. * The superclass of all elements indicating some kind of error. */ - class ErrorElement extends @error_element, Locatable { } + class ErrorElement extends @error_element, Locatable { + + + + } /** * INTERNAL: Do not use. * An availability condition of an `if`, `while`, or `guard` statements. - * + * * Examples: * ``` * if #available(iOS 12, *) { @@ -175,17 +241,23 @@ module Raw { * ``` */ class AvailabilityInfo extends @availability_info, AstNode { + override string toString() { result = "AvailabilityInfo" } /** * Holds if it is #unavailable as opposed to #available. + * */ - predicate isUnavailable() { availability_info_is_unavailable(this) } - + predicate isUnavailable() { + availability_info_is_unavailable(this) + } /** * Gets the `index`th spec of this availability info (0-based). + * */ - AvailabilitySpec getSpec(int index) { availability_info_specs(this, index, result) } + AvailabilitySpec getSpec(int index) { + availability_info_specs(this, index, result) + } } /** @@ -195,47 +267,57 @@ module Raw { * if #available(iOS 12, *) * ``` */ - class AvailabilitySpec extends @availability_spec, AstNode { } + class AvailabilitySpec extends @availability_spec, AstNode { + + + + } /** * INTERNAL: Do not use. * A component of a `KeyPathExpr`. */ class KeyPathComponent extends @key_path_component, AstNode { + override string toString() { result = "KeyPathComponent" } /** * Gets the kind of key path component. * * INTERNAL: Do not use. - * + * * This is 3 for properties, 4 for array and dictionary subscripts, 5 for optional forcing * (`!`), 6 for optional chaining (`?`), 7 for implicit optional wrapping, 8 for `self`, * and 9 for tuple element indexing. - * + * * The following values should not appear: 0 for invalid components, 1 for unresolved * properties, 2 for unresolved subscripts, 10 for #keyPath dictionary keys, and 11 for * implicit IDE code completion data. */ - int getKind() { key_path_components(this, result, _) } - + int getKind() { + key_path_components(this, result, _) + } /** * Gets the `index`th argument to an array or dictionary subscript expression (0-based). + * */ Argument getSubscriptArgument(int index) { key_path_component_subscript_arguments(this, index, result) } - /** * Gets the tuple index of this key path component, if it exists. + * */ - int getTupleIndex() { key_path_component_tuple_indices(this, result) } - + int getTupleIndex() { + key_path_component_tuple_indices(this, result) + } /** * Gets the property or subscript operator, if it exists. + * */ - ValueDecl getDeclRef() { key_path_component_decl_refs(this, result) } - + ValueDecl getDeclRef() { + key_path_component_decl_refs(this, result) + } /** * Gets the return type of this component application. * @@ -243,34 +325,46 @@ module Raw { * path; an optional-wrapping component is inserted if required to produce an optional type * as the final output. */ - Type getComponentType() { key_path_components(this, _, result) } + Type getComponentType() { + key_path_components(this, _, result) + } } /** * INTERNAL: Do not use. */ class UnspecifiedElement extends @unspecified_element, ErrorElement { + override string toString() { result = "UnspecifiedElement" } /** * Gets the parent of this unspecified element, if it exists. + * */ - Element getParent() { unspecified_element_parents(this, result) } - + Element getParent() { + unspecified_element_parents(this, result) + } /** * Gets the property of this unspecified element. + * */ - string getProperty() { unspecified_elements(this, result, _) } - + string getProperty() { + unspecified_elements(this, result, _) + } /** * Gets the index of this unspecified element, if it exists. + * */ - int getIndex() { unspecified_element_indices(this, result) } - + int getIndex() { + unspecified_element_indices(this, result) + } /** * Gets the error of this unspecified element. + * */ - string getError() { unspecified_elements(this, _, result) } + string getError() { + unspecified_elements(this, _, result) + } } /** @@ -278,38 +372,49 @@ module Raw { * A wildcard availability spec `*` */ class OtherAvailabilitySpec extends @other_availability_spec, AvailabilitySpec { + override string toString() { result = "OtherAvailabilitySpec" } + } /** * INTERNAL: Do not use. * An availability spec based on platform and version, for example `macOS 12` or `watchOS 14` */ - class PlatformVersionAvailabilitySpec extends @platform_version_availability_spec, - AvailabilitySpec - { + class PlatformVersionAvailabilitySpec extends @platform_version_availability_spec, AvailabilitySpec { + override string toString() { result = "PlatformVersionAvailabilitySpec" } /** * Gets the platform of this platform version availability spec. + * */ - string getPlatform() { platform_version_availability_specs(this, result, _) } - + string getPlatform() { + platform_version_availability_specs(this, result, _) + } /** * Gets the version of this platform version availability spec. + * */ - string getVersion() { platform_version_availability_specs(this, _, result) } + string getVersion() { + platform_version_availability_specs(this, _, result) + } } /** * INTERNAL: Do not use. */ class Decl extends @decl, AstNode { + + + /** * Gets the module of this declaration. + * */ - ModuleDecl getModule() { decls(this, result) } - + ModuleDecl getModule() { + decls(this, result) + } /** * Gets the `index`th member of this declaration (0-based). * @@ -317,15 +422,21 @@ module Raw { * on the order of members given by `getMember`. In some cases the order of members may not * align with expectations, and could change in future releases. */ - Decl getMember(int index) { decl_members(this, index, result) } + Decl getMember(int index) { + decl_members(this, index, result) + } } /** * INTERNAL: Do not use. */ class GenericContext extends @generic_context, Element { + + + /** * Gets the `index`th generic type parameter of this generic context (0-based). + * */ GenericTypeParamDecl getGenericTypeParam(int index) { generic_context_generic_type_params(this, index, result) @@ -336,85 +447,115 @@ module Raw { * INTERNAL: Do not use. */ class CapturedDecl extends @captured_decl, Decl { + override string toString() { result = "CapturedDecl" } /** * Gets the the declaration captured by the parent closure. + * */ - ValueDecl getDecl() { captured_decls(this, result) } - + ValueDecl getDecl() { + captured_decls(this, result) + } /** * Holds if this captured declaration is direct. + * */ - predicate isDirect() { captured_decl_is_direct(this) } - + predicate isDirect() { + captured_decl_is_direct(this) + } /** * Holds if this captured declaration is escaping. + * */ - predicate isEscaping() { captured_decl_is_escaping(this) } + predicate isEscaping() { + captured_decl_is_escaping(this) + } } /** * INTERNAL: Do not use. */ class EnumCaseDecl extends @enum_case_decl, Decl { + override string toString() { result = "EnumCaseDecl" } /** * Gets the `index`th element of this enum case declaration (0-based). + * */ - EnumElementDecl getElement(int index) { enum_case_decl_elements(this, index, result) } + EnumElementDecl getElement(int index) { + enum_case_decl_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class ExtensionDecl extends @extension_decl, GenericContext, Decl { + override string toString() { result = "ExtensionDecl" } /** * Gets the extended type declaration of this extension declaration. + * */ - NominalTypeDecl getExtendedTypeDecl() { extension_decls(this, result) } - + NominalTypeDecl getExtendedTypeDecl() { + extension_decls(this, result) + } /** * Gets the `index`th protocol of this extension declaration (0-based). + * */ - ProtocolDecl getProtocol(int index) { extension_decl_protocols(this, index, result) } + ProtocolDecl getProtocol(int index) { + extension_decl_protocols(this, index, result) + } } /** * INTERNAL: Do not use. */ class IfConfigDecl extends @if_config_decl, Decl { + override string toString() { result = "IfConfigDecl" } /** * 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) } + AstNode getActiveElement(int index) { + if_config_decl_active_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class ImportDecl extends @import_decl, Decl { + override string toString() { result = "ImportDecl" } /** * Holds if this import declaration is exported. + * */ - predicate isExported() { import_decl_is_exported(this) } - + predicate isExported() { + import_decl_is_exported(this) + } /** * Gets the imported module of this import declaration, if it exists. + * */ - ModuleDecl getImportedModule() { import_decl_imported_modules(this, result) } - + ModuleDecl getImportedModule() { + import_decl_imported_modules(this, result) + } /** * Gets the `index`th declaration of this import declaration (0-based). + * */ - ValueDecl getDeclaration(int index) { import_decl_declarations(this, index, result) } + ValueDecl getDeclaration(int index) { + import_decl_declarations(this, index, result) + } } /** @@ -422,39 +563,55 @@ module Raw { * A placeholder for missing declarations that can arise on object deserialization. */ class MissingMemberDecl extends @missing_member_decl, Decl { + override string toString() { result = "MissingMemberDecl" } /** * Gets the name of this missing member declaration. + * */ - string getName() { missing_member_decls(this, result) } + string getName() { + missing_member_decls(this, result) + } } /** * INTERNAL: Do not use. */ class OperatorDecl extends @operator_decl, Decl { + + + /** * Gets the name of this operator declaration. + * */ - string getName() { operator_decls(this, result) } + string getName() { + operator_decls(this, result) + } } /** * INTERNAL: Do not use. */ class PatternBindingDecl extends @pattern_binding_decl, Decl { + override string toString() { result = "PatternBindingDecl" } /** * Gets the `index`th init of this pattern binding declaration (0-based), if it exists. + * */ - Expr getInit(int index) { pattern_binding_decl_inits(this, index, result) } - + Expr getInit(int index) { + pattern_binding_decl_inits(this, index, result) + } /** * Gets the `index`th pattern of this pattern binding declaration (0-based). + * */ - Pattern getPattern(int index) { pattern_binding_decl_patterns(this, index, result) } + Pattern getPattern(int index) { + pattern_binding_decl_patterns(this, index, result) + } } /** @@ -462,6 +619,7 @@ module Raw { * A diagnostic directive, which is either `#error` or `#warning`. */ class PoundDiagnosticDecl extends @pound_diagnostic_decl, Decl { + override string toString() { result = "PoundDiagnosticDecl" } /** @@ -469,189 +627,269 @@ module Raw { * * This is 1 for `#error` and 2 for `#warning`. */ - int getKind() { pound_diagnostic_decls(this, result, _) } - + int getKind() { + pound_diagnostic_decls(this, result, _) + } /** * Gets the message of this pound diagnostic declaration. + * */ - StringLiteralExpr getMessage() { pound_diagnostic_decls(this, _, result) } + StringLiteralExpr getMessage() { + pound_diagnostic_decls(this, _, result) + } } /** * INTERNAL: Do not use. */ class PrecedenceGroupDecl extends @precedence_group_decl, Decl { + override string toString() { result = "PrecedenceGroupDecl" } + } /** * INTERNAL: Do not use. */ class TopLevelCodeDecl extends @top_level_code_decl, Decl { + override string toString() { result = "TopLevelCodeDecl" } /** * Gets the body of this top level code declaration. + * */ - BraceStmt getBody() { top_level_code_decls(this, result) } + BraceStmt getBody() { + top_level_code_decls(this, result) + } } /** * INTERNAL: Do not use. */ class ValueDecl extends @value_decl, Decl { + + + /** * Gets the interface type of this value declaration. + * */ - Type getInterfaceType() { value_decls(this, result) } + Type getInterfaceType() { + value_decls(this, result) + } } /** * INTERNAL: Do not use. */ class AbstractStorageDecl extends @abstract_storage_decl, ValueDecl { + + + /** * Gets the `index`th accessor of this abstract storage declaration (0-based). + * */ - Accessor getAccessor(int index) { abstract_storage_decl_accessors(this, index, result) } + Accessor getAccessor(int index) { + abstract_storage_decl_accessors(this, index, result) + } } /** * INTERNAL: Do not use. */ class EnumElementDecl extends @enum_element_decl, ValueDecl { + override string toString() { result = "EnumElementDecl" } /** * Gets the name of this enum element declaration. + * */ - string getName() { enum_element_decls(this, result) } - + string getName() { + enum_element_decls(this, result) + } /** * Gets the `index`th parameter of this enum element declaration (0-based). + * */ - ParamDecl getParam(int index) { enum_element_decl_params(this, index, result) } + ParamDecl getParam(int index) { + enum_element_decl_params(this, index, result) + } } /** * INTERNAL: Do not use. */ - class Function extends @function, GenericContext, ValueDecl, Callable { } + class Function extends @function, GenericContext, ValueDecl, Callable { + + + + } /** * INTERNAL: Do not use. */ class InfixOperatorDecl extends @infix_operator_decl, OperatorDecl { + override string toString() { result = "InfixOperatorDecl" } /** * Gets the precedence group of this infix operator declaration, if it exists. + * */ - PrecedenceGroupDecl getPrecedenceGroup() { infix_operator_decl_precedence_groups(this, result) } + PrecedenceGroupDecl getPrecedenceGroup() { + infix_operator_decl_precedence_groups(this, result) + } } /** * INTERNAL: Do not use. */ class PostfixOperatorDecl extends @postfix_operator_decl, OperatorDecl { + override string toString() { result = "PostfixOperatorDecl" } + } /** * INTERNAL: Do not use. */ class PrefixOperatorDecl extends @prefix_operator_decl, OperatorDecl { + override string toString() { result = "PrefixOperatorDecl" } + } /** * INTERNAL: Do not use. */ class TypeDecl extends @type_decl, ValueDecl { - /** - * Gets the name of this type declaration. - */ - string getName() { type_decls(this, result) } + + /** - * Gets the `index`th base type of this type declaration (0-based). + * Gets the name of this type declaration. + * */ - Type getBaseType(int index) { type_decl_base_types(this, index, result) } + string getName() { + type_decls(this, result) + } + /** + * Gets the `index`th base type of this type declaration (0-based). + * + */ + Type getBaseType(int index) { + type_decl_base_types(this, index, result) + } } /** * INTERNAL: Do not use. */ - class AbstractTypeParamDecl extends @abstract_type_param_decl, TypeDecl { } + class AbstractTypeParamDecl extends @abstract_type_param_decl, TypeDecl { + + + + } /** * INTERNAL: Do not use. */ - class AccessorOrNamedFunction extends @accessor_or_named_function, Function { } + class AccessorOrNamedFunction extends @accessor_or_named_function, Function { + + + + } /** * INTERNAL: Do not use. */ class Deinitializer extends @deinitializer, Function { + override string toString() { result = "Deinitializer" } + } /** * INTERNAL: Do not use. */ - class GenericTypeDecl extends @generic_type_decl, GenericContext, TypeDecl { } + class GenericTypeDecl extends @generic_type_decl, GenericContext, TypeDecl { + + + + } /** * INTERNAL: Do not use. */ class Initializer extends @initializer, Function { + override string toString() { result = "Initializer" } + } /** * INTERNAL: Do not use. */ class ModuleDecl extends @module_decl, TypeDecl { + override string toString() { result = "ModuleDecl" } /** * Holds if this module is the built-in one. + * */ - predicate isBuiltinModule() { module_decl_is_builtin_module(this) } - + predicate isBuiltinModule() { + module_decl_is_builtin_module(this) + } /** * Holds if this module is a system one. + * */ - predicate isSystemModule() { module_decl_is_system_module(this) } - + predicate isSystemModule() { + module_decl_is_system_module(this) + } /** * Gets the `index`th imported module of this module declaration (0-based). - *Gets any of the imported modules of this module declaration. +Gets any of the imported modules of this module declaration. + * */ - ModuleDecl getAnImportedModule() { module_decl_imported_modules(this, result) } - + ModuleDecl getAnImportedModule() { + module_decl_imported_modules(this, result) + } /** * Gets the `index`th exported module of this module declaration (0-based). - *Gets any of the exported modules of this module declaration. +Gets any of the exported modules of this module declaration. + * */ - ModuleDecl getAnExportedModule() { module_decl_exported_modules(this, result) } + ModuleDecl getAnExportedModule() { + module_decl_exported_modules(this, result) + } } /** * INTERNAL: Do not use. */ class SubscriptDecl extends @subscript_decl, AbstractStorageDecl, GenericContext { + override string toString() { result = "SubscriptDecl" } /** * Gets the `index`th parameter of this subscript declaration (0-based). + * */ - ParamDecl getParam(int index) { subscript_decl_params(this, index, result) } - + ParamDecl getParam(int index) { + subscript_decl_params(this, index, result) + } /** * Gets the element type of this subscript declaration. + * */ - Type getElementType() { subscript_decls(this, result) } + Type getElementType() { + subscript_decls(this, result) + } } /** @@ -674,31 +912,44 @@ module Raw { * * ... */ class VarDecl extends @var_decl, AbstractStorageDecl { + + + /** * Gets the name of this variable declaration. + * */ - string getName() { var_decls(this, result, _) } - + string getName() { + var_decls(this, result, _) + } /** * Gets the type of this variable declaration. + * */ - Type getType() { var_decls(this, _, result) } - + Type getType() { + var_decls(this, _, result) + } /** * Gets the attached property wrapper type of this variable declaration, if it exists. + * */ - Type getAttachedPropertyWrapperType() { var_decl_attached_property_wrapper_types(this, result) } - + Type getAttachedPropertyWrapperType() { + var_decl_attached_property_wrapper_types(this, result) + } /** * Gets the parent pattern of this variable declaration, if it exists. + * */ - Pattern getParentPattern() { var_decl_parent_patterns(this, result) } - + Pattern getParentPattern() { + var_decl_parent_patterns(this, result) + } /** * Gets the parent initializer of this variable declaration, if it exists. + * */ - Expr getParentInitializer() { var_decl_parent_initializers(this, result) } - + Expr getParentInitializer() { + var_decl_parent_initializers(this, result) + } /** * Gets the property wrapper backing variable binding of this variable declaration, if it exists. * @@ -708,16 +959,15 @@ module Raw { PatternBindingDecl getPropertyWrapperBackingVarBinding() { var_decl_property_wrapper_backing_var_bindings(this, result) } - /** * Gets the property wrapper backing variable of this variable declaration, if it exists. * * This is the compiler synthesized variable holding the property wrapper for this variable, if any. - * + * * For a property wrapper like * ``` * @propertyWrapper struct MyWrapper { ... } - * + * * struct S { * @MyWrapper var x : Int = 42 * } @@ -728,8 +978,9 @@ module Raw { * ``` * This predicate returns such variable declaration. */ - VarDecl getPropertyWrapperBackingVar() { var_decl_property_wrapper_backing_vars(this, result) } - + VarDecl getPropertyWrapperBackingVar() { + var_decl_property_wrapper_backing_vars(this, result) + } /** * Gets the property wrapper projection variable binding of this variable declaration, if it exists. * @@ -739,21 +990,20 @@ module Raw { PatternBindingDecl getPropertyWrapperProjectionVarBinding() { var_decl_property_wrapper_projection_var_bindings(this, result) } - /** * Gets the property wrapper projection variable of this variable declaration, if it exists. * * If this variable has a property wrapper with a projected value, this is the corresponding * synthesized variable holding that projected value, accessible with this variable's name * prefixed with `$`. - * + * * For a property wrapper like * ``` * @propertyWrapper struct MyWrapper { * var projectedValue : Bool * ... * } - * + * * struct S { * @MyWrapper var x : Int = 42 * } @@ -774,60 +1024,81 @@ module Raw { * INTERNAL: Do not use. */ class Accessor extends @accessor, AccessorOrNamedFunction { + override string toString() { result = "Accessor" } /** * Holds if this accessor is a getter. + * */ - predicate isGetter() { accessor_is_getter(this) } - + predicate isGetter() { + accessor_is_getter(this) + } /** * Holds if this accessor is a setter. + * */ - predicate isSetter() { accessor_is_setter(this) } - + predicate isSetter() { + accessor_is_setter(this) + } /** * Holds if this accessor is a `willSet`, called before the property is set. + * */ - predicate isWillSet() { accessor_is_will_set(this) } - + predicate isWillSet() { + accessor_is_will_set(this) + } /** * Holds if this accessor is a `didSet`, called after the property is set. + * */ - predicate isDidSet() { accessor_is_did_set(this) } - + predicate isDidSet() { + accessor_is_did_set(this) + } /** * Holds if this accessor is a `_read` coroutine, yielding a borrowed value of the property. + * */ - predicate isRead() { accessor_is_read(this) } - + predicate isRead() { + accessor_is_read(this) + } /** * Holds if this accessor is a `_modify` coroutine, yielding an inout value of the property. + * */ - predicate isModify() { accessor_is_modify(this) } - + predicate isModify() { + accessor_is_modify(this) + } /** * Holds if this accessor is an `unsafeAddress` immutable addressor. + * */ - predicate isUnsafeAddress() { accessor_is_unsafe_address(this) } - + predicate isUnsafeAddress() { + accessor_is_unsafe_address(this) + } /** * Holds if this accessor is an `unsafeMutableAddress` mutable addressor. + * */ - predicate isUnsafeMutableAddress() { accessor_is_unsafe_mutable_address(this) } + predicate isUnsafeMutableAddress() { + accessor_is_unsafe_mutable_address(this) + } } /** * INTERNAL: Do not use. */ class AssociatedTypeDecl extends @associated_type_decl, AbstractTypeParamDecl { + override string toString() { result = "AssociatedTypeDecl" } + } /** * INTERNAL: Do not use. */ class ConcreteVarDecl extends @concrete_var_decl, VarDecl { + override string toString() { result = "ConcreteVarDecl" } /** @@ -835,38 +1106,50 @@ module Raw { * * This is 0 if the variable was introduced with `let` and 1 if it was introduced with `var`. */ - int getIntroducerInt() { concrete_var_decls(this, result) } + int getIntroducerInt() { + concrete_var_decls(this, result) + } } /** * INTERNAL: Do not use. */ class GenericTypeParamDecl extends @generic_type_param_decl, AbstractTypeParamDecl { + override string toString() { result = "GenericTypeParamDecl" } + } /** * INTERNAL: Do not use. */ class NamedFunction extends @named_function, AccessorOrNamedFunction { + override string toString() { result = "NamedFunction" } + } /** * INTERNAL: Do not use. */ class NominalTypeDecl extends @nominal_type_decl, GenericTypeDecl { + + + /** * Gets the type of this nominal type declaration. + * */ - Type getType() { nominal_type_decls(this, result) } + Type getType() { + nominal_type_decls(this, result) + } } /** * INTERNAL: Do not use. * A declaration of an opaque type, that is formally equivalent to a given type but abstracts it * away. - * + * * Such a declaration is implicitly given when a declaration is written with an opaque result type, * for example * ``` @@ -875,15 +1158,19 @@ module Raw { * See https://docs.swift.org/swift-book/LanguageGuide/OpaqueTypes.html. */ class OpaqueTypeDecl extends @opaque_type_decl, GenericTypeDecl { + override string toString() { result = "OpaqueTypeDecl" } /** * Gets the naming declaration of this opaque type declaration. + * */ - ValueDecl getNamingDeclaration() { opaque_type_decls(this, result) } - + ValueDecl getNamingDeclaration() { + opaque_type_decls(this, result) + } /** * Gets the `index`th opaque generic parameter of this opaque type declaration (0-based). + * */ GenericTypeParamType getOpaqueGenericParam(int index) { opaque_type_decl_opaque_generic_params(this, index, result) @@ -894,13 +1181,16 @@ module Raw { * INTERNAL: Do not use. */ class ParamDecl extends @param_decl, VarDecl { + override string toString() { result = "ParamDecl" } /** * Holds if this is an `inout` parameter. + * */ - predicate isInout() { param_decl_is_inout(this) } - + predicate isInout() { + param_decl_is_inout(this) + } /** * Gets the property wrapper local wrapped variable binding of this parameter declaration, if it exists. * @@ -910,7 +1200,6 @@ module Raw { PatternBindingDecl getPropertyWrapperLocalWrappedVarBinding() { param_decl_property_wrapper_local_wrapped_var_bindings(this, result) } - /** * Gets the property wrapper local wrapped variable of this parameter declaration, if it exists. * @@ -930,6 +1219,7 @@ module Raw { * ``` */ class TypeAliasDecl extends @type_alias_decl, GenericTypeDecl { + override string toString() { result = "TypeAliasDecl" } /** @@ -940,52 +1230,68 @@ module Raw { * typealias MyInt = Int * ``` */ - Type getAliasedType() { type_alias_decls(this, result) } + Type getAliasedType() { + type_alias_decls(this, result) + } } /** * INTERNAL: Do not use. */ class ClassDecl extends @class_decl, NominalTypeDecl { + override string toString() { result = "ClassDecl" } + } /** * INTERNAL: Do not use. */ class EnumDecl extends @enum_decl, NominalTypeDecl { + override string toString() { result = "EnumDecl" } + } /** * INTERNAL: Do not use. */ class ProtocolDecl extends @protocol_decl, NominalTypeDecl { + override string toString() { result = "ProtocolDecl" } + } /** * INTERNAL: Do not use. */ class StructDecl extends @struct_decl, NominalTypeDecl { + override string toString() { result = "StructDecl" } + } /** * INTERNAL: Do not use. */ class Argument extends @argument, Locatable { + override string toString() { result = "Argument" } /** * Gets the label of this argument. + * */ - string getLabel() { arguments(this, result, _) } - + string getLabel() { + arguments(this, result, _) + } /** * Gets the expression of this argument. + * */ - Expr getExpr() { arguments(this, _, result) } + Expr getExpr() { + arguments(this, _, result) + } } /** @@ -993,20 +1299,32 @@ module Raw { * The base class for all expressions in Swift. */ class Expr extends @expr, AstNode { + + + /** * Gets the type of this expression, if it exists. + * */ - Type getType() { expr_types(this, result) } + Type getType() { + expr_types(this, result) + } } /** * INTERNAL: Do not use. */ class AnyTryExpr extends @any_try_expr, Expr { + + + /** * Gets the sub expression of this any try expression. + * */ - Expr getSubExpr() { any_try_exprs(this, result) } + Expr getSubExpr() { + any_try_exprs(this, result) + } } /** @@ -1014,6 +1332,7 @@ module Raw { * An implicit application of a property wrapper on the argument of a call. */ class AppliedPropertyWrapperExpr extends @applied_property_wrapper_expr, Expr { + override string toString() { result = "AppliedPropertyWrapperExpr" } /** @@ -1021,313 +1340,430 @@ module Raw { * * This is 1 for a wrapped value and 2 for a projected one. */ - int getKind() { applied_property_wrapper_exprs(this, result, _, _) } - + int getKind() { + applied_property_wrapper_exprs(this, result, _, _) + } /** * Gets the value of this applied property wrapper expression. * * The value on which the wrapper is applied. */ - Expr getValue() { applied_property_wrapper_exprs(this, _, result, _) } - + Expr getValue() { + applied_property_wrapper_exprs(this, _, result, _) + } /** * Gets the parameter declaration owning this wrapper application. + * */ - ParamDecl getParam() { applied_property_wrapper_exprs(this, _, _, result) } + ParamDecl getParam() { + applied_property_wrapper_exprs(this, _, _, result) + } } /** * INTERNAL: Do not use. */ class ApplyExpr extends @apply_expr, Expr { - /** - * Gets the function being applied. - */ - Expr getFunction() { apply_exprs(this, result) } + + /** - * Gets the `index`th argument passed to the applied function (0-based). + * Gets the function being applied. + * */ - Argument getArgument(int index) { apply_expr_arguments(this, index, result) } + Expr getFunction() { + apply_exprs(this, result) + } + /** + * Gets the `index`th argument passed to the applied function (0-based). + * + */ + Argument getArgument(int index) { + apply_expr_arguments(this, index, result) + } } /** * INTERNAL: Do not use. */ class AssignExpr extends @assign_expr, Expr { + override string toString() { result = "AssignExpr" } /** * Gets the dest of this assign expression. + * */ - Expr getDest() { assign_exprs(this, result, _) } - + Expr getDest() { + assign_exprs(this, result, _) + } /** * Gets the source of this assign expression. + * */ - Expr getSource() { assign_exprs(this, _, result) } + Expr getSource() { + assign_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class BindOptionalExpr extends @bind_optional_expr, Expr { + override string toString() { result = "BindOptionalExpr" } /** * Gets the sub expression of this bind optional expression. + * */ - Expr getSubExpr() { bind_optional_exprs(this, result) } + Expr getSubExpr() { + bind_optional_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class CaptureListExpr extends @capture_list_expr, Expr { + override string toString() { result = "CaptureListExpr" } /** * Gets the `index`th binding declaration of this capture list expression (0-based). + * */ PatternBindingDecl getBindingDecl(int index) { capture_list_expr_binding_decls(this, index, result) } - /** * Gets the closure body of this capture list expression. + * */ - ClosureExpr getClosureBody() { capture_list_exprs(this, result) } + ClosureExpr getClosureBody() { + capture_list_exprs(this, result) + } } /** * INTERNAL: Do not use. */ - class ClosureExpr extends @closure_expr, Expr, Callable { } + class ClosureExpr extends @closure_expr, Expr, Callable { + + + + } /** * INTERNAL: Do not use. */ - class CollectionExpr extends @collection_expr, Expr { } + class CollectionExpr extends @collection_expr, Expr { + + + + } /** * INTERNAL: Do not use. */ class DeclRefExpr extends @decl_ref_expr, Expr { + override string toString() { result = "DeclRefExpr" } /** * Gets the declaration of this declaration reference expression. + * */ - Decl getDecl() { decl_ref_exprs(this, result) } - + Decl getDecl() { + decl_ref_exprs(this, result) + } /** * Gets the `index`th replacement type of this declaration reference expression (0-based). + * */ - Type getReplacementType(int index) { decl_ref_expr_replacement_types(this, index, result) } - + Type getReplacementType(int index) { + decl_ref_expr_replacement_types(this, index, result) + } /** * Holds if this declaration reference expression has direct to storage semantics. + * */ - predicate hasDirectToStorageSemantics() { decl_ref_expr_has_direct_to_storage_semantics(this) } - + predicate hasDirectToStorageSemantics() { + decl_ref_expr_has_direct_to_storage_semantics(this) + } /** * Holds if this declaration reference expression has direct to implementation semantics. + * */ predicate hasDirectToImplementationSemantics() { decl_ref_expr_has_direct_to_implementation_semantics(this) } - /** * Holds if this declaration reference expression has ordinary semantics. + * */ - predicate hasOrdinarySemantics() { decl_ref_expr_has_ordinary_semantics(this) } - + predicate hasOrdinarySemantics() { + decl_ref_expr_has_ordinary_semantics(this) + } /** * Holds if this declaration reference expression has distributed thunk semantics. + * */ - predicate hasDistributedThunkSemantics() { decl_ref_expr_has_distributed_thunk_semantics(this) } + predicate hasDistributedThunkSemantics() { + decl_ref_expr_has_distributed_thunk_semantics(this) + } } /** * INTERNAL: Do not use. */ class DefaultArgumentExpr extends @default_argument_expr, Expr { + override string toString() { result = "DefaultArgumentExpr" } /** * Gets the parameter declaration of this default argument expression. + * */ - ParamDecl getParamDecl() { default_argument_exprs(this, result, _) } - + ParamDecl getParamDecl() { + default_argument_exprs(this, result, _) + } /** * Gets the parameter index of this default argument expression. + * */ - int getParamIndex() { default_argument_exprs(this, _, result) } - + int getParamIndex() { + default_argument_exprs(this, _, result) + } /** * Gets the caller side default of this default argument expression, if it exists. + * */ - Expr getCallerSideDefault() { default_argument_expr_caller_side_defaults(this, result) } + Expr getCallerSideDefault() { + default_argument_expr_caller_side_defaults(this, result) + } } /** * INTERNAL: Do not use. */ class DiscardAssignmentExpr extends @discard_assignment_expr, Expr { + override string toString() { result = "DiscardAssignmentExpr" } + } /** * INTERNAL: Do not use. */ class DotSyntaxBaseIgnoredExpr extends @dot_syntax_base_ignored_expr, Expr { + override string toString() { result = "DotSyntaxBaseIgnoredExpr" } /** * Gets the qualifier of this dot syntax base ignored expression. + * */ - Expr getQualifier() { dot_syntax_base_ignored_exprs(this, result, _) } - + Expr getQualifier() { + dot_syntax_base_ignored_exprs(this, result, _) + } /** * Gets the sub expression of this dot syntax base ignored expression. + * */ - Expr getSubExpr() { dot_syntax_base_ignored_exprs(this, _, result) } + Expr getSubExpr() { + dot_syntax_base_ignored_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class DynamicTypeExpr extends @dynamic_type_expr, Expr { + override string toString() { result = "DynamicTypeExpr" } /** * Gets the base of this dynamic type expression. + * */ - Expr getBase() { dynamic_type_exprs(this, result) } + Expr getBase() { + dynamic_type_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class EnumIsCaseExpr extends @enum_is_case_expr, Expr { + override string toString() { result = "EnumIsCaseExpr" } /** * Gets the sub expression of this enum is case expression. + * */ - Expr getSubExpr() { enum_is_case_exprs(this, result, _) } - + Expr getSubExpr() { + enum_is_case_exprs(this, result, _) + } /** * Gets the element of this enum is case expression. + * */ - EnumElementDecl getElement() { enum_is_case_exprs(this, _, result) } + EnumElementDecl getElement() { + enum_is_case_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class ErrorExpr extends @error_expr, Expr, ErrorElement { + override string toString() { result = "ErrorExpr" } + } /** * INTERNAL: Do not use. */ class ExplicitCastExpr extends @explicit_cast_expr, Expr { + + + /** * Gets the sub expression of this explicit cast expression. + * */ - Expr getSubExpr() { explicit_cast_exprs(this, result) } + Expr getSubExpr() { + explicit_cast_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class ForceValueExpr extends @force_value_expr, Expr { + override string toString() { result = "ForceValueExpr" } /** * Gets the sub expression of this force value expression. + * */ - Expr getSubExpr() { force_value_exprs(this, result) } + Expr getSubExpr() { + force_value_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class IdentityExpr extends @identity_expr, Expr { + + + /** * Gets the sub expression of this identity expression. + * */ - Expr getSubExpr() { identity_exprs(this, result) } + Expr getSubExpr() { + identity_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class IfExpr extends @if_expr, Expr { + override string toString() { result = "IfExpr" } /** * Gets the condition of this if expression. + * */ - Expr getCondition() { if_exprs(this, result, _, _) } - + Expr getCondition() { + if_exprs(this, result, _, _) + } /** * Gets the then expression of this if expression. + * */ - Expr getThenExpr() { if_exprs(this, _, result, _) } - + Expr getThenExpr() { + if_exprs(this, _, result, _) + } /** * Gets the else expression of this if expression. + * */ - Expr getElseExpr() { if_exprs(this, _, _, result) } + Expr getElseExpr() { + if_exprs(this, _, _, result) + } } /** * INTERNAL: Do not use. */ class ImplicitConversionExpr extends @implicit_conversion_expr, Expr { + + + /** * Gets the sub expression of this implicit conversion expression. + * */ - Expr getSubExpr() { implicit_conversion_exprs(this, result) } + Expr getSubExpr() { + implicit_conversion_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class InOutExpr extends @in_out_expr, Expr { + override string toString() { result = "InOutExpr" } /** * Gets the sub expression of this in out expression. + * */ - Expr getSubExpr() { in_out_exprs(this, result) } + Expr getSubExpr() { + in_out_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class KeyPathApplicationExpr extends @key_path_application_expr, Expr { + override string toString() { result = "KeyPathApplicationExpr" } /** * Gets the base of this key path application expression. + * */ - Expr getBase() { key_path_application_exprs(this, result, _) } - + Expr getBase() { + key_path_application_exprs(this, result, _) + } /** * Gets the key path of this key path application expression. + * */ - Expr getKeyPath() { key_path_application_exprs(this, _, result) } + Expr getKeyPath() { + key_path_application_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class KeyPathDotExpr extends @key_path_dot_expr, Expr { + override string toString() { result = "KeyPathDotExpr" } + } /** @@ -1335,107 +1771,149 @@ module Raw { * A key-path expression. */ class KeyPathExpr extends @key_path_expr, Expr { + override string toString() { result = "KeyPathExpr" } /** * Gets the root of this key path expression, if it exists. + * */ - TypeRepr getRoot() { key_path_expr_roots(this, result) } - + TypeRepr getRoot() { + key_path_expr_roots(this, result) + } /** * Gets the `index`th component of this key path expression (0-based). + * */ - KeyPathComponent getComponent(int index) { key_path_expr_components(this, index, result) } + KeyPathComponent getComponent(int index) { + key_path_expr_components(this, index, result) + } } /** * INTERNAL: Do not use. */ class LazyInitializationExpr extends @lazy_initialization_expr, Expr { + override string toString() { result = "LazyInitializationExpr" } /** * Gets the sub expression of this lazy initialization expression. + * */ - Expr getSubExpr() { lazy_initialization_exprs(this, result) } + Expr getSubExpr() { + lazy_initialization_exprs(this, result) + } } /** * INTERNAL: Do not use. */ - class LiteralExpr extends @literal_expr, Expr { } + class LiteralExpr extends @literal_expr, Expr { + + + + } /** * INTERNAL: Do not use. */ class LookupExpr extends @lookup_expr, Expr { - /** - * Gets the base of this lookup expression. - */ - Expr getBase() { lookup_exprs(this, result) } + + /** - * Gets the member of this lookup expression, if it exists. + * Gets the base of this lookup expression. + * */ - Decl getMember() { lookup_expr_members(this, result) } + Expr getBase() { + lookup_exprs(this, result) + } + /** + * Gets the member of this lookup expression, if it exists. + * + */ + Decl getMember() { + lookup_expr_members(this, result) + } } /** * INTERNAL: Do not use. */ class MakeTemporarilyEscapableExpr extends @make_temporarily_escapable_expr, Expr { + override string toString() { result = "MakeTemporarilyEscapableExpr" } /** * Gets the escaping closure of this make temporarily escapable expression. + * */ - OpaqueValueExpr getEscapingClosure() { make_temporarily_escapable_exprs(this, result, _, _) } - + OpaqueValueExpr getEscapingClosure() { + make_temporarily_escapable_exprs(this, result, _, _) + } /** * Gets the nonescaping closure of this make temporarily escapable expression. + * */ - Expr getNonescapingClosure() { make_temporarily_escapable_exprs(this, _, result, _) } - + Expr getNonescapingClosure() { + make_temporarily_escapable_exprs(this, _, result, _) + } /** * Gets the sub expression of this make temporarily escapable expression. + * */ - Expr getSubExpr() { make_temporarily_escapable_exprs(this, _, _, result) } + Expr getSubExpr() { + make_temporarily_escapable_exprs(this, _, _, result) + } } /** * INTERNAL: Do not use. */ class ObjCSelectorExpr extends @obj_c_selector_expr, Expr { + override string toString() { result = "ObjCSelectorExpr" } /** * Gets the sub expression of this obj c selector expression. + * */ - Expr getSubExpr() { obj_c_selector_exprs(this, result, _) } - + Expr getSubExpr() { + obj_c_selector_exprs(this, result, _) + } /** * Gets the method of this obj c selector expression. + * */ - Function getMethod() { obj_c_selector_exprs(this, _, result) } + Function getMethod() { + obj_c_selector_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class OneWayExpr extends @one_way_expr, Expr { + override string toString() { result = "OneWayExpr" } /** * Gets the sub expression of this one way expression. + * */ - Expr getSubExpr() { one_way_exprs(this, result) } + Expr getSubExpr() { + one_way_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class OpaqueValueExpr extends @opaque_value_expr, Expr { + override string toString() { result = "OpaqueValueExpr" } + } /** @@ -1453,6 +1931,7 @@ module Raw { * ``` */ class OpenExistentialExpr extends @open_existential_expr, Expr { + override string toString() { result = "OpenExistentialExpr" } /** @@ -1460,41 +1939,55 @@ module Raw { * * This wrapped subexpression is where the opaque value and the dynamic type under the protocol type may be used. */ - Expr getSubExpr() { open_existential_exprs(this, result, _, _) } - + Expr getSubExpr() { + open_existential_exprs(this, result, _, _) + } /** * Gets the protocol-typed expression opened by this expression. + * */ - Expr getExistential() { open_existential_exprs(this, _, result, _) } - + Expr getExistential() { + open_existential_exprs(this, _, result, _) + } /** * Gets the opaque value expression embedded within `getSubExpr()`. + * */ - OpaqueValueExpr getOpaqueExpr() { open_existential_exprs(this, _, _, result) } + OpaqueValueExpr getOpaqueExpr() { + open_existential_exprs(this, _, _, result) + } } /** * INTERNAL: Do not use. */ class OptionalEvaluationExpr extends @optional_evaluation_expr, Expr { + override string toString() { result = "OptionalEvaluationExpr" } /** * Gets the sub expression of this optional evaluation expression. + * */ - Expr getSubExpr() { optional_evaluation_exprs(this, result) } + Expr getSubExpr() { + optional_evaluation_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class OtherInitializerRefExpr extends @other_initializer_ref_expr, Expr { + override string toString() { result = "OtherInitializerRefExpr" } /** * Gets the initializer of this other initializer reference expression. + * */ - Initializer getInitializer() { other_initializer_ref_exprs(this, result) } + Initializer getInitializer() { + other_initializer_ref_exprs(this, result) + } } /** @@ -1503,10 +1996,12 @@ module Raw { * for failing compilations. */ class OverloadedDeclRefExpr extends @overloaded_decl_ref_expr, Expr, ErrorElement { + override string toString() { result = "OverloadedDeclRefExpr" } /** * Gets the `index`th possible declaration of this overloaded declaration reference expression (0-based). + * */ ValueDecl getPossibleDeclaration(int index) { overloaded_decl_ref_expr_possible_declarations(this, index, result) @@ -1519,532 +2014,678 @@ module Raw { * wrapper with an initializer. */ class PropertyWrapperValuePlaceholderExpr extends @property_wrapper_value_placeholder_expr, Expr { + override string toString() { result = "PropertyWrapperValuePlaceholderExpr" } /** * Gets the wrapped value of this property wrapper value placeholder expression, if it exists. + * */ - Expr getWrappedValue() { property_wrapper_value_placeholder_expr_wrapped_values(this, result) } - + Expr getWrappedValue() { + property_wrapper_value_placeholder_expr_wrapped_values(this, result) + } /** * Gets the placeholder of this property wrapper value placeholder expression. + * */ - OpaqueValueExpr getPlaceholder() { property_wrapper_value_placeholder_exprs(this, result) } + OpaqueValueExpr getPlaceholder() { + property_wrapper_value_placeholder_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class RebindSelfInInitializerExpr extends @rebind_self_in_initializer_expr, Expr { + override string toString() { result = "RebindSelfInInitializerExpr" } /** * Gets the sub expression of this rebind self in initializer expression. + * */ - Expr getSubExpr() { rebind_self_in_initializer_exprs(this, result, _) } - + Expr getSubExpr() { + rebind_self_in_initializer_exprs(this, result, _) + } /** * Gets the self of this rebind self in initializer expression. + * */ - VarDecl getSelf() { rebind_self_in_initializer_exprs(this, _, result) } + VarDecl getSelf() { + rebind_self_in_initializer_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class SequenceExpr extends @sequence_expr, Expr { + override string toString() { result = "SequenceExpr" } /** * Gets the `index`th element of this sequence expression (0-based). + * */ - Expr getElement(int index) { sequence_expr_elements(this, index, result) } + Expr getElement(int index) { + sequence_expr_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class SuperRefExpr extends @super_ref_expr, Expr { + override string toString() { result = "SuperRefExpr" } /** * Gets the self of this super reference expression. + * */ - VarDecl getSelf() { super_ref_exprs(this, result) } + VarDecl getSelf() { + super_ref_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class TapExpr extends @tap_expr, Expr { + override string toString() { result = "TapExpr" } /** * Gets the sub expression of this tap expression, if it exists. + * */ - Expr getSubExpr() { tap_expr_sub_exprs(this, result) } - + Expr getSubExpr() { + tap_expr_sub_exprs(this, result) + } /** * Gets the body of this tap expression. + * */ - BraceStmt getBody() { tap_exprs(this, result, _) } - + BraceStmt getBody() { + tap_exprs(this, result, _) + } /** * Gets the variable of this tap expression. + * */ - VarDecl getVar() { tap_exprs(this, _, result) } + VarDecl getVar() { + tap_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class TupleElementExpr extends @tuple_element_expr, Expr { + override string toString() { result = "TupleElementExpr" } /** * Gets the sub expression of this tuple element expression. + * */ - Expr getSubExpr() { tuple_element_exprs(this, result, _) } - + Expr getSubExpr() { + tuple_element_exprs(this, result, _) + } /** * Gets the index of this tuple element expression. + * */ - int getIndex() { tuple_element_exprs(this, _, result) } + int getIndex() { + tuple_element_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class TupleExpr extends @tuple_expr, Expr { + override string toString() { result = "TupleExpr" } /** * Gets the `index`th element of this tuple expression (0-based). + * */ - Expr getElement(int index) { tuple_expr_elements(this, index, result) } + Expr getElement(int index) { + tuple_expr_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class TypeExpr extends @type_expr, Expr { + override string toString() { result = "TypeExpr" } /** * Gets the type representation of this type expression, if it exists. + * */ - TypeRepr getTypeRepr() { type_expr_type_reprs(this, result) } + TypeRepr getTypeRepr() { + type_expr_type_reprs(this, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedDeclRefExpr extends @unresolved_decl_ref_expr, Expr, ErrorElement { + override string toString() { result = "UnresolvedDeclRefExpr" } /** * Gets the name of this unresolved declaration reference expression, if it exists. + * */ - string getName() { unresolved_decl_ref_expr_names(this, result) } + string getName() { + unresolved_decl_ref_expr_names(this, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedDotExpr extends @unresolved_dot_expr, Expr, ErrorElement { + override string toString() { result = "UnresolvedDotExpr" } /** * Gets the base of this unresolved dot expression. + * */ - Expr getBase() { unresolved_dot_exprs(this, result, _) } - + Expr getBase() { + unresolved_dot_exprs(this, result, _) + } /** * Gets the name of this unresolved dot expression. + * */ - string getName() { unresolved_dot_exprs(this, _, result) } + string getName() { + unresolved_dot_exprs(this, _, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedMemberExpr extends @unresolved_member_expr, Expr, ErrorElement { + override string toString() { result = "UnresolvedMemberExpr" } /** * Gets the name of this unresolved member expression. + * */ - string getName() { unresolved_member_exprs(this, result) } + string getName() { + unresolved_member_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedPatternExpr extends @unresolved_pattern_expr, Expr, ErrorElement { + override string toString() { result = "UnresolvedPatternExpr" } /** * Gets the sub pattern of this unresolved pattern expression. + * */ - Pattern getSubPattern() { unresolved_pattern_exprs(this, result) } + Pattern getSubPattern() { + unresolved_pattern_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedSpecializeExpr extends @unresolved_specialize_expr, Expr, ErrorElement { + override string toString() { result = "UnresolvedSpecializeExpr" } /** * Gets the sub expression of this unresolved specialize expression. + * */ - Expr getSubExpr() { unresolved_specialize_exprs(this, result) } + Expr getSubExpr() { + unresolved_specialize_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class VarargExpansionExpr extends @vararg_expansion_expr, Expr { + override string toString() { result = "VarargExpansionExpr" } /** * Gets the sub expression of this vararg expansion expression. + * */ - Expr getSubExpr() { vararg_expansion_exprs(this, result) } + Expr getSubExpr() { + vararg_expansion_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class AbiSafeConversionExpr extends @abi_safe_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "AbiSafeConversionExpr" } + } /** * INTERNAL: Do not use. */ class AnyHashableErasureExpr extends @any_hashable_erasure_expr, ImplicitConversionExpr { + override string toString() { result = "AnyHashableErasureExpr" } + } /** * INTERNAL: Do not use. */ class ArchetypeToSuperExpr extends @archetype_to_super_expr, ImplicitConversionExpr { + override string toString() { result = "ArchetypeToSuperExpr" } + } /** * INTERNAL: Do not use. */ class ArrayExpr extends @array_expr, CollectionExpr { + override string toString() { result = "ArrayExpr" } /** * Gets the `index`th element of this array expression (0-based). + * */ - Expr getElement(int index) { array_expr_elements(this, index, result) } + Expr getElement(int index) { + array_expr_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class ArrayToPointerExpr extends @array_to_pointer_expr, ImplicitConversionExpr { + override string toString() { result = "ArrayToPointerExpr" } + } /** * INTERNAL: Do not use. */ class AutoClosureExpr extends @auto_closure_expr, ClosureExpr { + override string toString() { result = "AutoClosureExpr" } + } /** * INTERNAL: Do not use. */ class AwaitExpr extends @await_expr, IdentityExpr { + override string toString() { result = "AwaitExpr" } + } /** * INTERNAL: Do not use. */ class BinaryExpr extends @binary_expr, ApplyExpr { + override string toString() { result = "BinaryExpr" } + } /** * INTERNAL: Do not use. */ class BridgeFromObjCExpr extends @bridge_from_obj_c_expr, ImplicitConversionExpr { + override string toString() { result = "BridgeFromObjCExpr" } + } /** * INTERNAL: Do not use. */ class BridgeToObjCExpr extends @bridge_to_obj_c_expr, ImplicitConversionExpr { + override string toString() { result = "BridgeToObjCExpr" } + } /** * INTERNAL: Do not use. */ - class BuiltinLiteralExpr extends @builtin_literal_expr, LiteralExpr { } + class BuiltinLiteralExpr extends @builtin_literal_expr, LiteralExpr { + + + + } /** * INTERNAL: Do not use. */ class CallExpr extends @call_expr, ApplyExpr { + override string toString() { result = "CallExpr" } + } /** * INTERNAL: Do not use. */ - class CheckedCastExpr extends @checked_cast_expr, ExplicitCastExpr { } + class CheckedCastExpr extends @checked_cast_expr, ExplicitCastExpr { + + + + } /** * INTERNAL: Do not use. */ class ClassMetatypeToObjectExpr extends @class_metatype_to_object_expr, ImplicitConversionExpr { + override string toString() { result = "ClassMetatypeToObjectExpr" } + } /** * INTERNAL: Do not use. */ class CoerceExpr extends @coerce_expr, ExplicitCastExpr { + override string toString() { result = "CoerceExpr" } + } /** * INTERNAL: Do not use. */ - class CollectionUpcastConversionExpr extends @collection_upcast_conversion_expr, - ImplicitConversionExpr - { + class CollectionUpcastConversionExpr extends @collection_upcast_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "CollectionUpcastConversionExpr" } + } /** * INTERNAL: Do not use. */ - class ConditionalBridgeFromObjCExpr extends @conditional_bridge_from_obj_c_expr, - ImplicitConversionExpr - { + class ConditionalBridgeFromObjCExpr extends @conditional_bridge_from_obj_c_expr, ImplicitConversionExpr { + override string toString() { result = "ConditionalBridgeFromObjCExpr" } + } /** * INTERNAL: Do not use. */ - class CovariantFunctionConversionExpr extends @covariant_function_conversion_expr, - ImplicitConversionExpr - { + class CovariantFunctionConversionExpr extends @covariant_function_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "CovariantFunctionConversionExpr" } + } /** * INTERNAL: Do not use. */ - class CovariantReturnConversionExpr extends @covariant_return_conversion_expr, - ImplicitConversionExpr - { + class CovariantReturnConversionExpr extends @covariant_return_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "CovariantReturnConversionExpr" } + } /** * INTERNAL: Do not use. */ class DerivedToBaseExpr extends @derived_to_base_expr, ImplicitConversionExpr { + override string toString() { result = "DerivedToBaseExpr" } + } /** * INTERNAL: Do not use. */ class DestructureTupleExpr extends @destructure_tuple_expr, ImplicitConversionExpr { + override string toString() { result = "DestructureTupleExpr" } + } /** * INTERNAL: Do not use. */ class DictionaryExpr extends @dictionary_expr, CollectionExpr { + override string toString() { result = "DictionaryExpr" } /** * Gets the `index`th element of this dictionary expression (0-based). + * */ - Expr getElement(int index) { dictionary_expr_elements(this, index, result) } + Expr getElement(int index) { + dictionary_expr_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class DifferentiableFunctionExpr extends @differentiable_function_expr, ImplicitConversionExpr { + override string toString() { result = "DifferentiableFunctionExpr" } + } /** * INTERNAL: Do not use. */ - class DifferentiableFunctionExtractOriginalExpr extends @differentiable_function_extract_original_expr, - ImplicitConversionExpr - { + class DifferentiableFunctionExtractOriginalExpr extends @differentiable_function_extract_original_expr, ImplicitConversionExpr { + override string toString() { result = "DifferentiableFunctionExtractOriginalExpr" } + } /** * INTERNAL: Do not use. */ class DotSelfExpr extends @dot_self_expr, IdentityExpr { + override string toString() { result = "DotSelfExpr" } + } /** * INTERNAL: Do not use. */ - class DynamicLookupExpr extends @dynamic_lookup_expr, LookupExpr { } + class DynamicLookupExpr extends @dynamic_lookup_expr, LookupExpr { + + + + } /** * INTERNAL: Do not use. */ class ErasureExpr extends @erasure_expr, ImplicitConversionExpr { + override string toString() { result = "ErasureExpr" } + } /** * INTERNAL: Do not use. */ - class ExistentialMetatypeToObjectExpr extends @existential_metatype_to_object_expr, - ImplicitConversionExpr - { + class ExistentialMetatypeToObjectExpr extends @existential_metatype_to_object_expr, ImplicitConversionExpr { + override string toString() { result = "ExistentialMetatypeToObjectExpr" } + } /** * INTERNAL: Do not use. */ class ExplicitClosureExpr extends @explicit_closure_expr, ClosureExpr { + override string toString() { result = "ExplicitClosureExpr" } + } /** * INTERNAL: Do not use. */ class ForceTryExpr extends @force_try_expr, AnyTryExpr { + override string toString() { result = "ForceTryExpr" } + } /** * INTERNAL: Do not use. */ class ForeignObjectConversionExpr extends @foreign_object_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "ForeignObjectConversionExpr" } + } /** * INTERNAL: Do not use. */ class FunctionConversionExpr extends @function_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "FunctionConversionExpr" } + } /** * INTERNAL: Do not use. */ class InOutToPointerExpr extends @in_out_to_pointer_expr, ImplicitConversionExpr { + override string toString() { result = "InOutToPointerExpr" } + } /** * INTERNAL: Do not use. */ class InjectIntoOptionalExpr extends @inject_into_optional_expr, ImplicitConversionExpr { + override string toString() { result = "InjectIntoOptionalExpr" } + } /** * INTERNAL: Do not use. */ class InterpolatedStringLiteralExpr extends @interpolated_string_literal_expr, LiteralExpr { + override string toString() { result = "InterpolatedStringLiteralExpr" } /** * Gets the interpolation expression of this interpolated string literal expression, if it exists. + * */ OpaqueValueExpr getInterpolationExpr() { interpolated_string_literal_expr_interpolation_exprs(this, result) } - /** * Gets the appending expression of this interpolated string literal expression, if it exists. + * */ - TapExpr getAppendingExpr() { interpolated_string_literal_expr_appending_exprs(this, result) } + TapExpr getAppendingExpr() { + interpolated_string_literal_expr_appending_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class LinearFunctionExpr extends @linear_function_expr, ImplicitConversionExpr { + override string toString() { result = "LinearFunctionExpr" } + } /** * INTERNAL: Do not use. */ - class LinearFunctionExtractOriginalExpr extends @linear_function_extract_original_expr, - ImplicitConversionExpr - { + class LinearFunctionExtractOriginalExpr extends @linear_function_extract_original_expr, ImplicitConversionExpr { + override string toString() { result = "LinearFunctionExtractOriginalExpr" } + } /** * INTERNAL: Do not use. */ - class LinearToDifferentiableFunctionExpr extends @linear_to_differentiable_function_expr, - ImplicitConversionExpr - { + class LinearToDifferentiableFunctionExpr extends @linear_to_differentiable_function_expr, ImplicitConversionExpr { + override string toString() { result = "LinearToDifferentiableFunctionExpr" } + } /** * INTERNAL: Do not use. */ class LoadExpr extends @load_expr, ImplicitConversionExpr { + override string toString() { result = "LoadExpr" } + } /** * INTERNAL: Do not use. */ class MemberRefExpr extends @member_ref_expr, LookupExpr { + override string toString() { result = "MemberRefExpr" } /** * Holds if this member reference expression has direct to storage semantics. + * */ predicate hasDirectToStorageSemantics() { member_ref_expr_has_direct_to_storage_semantics(this) } - /** * Holds if this member reference expression has direct to implementation semantics. + * */ predicate hasDirectToImplementationSemantics() { member_ref_expr_has_direct_to_implementation_semantics(this) } - /** * Holds if this member reference expression has ordinary semantics. + * */ - predicate hasOrdinarySemantics() { member_ref_expr_has_ordinary_semantics(this) } - + predicate hasOrdinarySemantics() { + member_ref_expr_has_ordinary_semantics(this) + } /** * Holds if this member reference expression has distributed thunk semantics. + * */ predicate hasDistributedThunkSemantics() { member_ref_expr_has_distributed_thunk_semantics(this) @@ -2055,14 +2696,18 @@ module Raw { * INTERNAL: Do not use. */ class MetatypeConversionExpr extends @metatype_conversion_expr, ImplicitConversionExpr { + override string toString() { result = "MetatypeConversionExpr" } + } /** * INTERNAL: Do not use. */ class NilLiteralExpr extends @nil_literal_expr, LiteralExpr { + override string toString() { result = "NilLiteralExpr" } + } /** @@ -2070,6 +2715,7 @@ module Raw { * An instance of `#fileLiteral`, `#imageLiteral` or `#colorLiteral` expressions, which are used in playgrounds. */ class ObjectLiteralExpr extends @object_literal_expr, LiteralExpr { + override string toString() { result = "ObjectLiteralExpr" } /** @@ -2077,56 +2723,70 @@ module Raw { * * This is 0 for `#fileLiteral`, 1 for `#imageLiteral` and 2 for `#colorLiteral`. */ - int getKind() { object_literal_exprs(this, result) } - + int getKind() { + object_literal_exprs(this, result) + } /** * Gets the `index`th argument of this object literal expression (0-based). + * */ - Argument getArgument(int index) { object_literal_expr_arguments(this, index, result) } + Argument getArgument(int index) { + object_literal_expr_arguments(this, index, result) + } } /** * INTERNAL: Do not use. */ class OptionalTryExpr extends @optional_try_expr, AnyTryExpr { + override string toString() { result = "OptionalTryExpr" } + } /** * INTERNAL: Do not use. */ class ParenExpr extends @paren_expr, IdentityExpr { + override string toString() { result = "ParenExpr" } + } /** * INTERNAL: Do not use. */ class PointerToPointerExpr extends @pointer_to_pointer_expr, ImplicitConversionExpr { + override string toString() { result = "PointerToPointerExpr" } + } /** * INTERNAL: Do not use. */ class PostfixUnaryExpr extends @postfix_unary_expr, ApplyExpr { + override string toString() { result = "PostfixUnaryExpr" } + } /** * INTERNAL: Do not use. */ class PrefixUnaryExpr extends @prefix_unary_expr, ApplyExpr { + override string toString() { result = "PrefixUnaryExpr" } + } /** * INTERNAL: Do not use. */ - class ProtocolMetatypeToObjectExpr extends @protocol_metatype_to_object_expr, - ImplicitConversionExpr - { + class ProtocolMetatypeToObjectExpr extends @protocol_metatype_to_object_expr, ImplicitConversionExpr { + override string toString() { result = "ProtocolMetatypeToObjectExpr" } + } /** @@ -2134,17 +2794,23 @@ module Raw { * A regular expression literal which is checked at compile time, for example `/a(a|b)*b/`. */ class RegexLiteralExpr extends @regex_literal_expr, LiteralExpr { + override string toString() { result = "RegexLiteralExpr" } /** * Gets the pattern of this regular expression. + * */ - string getPattern() { regex_literal_exprs(this, result, _) } - + string getPattern() { + regex_literal_exprs(this, result, _) + } /** * Gets the version of the internal regular expression language being used by Swift. + * */ - int getVersion() { regex_literal_exprs(this, _, result) } + int getVersion() { + regex_literal_exprs(this, _, result) + } } /** @@ -2153,49 +2819,65 @@ module Raw { * This is completely replaced by the synthesized type `MethodLookupExpr`. */ class SelfApplyExpr extends @self_apply_expr, ApplyExpr { + + + /** * Gets the base of this self apply expression. + * */ - Expr getBase() { self_apply_exprs(this, result) } + Expr getBase() { + self_apply_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class StringToPointerExpr extends @string_to_pointer_expr, ImplicitConversionExpr { + override string toString() { result = "StringToPointerExpr" } + } /** * INTERNAL: Do not use. */ class SubscriptExpr extends @subscript_expr, LookupExpr { + override string toString() { result = "SubscriptExpr" } /** * Gets the `index`th argument of this subscript expression (0-based). + * */ - Argument getArgument(int index) { subscript_expr_arguments(this, index, result) } - + Argument getArgument(int index) { + subscript_expr_arguments(this, index, result) + } /** * Holds if this subscript expression has direct to storage semantics. + * */ - predicate hasDirectToStorageSemantics() { subscript_expr_has_direct_to_storage_semantics(this) } - + predicate hasDirectToStorageSemantics() { + subscript_expr_has_direct_to_storage_semantics(this) + } /** * Holds if this subscript expression has direct to implementation semantics. + * */ predicate hasDirectToImplementationSemantics() { subscript_expr_has_direct_to_implementation_semantics(this) } - /** * Holds if this subscript expression has ordinary semantics. + * */ - predicate hasOrdinarySemantics() { subscript_expr_has_ordinary_semantics(this) } - + predicate hasOrdinarySemantics() { + subscript_expr_has_ordinary_semantics(this) + } /** * Holds if this subscript expression has distributed thunk semantics. + * */ predicate hasDistributedThunkSemantics() { subscript_expr_has_distributed_thunk_semantics(this) @@ -2206,1020 +2888,1392 @@ module Raw { * INTERNAL: Do not use. */ class TryExpr extends @try_expr, AnyTryExpr { + override string toString() { result = "TryExpr" } + } /** * INTERNAL: Do not use. */ class UnderlyingToOpaqueExpr extends @underlying_to_opaque_expr, ImplicitConversionExpr { + override string toString() { result = "UnderlyingToOpaqueExpr" } + } /** * INTERNAL: Do not use. */ class UnevaluatedInstanceExpr extends @unevaluated_instance_expr, ImplicitConversionExpr { + override string toString() { result = "UnevaluatedInstanceExpr" } + } /** * INTERNAL: Do not use. */ - class UnresolvedMemberChainResultExpr extends @unresolved_member_chain_result_expr, IdentityExpr, - ErrorElement - { + class UnresolvedMemberChainResultExpr extends @unresolved_member_chain_result_expr, IdentityExpr, ErrorElement { + override string toString() { result = "UnresolvedMemberChainResultExpr" } + } /** * INTERNAL: Do not use. */ - class UnresolvedTypeConversionExpr extends @unresolved_type_conversion_expr, - ImplicitConversionExpr, ErrorElement - { + class UnresolvedTypeConversionExpr extends @unresolved_type_conversion_expr, ImplicitConversionExpr, ErrorElement { + override string toString() { result = "UnresolvedTypeConversionExpr" } + } /** * INTERNAL: Do not use. */ class BooleanLiteralExpr extends @boolean_literal_expr, BuiltinLiteralExpr { + override string toString() { result = "BooleanLiteralExpr" } /** * Gets the value of this boolean literal expression. + * */ - boolean getValue() { boolean_literal_exprs(this, result) } + boolean getValue() { + boolean_literal_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class ConditionalCheckedCastExpr extends @conditional_checked_cast_expr, CheckedCastExpr { + override string toString() { result = "ConditionalCheckedCastExpr" } + } /** * INTERNAL: Do not use. */ class DotSyntaxCallExpr extends @dot_syntax_call_expr, SelfApplyExpr { + override string toString() { result = "DotSyntaxCallExpr" } + } /** * INTERNAL: Do not use. */ class DynamicMemberRefExpr extends @dynamic_member_ref_expr, DynamicLookupExpr { + override string toString() { result = "DynamicMemberRefExpr" } + } /** * INTERNAL: Do not use. */ class DynamicSubscriptExpr extends @dynamic_subscript_expr, DynamicLookupExpr { + override string toString() { result = "DynamicSubscriptExpr" } + } /** * INTERNAL: Do not use. */ class ForcedCheckedCastExpr extends @forced_checked_cast_expr, CheckedCastExpr { + override string toString() { result = "ForcedCheckedCastExpr" } + } /** * INTERNAL: Do not use. */ class InitializerRefCallExpr extends @initializer_ref_call_expr, SelfApplyExpr { + override string toString() { result = "InitializerRefCallExpr" } + } /** * INTERNAL: Do not use. */ class IsExpr extends @is_expr, CheckedCastExpr { + override string toString() { result = "IsExpr" } + } /** * INTERNAL: Do not use. */ class MagicIdentifierLiteralExpr extends @magic_identifier_literal_expr, BuiltinLiteralExpr { + override string toString() { result = "MagicIdentifierLiteralExpr" } /** * Gets the kind of this magic identifier literal expression. + * */ - string getKind() { magic_identifier_literal_exprs(this, result) } + string getKind() { + magic_identifier_literal_exprs(this, result) + } } /** * INTERNAL: Do not use. */ - class NumberLiteralExpr extends @number_literal_expr, BuiltinLiteralExpr { } + class NumberLiteralExpr extends @number_literal_expr, BuiltinLiteralExpr { + + + + } /** * INTERNAL: Do not use. */ class StringLiteralExpr extends @string_literal_expr, BuiltinLiteralExpr { + override string toString() { result = "StringLiteralExpr" } /** * Gets the value of this string literal expression. + * */ - string getValue() { string_literal_exprs(this, result) } + string getValue() { + string_literal_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class FloatLiteralExpr extends @float_literal_expr, NumberLiteralExpr { + override string toString() { result = "FloatLiteralExpr" } /** * Gets the string value of this float literal expression. + * */ - string getStringValue() { float_literal_exprs(this, result) } + string getStringValue() { + float_literal_exprs(this, result) + } } /** * INTERNAL: Do not use. */ class IntegerLiteralExpr extends @integer_literal_expr, NumberLiteralExpr { + override string toString() { result = "IntegerLiteralExpr" } /** * Gets the string value of this integer literal expression. + * */ - string getStringValue() { integer_literal_exprs(this, result) } + string getStringValue() { + integer_literal_exprs(this, result) + } } /** * INTERNAL: Do not use. */ - class Pattern extends @pattern, AstNode { } + class Pattern extends @pattern, AstNode { + + + + } /** * INTERNAL: Do not use. */ class AnyPattern extends @any_pattern, Pattern { + override string toString() { result = "AnyPattern" } + } /** * INTERNAL: Do not use. */ class BindingPattern extends @binding_pattern, Pattern { + override string toString() { result = "BindingPattern" } /** * Gets the sub pattern of this binding pattern. + * */ - Pattern getSubPattern() { binding_patterns(this, result) } + Pattern getSubPattern() { + binding_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class BoolPattern extends @bool_pattern, Pattern { + override string toString() { result = "BoolPattern" } /** * Gets the value of this bool pattern. + * */ - boolean getValue() { bool_patterns(this, result) } + boolean getValue() { + bool_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class EnumElementPattern extends @enum_element_pattern, Pattern { + override string toString() { result = "EnumElementPattern" } /** * Gets the element of this enum element pattern. + * */ - EnumElementDecl getElement() { enum_element_patterns(this, result) } - + EnumElementDecl getElement() { + enum_element_patterns(this, result) + } /** * Gets the sub pattern of this enum element pattern, if it exists. + * */ - Pattern getSubPattern() { enum_element_pattern_sub_patterns(this, result) } + Pattern getSubPattern() { + enum_element_pattern_sub_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class ExprPattern extends @expr_pattern, Pattern { + override string toString() { result = "ExprPattern" } /** * Gets the sub expression of this expression pattern. + * */ - Expr getSubExpr() { expr_patterns(this, result) } + Expr getSubExpr() { + expr_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class IsPattern extends @is_pattern, Pattern { + override string toString() { result = "IsPattern" } /** * Gets the cast type representation of this is pattern, if it exists. + * */ - TypeRepr getCastTypeRepr() { is_pattern_cast_type_reprs(this, result) } - + TypeRepr getCastTypeRepr() { + is_pattern_cast_type_reprs(this, result) + } /** * Gets the sub pattern of this is pattern, if it exists. + * */ - Pattern getSubPattern() { is_pattern_sub_patterns(this, result) } + Pattern getSubPattern() { + is_pattern_sub_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class NamedPattern extends @named_pattern, Pattern { + override string toString() { result = "NamedPattern" } /** * Gets the name of this named pattern. + * */ - string getName() { named_patterns(this, result) } + string getName() { + named_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class OptionalSomePattern extends @optional_some_pattern, Pattern { + override string toString() { result = "OptionalSomePattern" } /** * Gets the sub pattern of this optional some pattern. + * */ - Pattern getSubPattern() { optional_some_patterns(this, result) } + Pattern getSubPattern() { + optional_some_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class ParenPattern extends @paren_pattern, Pattern { + override string toString() { result = "ParenPattern" } /** * Gets the sub pattern of this paren pattern. + * */ - Pattern getSubPattern() { paren_patterns(this, result) } + Pattern getSubPattern() { + paren_patterns(this, result) + } } /** * INTERNAL: Do not use. */ class TuplePattern extends @tuple_pattern, Pattern { + override string toString() { result = "TuplePattern" } /** * Gets the `index`th element of this tuple pattern (0-based). + * */ - Pattern getElement(int index) { tuple_pattern_elements(this, index, result) } + Pattern getElement(int index) { + tuple_pattern_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class TypedPattern extends @typed_pattern, Pattern { + override string toString() { result = "TypedPattern" } /** * Gets the sub pattern of this typed pattern. + * */ - Pattern getSubPattern() { typed_patterns(this, result) } - + Pattern getSubPattern() { + typed_patterns(this, result) + } /** * Gets the type representation of this typed pattern, if it exists. + * */ - TypeRepr getTypeRepr() { typed_pattern_type_reprs(this, result) } + TypeRepr getTypeRepr() { + typed_pattern_type_reprs(this, result) + } } /** * INTERNAL: Do not use. */ class CaseLabelItem extends @case_label_item, AstNode { + override string toString() { result = "CaseLabelItem" } /** * Gets the pattern of this case label item. + * */ - Pattern getPattern() { case_label_items(this, result) } - + Pattern getPattern() { + case_label_items(this, result) + } /** * Gets the guard of this case label item, if it exists. + * */ - Expr getGuard() { case_label_item_guards(this, result) } + Expr getGuard() { + case_label_item_guards(this, result) + } } /** * INTERNAL: Do not use. */ class ConditionElement extends @condition_element, AstNode { + override string toString() { result = "ConditionElement" } /** * Gets the boolean of this condition element, if it exists. + * */ - Expr getBoolean() { condition_element_booleans(this, result) } - + Expr getBoolean() { + condition_element_booleans(this, result) + } /** * Gets the pattern of this condition element, if it exists. + * */ - Pattern getPattern() { condition_element_patterns(this, result) } - + Pattern getPattern() { + condition_element_patterns(this, result) + } /** * Gets the initializer of this condition element, if it exists. + * */ - Expr getInitializer() { condition_element_initializers(this, result) } - + Expr getInitializer() { + condition_element_initializers(this, result) + } /** * Gets the availability of this condition element, if it exists. + * */ - AvailabilityInfo getAvailability() { condition_element_availabilities(this, result) } + AvailabilityInfo getAvailability() { + condition_element_availabilities(this, result) + } } /** * INTERNAL: Do not use. */ - class Stmt extends @stmt, AstNode { } + class Stmt extends @stmt, AstNode { + + + + } /** * INTERNAL: Do not use. */ class StmtCondition extends @stmt_condition, AstNode { + override string toString() { result = "StmtCondition" } /** * Gets the `index`th element of this statement condition (0-based). + * */ - ConditionElement getElement(int index) { stmt_condition_elements(this, index, result) } + ConditionElement getElement(int index) { + stmt_condition_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class BraceStmt extends @brace_stmt, Stmt { + override string toString() { result = "BraceStmt" } /** * Gets the `index`th element of this brace statement (0-based). + * */ - AstNode getElement(int index) { brace_stmt_elements(this, index, result) } + AstNode getElement(int index) { + brace_stmt_elements(this, index, result) + } } /** * INTERNAL: Do not use. */ class BreakStmt extends @break_stmt, Stmt { + override string toString() { result = "BreakStmt" } /** * Gets the target name of this break statement, if it exists. + * */ - string getTargetName() { break_stmt_target_names(this, result) } - + string getTargetName() { + break_stmt_target_names(this, result) + } /** * Gets the target of this break statement, if it exists. + * */ - Stmt getTarget() { break_stmt_targets(this, result) } + Stmt getTarget() { + break_stmt_targets(this, result) + } } /** * INTERNAL: Do not use. */ class CaseStmt extends @case_stmt, Stmt { + override string toString() { result = "CaseStmt" } /** * Gets the body of this case statement. + * */ - Stmt getBody() { case_stmts(this, result) } - + Stmt getBody() { + case_stmts(this, result) + } /** * Gets the `index`th label of this case statement (0-based). + * */ - CaseLabelItem getLabel(int index) { case_stmt_labels(this, index, result) } - + CaseLabelItem getLabel(int index) { + case_stmt_labels(this, index, result) + } /** * Gets the `index`th variable of this case statement (0-based). + * */ - VarDecl getVariable(int index) { case_stmt_variables(this, index, result) } + VarDecl getVariable(int index) { + case_stmt_variables(this, index, result) + } } /** * INTERNAL: Do not use. */ class ContinueStmt extends @continue_stmt, Stmt { + override string toString() { result = "ContinueStmt" } /** * Gets the target name of this continue statement, if it exists. + * */ - string getTargetName() { continue_stmt_target_names(this, result) } - + string getTargetName() { + continue_stmt_target_names(this, result) + } /** * Gets the target of this continue statement, if it exists. + * */ - Stmt getTarget() { continue_stmt_targets(this, result) } + Stmt getTarget() { + continue_stmt_targets(this, result) + } } /** * INTERNAL: Do not use. */ class DeferStmt extends @defer_stmt, Stmt { + override string toString() { result = "DeferStmt" } /** * Gets the body of this defer statement. + * */ - BraceStmt getBody() { defer_stmts(this, result) } + BraceStmt getBody() { + defer_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class FailStmt extends @fail_stmt, Stmt { + override string toString() { result = "FailStmt" } + } /** * INTERNAL: Do not use. */ class FallthroughStmt extends @fallthrough_stmt, Stmt { + override string toString() { result = "FallthroughStmt" } /** * Gets the fallthrough source of this fallthrough statement. + * */ - CaseStmt getFallthroughSource() { fallthrough_stmts(this, result, _) } - + CaseStmt getFallthroughSource() { + fallthrough_stmts(this, result, _) + } /** * Gets the fallthrough dest of this fallthrough statement. + * */ - CaseStmt getFallthroughDest() { fallthrough_stmts(this, _, result) } + CaseStmt getFallthroughDest() { + fallthrough_stmts(this, _, result) + } } /** * INTERNAL: Do not use. */ class LabeledStmt extends @labeled_stmt, Stmt { + + + /** * Gets the label of this labeled statement, if it exists. + * */ - string getLabel() { labeled_stmt_labels(this, result) } + string getLabel() { + labeled_stmt_labels(this, result) + } } /** * INTERNAL: Do not use. */ class PoundAssertStmt extends @pound_assert_stmt, Stmt { + override string toString() { result = "PoundAssertStmt" } /** * Gets the condition of this pound assert statement. + * */ - Expr getCondition() { pound_assert_stmts(this, result, _) } - + Expr getCondition() { + pound_assert_stmts(this, result, _) + } /** * Gets the message of this pound assert statement. + * */ - string getMessage() { pound_assert_stmts(this, _, result) } + string getMessage() { + pound_assert_stmts(this, _, result) + } } /** * INTERNAL: Do not use. */ class ReturnStmt extends @return_stmt, Stmt { + override string toString() { result = "ReturnStmt" } /** * Gets the result of this return statement, if it exists. + * */ - Expr getResult() { return_stmt_results(this, result) } + Expr getResult() { + return_stmt_results(this, result) + } } /** * INTERNAL: Do not use. */ class ThrowStmt extends @throw_stmt, Stmt { + override string toString() { result = "ThrowStmt" } /** * Gets the sub expression of this throw statement. + * */ - Expr getSubExpr() { throw_stmts(this, result) } + Expr getSubExpr() { + throw_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class YieldStmt extends @yield_stmt, Stmt { + override string toString() { result = "YieldStmt" } /** * Gets the `index`th result of this yield statement (0-based). + * */ - Expr getResult(int index) { yield_stmt_results(this, index, result) } + Expr getResult(int index) { + yield_stmt_results(this, index, result) + } } /** * INTERNAL: Do not use. */ class DoCatchStmt extends @do_catch_stmt, LabeledStmt { + override string toString() { result = "DoCatchStmt" } /** * Gets the body of this do catch statement. + * */ - Stmt getBody() { do_catch_stmts(this, result) } - + Stmt getBody() { + do_catch_stmts(this, result) + } /** * Gets the `index`th catch of this do catch statement (0-based). + * */ - CaseStmt getCatch(int index) { do_catch_stmt_catches(this, index, result) } + CaseStmt getCatch(int index) { + do_catch_stmt_catches(this, index, result) + } } /** * INTERNAL: Do not use. */ class DoStmt extends @do_stmt, LabeledStmt { + override string toString() { result = "DoStmt" } /** * Gets the body of this do statement. + * */ - BraceStmt getBody() { do_stmts(this, result) } + BraceStmt getBody() { + do_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class ForEachStmt extends @for_each_stmt, LabeledStmt { + override string toString() { result = "ForEachStmt" } /** * Gets the pattern of this for each statement. + * */ - Pattern getPattern() { for_each_stmts(this, result, _, _) } - - /** - * Gets the sequence of this for each statement. - */ - Expr getSequence() { for_each_stmts(this, _, result, _) } - + Pattern getPattern() { + for_each_stmts(this, result, _) + } /** * Gets the where of this for each statement, if it exists. + * */ - Expr getWhere() { for_each_stmt_wheres(this, result) } - + Expr getWhere() { + for_each_stmt_wheres(this, result) + } + /** + * Gets the iteratorvar of this for each statement, if it exists. + * + */ + PatternBindingDecl getIteratorVar() { + for_each_stmt_iterator_vars(this, result) + } /** * Gets the nextcall of this for each statement, if it exists. + * */ - Expr getNextCall() { for_each_stmt_next_calls(this, result) } - + Expr getNextCall() { + for_each_stmt_next_calls(this, result) + } /** * Gets the body of this for each statement. + * */ - BraceStmt getBody() { for_each_stmts(this, _, _, result) } + BraceStmt getBody() { + for_each_stmts(this, _, result) + } } /** * INTERNAL: Do not use. */ class LabeledConditionalStmt extends @labeled_conditional_stmt, LabeledStmt { + + + /** * Gets the condition of this labeled conditional statement. + * */ - StmtCondition getCondition() { labeled_conditional_stmts(this, result) } + StmtCondition getCondition() { + labeled_conditional_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class RepeatWhileStmt extends @repeat_while_stmt, LabeledStmt { + override string toString() { result = "RepeatWhileStmt" } /** * Gets the condition of this repeat while statement. + * */ - Expr getCondition() { repeat_while_stmts(this, result, _) } - + Expr getCondition() { + repeat_while_stmts(this, result, _) + } /** * Gets the body of this repeat while statement. + * */ - Stmt getBody() { repeat_while_stmts(this, _, result) } + Stmt getBody() { + repeat_while_stmts(this, _, result) + } } /** * INTERNAL: Do not use. */ class SwitchStmt extends @switch_stmt, LabeledStmt { + override string toString() { result = "SwitchStmt" } /** * Gets the expression of this switch statement. + * */ - Expr getExpr() { switch_stmts(this, result) } - + Expr getExpr() { + switch_stmts(this, result) + } /** * Gets the `index`th case of this switch statement (0-based). + * */ - CaseStmt getCase(int index) { switch_stmt_cases(this, index, result) } + CaseStmt getCase(int index) { + switch_stmt_cases(this, index, result) + } } /** * INTERNAL: Do not use. */ class GuardStmt extends @guard_stmt, LabeledConditionalStmt { + override string toString() { result = "GuardStmt" } /** * Gets the body of this guard statement. + * */ - BraceStmt getBody() { guard_stmts(this, result) } + BraceStmt getBody() { + guard_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class IfStmt extends @if_stmt, LabeledConditionalStmt { + override string toString() { result = "IfStmt" } /** * Gets the then of this if statement. + * */ - Stmt getThen() { if_stmts(this, result) } - + Stmt getThen() { + if_stmts(this, result) + } /** * Gets the else of this if statement, if it exists. + * */ - Stmt getElse() { if_stmt_elses(this, result) } + Stmt getElse() { + if_stmt_elses(this, result) + } } /** * INTERNAL: Do not use. */ class WhileStmt extends @while_stmt, LabeledConditionalStmt { + override string toString() { result = "WhileStmt" } /** * Gets the body of this while statement. + * */ - Stmt getBody() { while_stmts(this, result) } + Stmt getBody() { + while_stmts(this, result) + } } /** * INTERNAL: Do not use. */ class Type extends @type, Element { - /** - * Gets the name of this type. - */ - string getName() { types(this, result, _) } + + /** - * Gets the canonical type of this type. + * Gets the name of this type. + * */ - Type getCanonicalType() { types(this, _, result) } + string getName() { + types(this, result, _) + } + /** + * Gets the canonical type of this type. + * + */ + Type getCanonicalType() { + types(this, _, result) + } } /** * INTERNAL: Do not use. */ class TypeRepr extends @type_repr, AstNode { + override string toString() { result = "TypeRepr" } /** * Gets the type of this type representation. + * */ - Type getType() { type_reprs(this, result) } + Type getType() { + type_reprs(this, result) + } } /** * INTERNAL: Do not use. */ class AnyFunctionType extends @any_function_type, Type { + + + /** * Gets the result of this function type. + * */ - Type getResult() { any_function_types(this, result) } - + Type getResult() { + any_function_types(this, result) + } /** * Gets the `index`th parameter type of this function type (0-based). + * */ - Type getParamType(int index) { any_function_type_param_types(this, index, result) } - + Type getParamType(int index) { + any_function_type_param_types(this, index, result) + } /** * Holds if this type refers to a throwing function. + * */ - predicate isThrowing() { any_function_type_is_throwing(this) } - + predicate isThrowing() { + any_function_type_is_throwing(this) + } /** * Holds if this type refers to an `async` function. + * */ - predicate isAsync() { any_function_type_is_async(this) } + predicate isAsync() { + any_function_type_is_async(this) + } } /** * INTERNAL: Do not use. */ class AnyGenericType extends @any_generic_type, Type { - /** - * Gets the parent of this any generic type, if it exists. - */ - Type getParent() { any_generic_type_parents(this, result) } + + /** - * Gets the declaration of this any generic type. + * Gets the parent of this any generic type, if it exists. + * */ - GenericTypeDecl getDeclaration() { any_generic_types(this, result) } + Type getParent() { + any_generic_type_parents(this, result) + } + /** + * Gets the declaration of this any generic type. + * + */ + GenericTypeDecl getDeclaration() { + any_generic_types(this, result) + } } /** * INTERNAL: Do not use. */ - class AnyMetatypeType extends @any_metatype_type, Type { } + class AnyMetatypeType extends @any_metatype_type, Type { + + + + } /** * INTERNAL: Do not use. */ - class BuiltinType extends @builtin_type, Type { } + class BuiltinType extends @builtin_type, Type { + + + + } /** * INTERNAL: Do not use. */ class DependentMemberType extends @dependent_member_type, Type { + override string toString() { result = "DependentMemberType" } /** * Gets the base type of this dependent member type. + * */ - Type getBaseType() { dependent_member_types(this, result, _) } - + Type getBaseType() { + dependent_member_types(this, result, _) + } /** * Gets the associated type declaration of this dependent member type. + * */ - AssociatedTypeDecl getAssociatedTypeDecl() { dependent_member_types(this, _, result) } + AssociatedTypeDecl getAssociatedTypeDecl() { + dependent_member_types(this, _, result) + } } /** * INTERNAL: Do not use. */ class DynamicSelfType extends @dynamic_self_type, Type { + override string toString() { result = "DynamicSelfType" } /** * Gets the static self type of this dynamic self type. + * */ - Type getStaticSelfType() { dynamic_self_types(this, result) } + Type getStaticSelfType() { + dynamic_self_types(this, result) + } } /** * INTERNAL: Do not use. */ class ErrorType extends @error_type, Type, ErrorElement { + override string toString() { result = "ErrorType" } + } /** * INTERNAL: Do not use. */ class ExistentialType extends @existential_type, Type { + override string toString() { result = "ExistentialType" } /** * Gets the constraint of this existential type. + * */ - Type getConstraint() { existential_types(this, result) } + Type getConstraint() { + existential_types(this, result) + } } /** * INTERNAL: Do not use. */ class InOutType extends @in_out_type, Type { + override string toString() { result = "InOutType" } /** * Gets the object type of this in out type. + * */ - Type getObjectType() { in_out_types(this, result) } + Type getObjectType() { + in_out_types(this, result) + } } /** * INTERNAL: Do not use. */ class LValueType extends @l_value_type, Type { + override string toString() { result = "LValueType" } /** * Gets the object type of this l value type. + * */ - Type getObjectType() { l_value_types(this, result) } + Type getObjectType() { + l_value_types(this, result) + } } /** * INTERNAL: Do not use. */ class ModuleType extends @module_type, Type { + override string toString() { result = "ModuleType" } /** * Gets the module of this module type. + * */ - ModuleDecl getModule() { module_types(this, result) } + ModuleDecl getModule() { + module_types(this, result) + } } /** * INTERNAL: Do not use. * A sugar type of the form `P` with `P` a protocol. - * + * * If `P` has primary associated type `A`, then `T: P` is a shortcut for `T: P where T.A == X`. */ class ParameterizedProtocolType extends @parameterized_protocol_type, Type { + override string toString() { result = "ParameterizedProtocolType" } /** * Gets the base of this parameterized protocol type. + * */ - ProtocolType getBase() { parameterized_protocol_types(this, result) } - + ProtocolType getBase() { + parameterized_protocol_types(this, result) + } /** * Gets the `index`th argument of this parameterized protocol type (0-based). + * */ - Type getArg(int index) { parameterized_protocol_type_args(this, index, result) } + Type getArg(int index) { + parameterized_protocol_type_args(this, index, result) + } } /** * INTERNAL: Do not use. */ class ProtocolCompositionType extends @protocol_composition_type, Type { + override string toString() { result = "ProtocolCompositionType" } /** * Gets the `index`th member of this protocol composition type (0-based). + * */ - Type getMember(int index) { protocol_composition_type_members(this, index, result) } + Type getMember(int index) { + protocol_composition_type_members(this, index, result) + } } /** * INTERNAL: Do not use. */ class ReferenceStorageType extends @reference_storage_type, Type { + + + /** * Gets the referent type of this reference storage type. + * */ - Type getReferentType() { reference_storage_types(this, result) } + Type getReferentType() { + reference_storage_types(this, result) + } } /** * INTERNAL: Do not use. */ - class SubstitutableType extends @substitutable_type, Type { } + class SubstitutableType extends @substitutable_type, Type { + + + + } /** * INTERNAL: Do not use. */ - class SugarType extends @sugar_type, Type { } + class SugarType extends @sugar_type, Type { + + + + } /** * INTERNAL: Do not use. */ class TupleType extends @tuple_type, Type { + override string toString() { result = "TupleType" } /** * Gets the `index`th type of this tuple type (0-based). + * */ - Type getType(int index) { tuple_type_types(this, index, result) } - + Type getType(int index) { + tuple_type_types(this, index, result) + } /** * Gets the `index`th name of this tuple type (0-based), if it exists. + * */ - string getName(int index) { tuple_type_names(this, index, result) } + string getName(int index) { + tuple_type_names(this, index, result) + } } /** * INTERNAL: Do not use. */ class UnresolvedType extends @unresolved_type, Type, ErrorElement { + override string toString() { result = "UnresolvedType" } + } /** * INTERNAL: Do not use. */ - class AnyBuiltinIntegerType extends @any_builtin_integer_type, BuiltinType { } + class AnyBuiltinIntegerType extends @any_builtin_integer_type, BuiltinType { + + + + } /** * INTERNAL: Do not use. */ class ArchetypeType extends @archetype_type, SubstitutableType { + + + /** * Gets the interface type of this archetype type. + * */ - Type getInterfaceType() { archetype_types(this, result) } - + Type getInterfaceType() { + archetype_types(this, result) + } /** * Gets the superclass of this archetype type, if it exists. + * */ - Type getSuperclass() { archetype_type_superclasses(this, result) } - + Type getSuperclass() { + archetype_type_superclasses(this, result) + } /** * Gets the `index`th protocol of this archetype type (0-based). + * */ - ProtocolDecl getProtocol(int index) { archetype_type_protocols(this, index, result) } + ProtocolDecl getProtocol(int index) { + archetype_type_protocols(this, index, result) + } } /** * INTERNAL: Do not use. */ class BuiltinBridgeObjectType extends @builtin_bridge_object_type, BuiltinType { + override string toString() { result = "BuiltinBridgeObjectType" } + } /** * INTERNAL: Do not use. */ class BuiltinDefaultActorStorageType extends @builtin_default_actor_storage_type, BuiltinType { + override string toString() { result = "BuiltinDefaultActorStorageType" } + } /** * INTERNAL: Do not use. */ class BuiltinExecutorType extends @builtin_executor_type, BuiltinType { + override string toString() { result = "BuiltinExecutorType" } + } /** * INTERNAL: Do not use. */ class BuiltinFloatType extends @builtin_float_type, BuiltinType { + override string toString() { result = "BuiltinFloatType" } + } /** * INTERNAL: Do not use. */ class BuiltinJobType extends @builtin_job_type, BuiltinType { + override string toString() { result = "BuiltinJobType" } + } /** * INTERNAL: Do not use. */ class BuiltinNativeObjectType extends @builtin_native_object_type, BuiltinType { + override string toString() { result = "BuiltinNativeObjectType" } + } /** * INTERNAL: Do not use. */ class BuiltinRawPointerType extends @builtin_raw_pointer_type, BuiltinType { + override string toString() { result = "BuiltinRawPointerType" } + } /** * INTERNAL: Do not use. */ class BuiltinRawUnsafeContinuationType extends @builtin_raw_unsafe_continuation_type, BuiltinType { + override string toString() { result = "BuiltinRawUnsafeContinuationType" } + } /** * INTERNAL: Do not use. */ class BuiltinUnsafeValueBufferType extends @builtin_unsafe_value_buffer_type, BuiltinType { + override string toString() { result = "BuiltinUnsafeValueBufferType" } + } /** * INTERNAL: Do not use. */ class BuiltinVectorType extends @builtin_vector_type, BuiltinType { + override string toString() { result = "BuiltinVectorType" } + } /** * INTERNAL: Do not use. */ class ExistentialMetatypeType extends @existential_metatype_type, AnyMetatypeType { + override string toString() { result = "ExistentialMetatypeType" } + } /** * INTERNAL: Do not use. */ class FunctionType extends @function_type, AnyFunctionType { + override string toString() { result = "FunctionType" } + } /** @@ -3227,10 +4281,12 @@ module Raw { * The type of a generic function with type parameters */ class GenericFunctionType extends @generic_function_type, AnyFunctionType { + override string toString() { result = "GenericFunctionType" } /** * Gets the `index`th type parameter of this generic type (0-based). + * */ GenericTypeParamType getGenericParam(int index) { generic_function_type_generic_params(this, index, result) @@ -3241,237 +4297,320 @@ module Raw { * INTERNAL: Do not use. */ class GenericTypeParamType extends @generic_type_param_type, SubstitutableType { + override string toString() { result = "GenericTypeParamType" } + } /** * INTERNAL: Do not use. */ class MetatypeType extends @metatype_type, AnyMetatypeType { + override string toString() { result = "MetatypeType" } + } /** * INTERNAL: Do not use. */ - class NominalOrBoundGenericNominalType extends @nominal_or_bound_generic_nominal_type, - AnyGenericType - { } + class NominalOrBoundGenericNominalType extends @nominal_or_bound_generic_nominal_type, AnyGenericType { + + + + } /** * INTERNAL: Do not use. */ class ParenType extends @paren_type, SugarType { + override string toString() { result = "ParenType" } /** * Gets the type of this paren type. + * */ - Type getType() { paren_types(this, result) } + Type getType() { + paren_types(this, result) + } } /** * INTERNAL: Do not use. */ - class SyntaxSugarType extends @syntax_sugar_type, SugarType { } + class SyntaxSugarType extends @syntax_sugar_type, SugarType { + + + + } /** * INTERNAL: Do not use. */ class TypeAliasType extends @type_alias_type, SugarType { + override string toString() { result = "TypeAliasType" } /** * Gets the declaration of this type alias type. + * */ - TypeAliasDecl getDecl() { type_alias_types(this, result) } + TypeAliasDecl getDecl() { + type_alias_types(this, result) + } } /** * INTERNAL: Do not use. */ class UnboundGenericType extends @unbound_generic_type, AnyGenericType { + override string toString() { result = "UnboundGenericType" } + } /** * INTERNAL: Do not use. */ class UnmanagedStorageType extends @unmanaged_storage_type, ReferenceStorageType { + override string toString() { result = "UnmanagedStorageType" } + } /** * INTERNAL: Do not use. */ class UnownedStorageType extends @unowned_storage_type, ReferenceStorageType { + override string toString() { result = "UnownedStorageType" } + } /** * INTERNAL: Do not use. */ class WeakStorageType extends @weak_storage_type, ReferenceStorageType { + override string toString() { result = "WeakStorageType" } + } /** * INTERNAL: Do not use. */ class BoundGenericType extends @bound_generic_type, NominalOrBoundGenericNominalType { + + + /** * 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) } + Type getArgType(int index) { + bound_generic_type_arg_types(this, index, result) + } } /** * INTERNAL: Do not use. */ class BuiltinIntegerLiteralType extends @builtin_integer_literal_type, AnyBuiltinIntegerType { + override string toString() { result = "BuiltinIntegerLiteralType" } + } /** * INTERNAL: Do not use. */ class BuiltinIntegerType extends @builtin_integer_type, AnyBuiltinIntegerType { + override string toString() { result = "BuiltinIntegerType" } /** * Gets the width of this builtin integer type, if it exists. + * */ - int getWidth() { builtin_integer_type_widths(this, result) } + int getWidth() { + builtin_integer_type_widths(this, result) + } } /** * INTERNAL: Do not use. */ class DictionaryType extends @dictionary_type, SyntaxSugarType { + override string toString() { result = "DictionaryType" } /** * Gets the key type of this dictionary type. + * */ - Type getKeyType() { dictionary_types(this, result, _) } - + Type getKeyType() { + dictionary_types(this, result, _) + } /** * Gets the value type of this dictionary type. + * */ - Type getValueType() { dictionary_types(this, _, result) } + Type getValueType() { + dictionary_types(this, _, result) + } } /** * INTERNAL: Do not use. */ - class NominalType extends @nominal_type, NominalOrBoundGenericNominalType { } + class NominalType extends @nominal_type, NominalOrBoundGenericNominalType { + + + + } /** * INTERNAL: Do not use. * An opaque type, that is a type formally equivalent to an underlying type but abstracting it away. - * + * * See https://docs.swift.org/swift-book/LanguageGuide/OpaqueTypes.html. */ class OpaqueTypeArchetypeType extends @opaque_type_archetype_type, ArchetypeType { + override string toString() { result = "OpaqueTypeArchetypeType" } /** * Gets the declaration of this opaque type archetype type. + * */ - OpaqueTypeDecl getDeclaration() { opaque_type_archetype_types(this, result) } + OpaqueTypeDecl getDeclaration() { + opaque_type_archetype_types(this, result) + } } /** * INTERNAL: Do not use. */ class OpenedArchetypeType extends @opened_archetype_type, ArchetypeType { + override string toString() { result = "OpenedArchetypeType" } + } /** * INTERNAL: Do not use. */ class PrimaryArchetypeType extends @primary_archetype_type, ArchetypeType { + override string toString() { result = "PrimaryArchetypeType" } + } /** * INTERNAL: Do not use. */ class UnarySyntaxSugarType extends @unary_syntax_sugar_type, SyntaxSugarType { + + + /** * Gets the base type of this unary syntax sugar type. + * */ - Type getBaseType() { unary_syntax_sugar_types(this, result) } + Type getBaseType() { + unary_syntax_sugar_types(this, result) + } } /** * INTERNAL: Do not use. */ class ArraySliceType extends @array_slice_type, UnarySyntaxSugarType { + override string toString() { result = "ArraySliceType" } + } /** * INTERNAL: Do not use. */ class BoundGenericClassType extends @bound_generic_class_type, BoundGenericType { + override string toString() { result = "BoundGenericClassType" } + } /** * INTERNAL: Do not use. */ class BoundGenericEnumType extends @bound_generic_enum_type, BoundGenericType { + override string toString() { result = "BoundGenericEnumType" } + } /** * INTERNAL: Do not use. */ class BoundGenericStructType extends @bound_generic_struct_type, BoundGenericType { + override string toString() { result = "BoundGenericStructType" } + } /** * INTERNAL: Do not use. */ class ClassType extends @class_type, NominalType { + override string toString() { result = "ClassType" } + } /** * INTERNAL: Do not use. */ class EnumType extends @enum_type, NominalType { + override string toString() { result = "EnumType" } + } /** * INTERNAL: Do not use. */ class OptionalType extends @optional_type, UnarySyntaxSugarType { + override string toString() { result = "OptionalType" } + } /** * INTERNAL: Do not use. */ class ProtocolType extends @protocol_type, NominalType { + override string toString() { result = "ProtocolType" } + } /** * INTERNAL: Do not use. */ class StructType extends @struct_type, NominalType { + override string toString() { result = "StructType" } + } /** * INTERNAL: Do not use. */ class VariadicSequenceType extends @variadic_sequence_type, UnarySyntaxSugarType { + override string toString() { result = "VariadicSequenceType" } + } + } diff --git a/swift/ql/lib/codeql/swift/generated/stmt/ForEachStmt.qll b/swift/ql/lib/codeql/swift/generated/stmt/ForEachStmt.qll index e0467f83926..676410c15db 100644 --- a/swift/ql/lib/codeql/swift/generated/stmt/ForEachStmt.qll +++ b/swift/ql/lib/codeql/swift/generated/stmt/ForEachStmt.qll @@ -5,6 +5,7 @@ import codeql.swift.elements.stmt.BraceStmt import codeql.swift.elements.expr.Expr import codeql.swift.elements.stmt.LabeledStmt import codeql.swift.elements.pattern.Pattern +import codeql.swift.elements.decl.PatternBindingDecl module Generated { class ForEachStmt extends Synth::TForEachStmt, LabeledStmt { @@ -17,44 +18,18 @@ module Generated { * behavior of both the `Immediate` and non-`Immediate` versions. */ Pattern getImmediatePattern() { - result = - Synth::convertPatternFromRaw(Synth::convertForEachStmtToRaw(this) - .(Raw::ForEachStmt) - .getPattern()) + result = Synth::convertPatternFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getPattern()) } /** * Gets the pattern of this for each statement. + * */ final Pattern getPattern() { - exists(Pattern immediate | - immediate = this.getImmediatePattern() and - result = immediate.resolve() - ) + exists(Pattern immediate | immediate = this.getImmediatePattern() and + result = immediate.resolve()) } - /** - * Gets the sequence of this for each statement. - * - * This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the - * behavior of both the `Immediate` and non-`Immediate` versions. - */ - Expr getImmediateSequence() { - result = - Synth::convertExprFromRaw(Synth::convertForEachStmtToRaw(this) - .(Raw::ForEachStmt) - .getSequence()) - } - - /** - * Gets the sequence of this for each statement. - */ - final Expr getSequence() { - exists(Expr immediate | - immediate = this.getImmediateSequence() and - result = immediate.resolve() - ) - } /** * Gets the where of this for each statement, if it exists. @@ -63,24 +38,39 @@ module Generated { * behavior of both the `Immediate` and non-`Immediate` versions. */ Expr getImmediateWhere() { - result = - Synth::convertExprFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getWhere()) + result = Synth::convertExprFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getWhere()) } /** * Gets the where of this for each statement, if it exists. + * */ final Expr getWhere() { - exists(Expr immediate | - immediate = this.getImmediateWhere() and - result = immediate.resolve() - ) + exists(Expr immediate | immediate = this.getImmediateWhere() and + result = immediate.resolve()) } /** * Holds if `getWhere()` exists. */ - final predicate hasWhere() { exists(this.getWhere()) } + final predicate hasWhere() { + exists(this.getWhere()) + } + + /** + * Gets the iteratorvar of this for each statement, if it exists. + * + */ + PatternBindingDecl getIteratorVar() { + result = Synth::convertPatternBindingDeclFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getIteratorVar()) + } + + /** + * Holds if `getIteratorVar()` exists. + */ + final predicate hasIteratorVar() { + exists(this.getIteratorVar()) + } /** * Gets the nextcall of this for each statement, if it exists. @@ -89,35 +79,32 @@ module Generated { * behavior of both the `Immediate` and non-`Immediate` versions. */ Expr getImmediateNextCall() { - result = - Synth::convertExprFromRaw(Synth::convertForEachStmtToRaw(this) - .(Raw::ForEachStmt) - .getNextCall()) + result = Synth::convertExprFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getNextCall()) } /** * Gets the nextcall of this for each statement, if it exists. + * */ final Expr getNextCall() { - exists(Expr immediate | - immediate = this.getImmediateNextCall() and - result = immediate.resolve() - ) + exists(Expr immediate | immediate = this.getImmediateNextCall() and + result = immediate.resolve()) } /** * Holds if `getNextCall()` exists. */ - final predicate hasNextCall() { exists(this.getNextCall()) } + final predicate hasNextCall() { + exists(this.getNextCall()) + } /** * Gets the body of this for each statement. + * */ BraceStmt getBody() { - result = - Synth::convertBraceStmtFromRaw(Synth::convertForEachStmtToRaw(this) - .(Raw::ForEachStmt) - .getBody()) + result = Synth::convertBraceStmtFromRaw(Synth::convertForEachStmtToRaw(this).(Raw::ForEachStmt).getBody()) } + } } diff --git a/swift/ql/lib/swift.dbscheme b/swift/ql/lib/swift.dbscheme index c7087ed249c..309d412a592 100644 --- a/swift/ql/lib/swift.dbscheme +++ b/swift/ql/lib/swift.dbscheme @@ -1908,7 +1908,6 @@ do_stmts( //dir=stmt for_each_stmts( //dir=stmt unique int id: @for_each_stmt, int pattern: @pattern_or_none ref, - int sequence: @expr_or_none ref, int body: @brace_stmt_or_none ref ); @@ -1918,6 +1917,12 @@ for_each_stmt_wheres( //dir=stmt int where: @expr_or_none ref ); +#keyset[id] +for_each_stmt_iterator_vars( //dir=stmt + int id: @for_each_stmt ref, + int iteratorVar: @pattern_binding_decl_or_none ref +); + #keyset[id] for_each_stmt_next_calls( //dir=stmt int id: @for_each_stmt ref, diff --git a/swift/ql/test/library-tests/ast/PrintAst.expected b/swift/ql/test/library-tests/ast/PrintAst.expected index e0141f14e4c..3f89a2d58cb 100644 --- a/swift/ql/test/library-tests/ast/PrintAst.expected +++ b/swift/ql/test/library-tests/ast/PrintAst.expected @@ -703,18 +703,20 @@ cfg.swift: # 155| Type = Int? # 138| getElement(0): [ForEachStmt] for ... in ... { ... } # 138| getPattern(): [AnyPattern] _ -# 138| getSequence(): [CallExpr] call to makeIterator() -# 138| getFunction(): [MethodLookupExpr] .makeIterator() -# 138| getBase(): [BinaryExpr] ... ....(_:_:) ... -# 138| getFunction(): [MethodLookupExpr] ....(_:_:) -# 138| getBase(): [TypeExpr] Int.Type -# 138| getTypeRepr(): [TypeRepr] Int -# 138| getMethodRef(): [DeclRefExpr] ...(_:_:) -# 138| getArgument(0): [Argument] : 0 -# 138| getExpr(): [IntegerLiteralExpr] 0 -# 138| getArgument(1): [Argument] : 10 -# 138| getExpr(): [IntegerLiteralExpr] 10 -#-----| getMethodRef(): [DeclRefExpr] makeIterator() +#-----| getIteratorVar(): [PatternBindingDecl] var ... = ... +# 138| getInit(0): [CallExpr] call to makeIterator() +# 138| getFunction(): [MethodLookupExpr] .makeIterator() +# 138| getBase(): [BinaryExpr] ... ....(_:_:) ... +# 138| getFunction(): [MethodLookupExpr] ....(_:_:) +# 138| getBase(): [TypeExpr] Int.Type +# 138| getTypeRepr(): [TypeRepr] Int +# 138| getMethodRef(): [DeclRefExpr] ...(_:_:) +# 138| getArgument(0): [Argument] : 0 +# 138| getExpr(): [IntegerLiteralExpr] 0 +# 138| getArgument(1): [Argument] : 10 +# 138| getExpr(): [IntegerLiteralExpr] 10 +#-----| getMethodRef(): [DeclRefExpr] makeIterator() +# 138| getPattern(0): [NamedPattern] $generator # 138| getNextCall(): [CallExpr] call to next() # 138| getFunction(): [MethodLookupExpr] .next() # 138| getBase(): [DeclRefExpr] $generator @@ -842,7 +844,6 @@ cfg.swift: # 158| getElse(): [BraceStmt] { ... } # 159| getElement(0): [ReturnStmt] return ... # 159| getResult(): [BooleanLiteralExpr] false -# 138| [NamedPattern] $generator # 138| [ConcreteVarDecl] $generator # 138| Type = IndexingIterator> # 141| [ConcreteVarDecl] $match @@ -3258,18 +3259,20 @@ cfg.swift: # 525| getBody(): [BraceStmt] { ... } # 526| getElement(0): [ForEachStmt] for ... in ... { ... } # 526| getPattern(): [NamedPattern] i -# 526| getSequence(): [CallExpr] call to makeIterator() -# 526| getFunction(): [MethodLookupExpr] .makeIterator() -# 526| getBase(): [BinaryExpr] ... ....(_:_:) ... -# 526| getFunction(): [MethodLookupExpr] ....(_:_:) -# 526| getBase(): [TypeExpr] Int.Type -# 526| getTypeRepr(): [TypeRepr] Int -# 526| getMethodRef(): [DeclRefExpr] ...(_:_:) -# 526| getArgument(0): [Argument] : 1 -# 526| getExpr(): [IntegerLiteralExpr] 1 -# 526| getArgument(1): [Argument] : 100 -# 526| getExpr(): [IntegerLiteralExpr] 100 -#-----| getMethodRef(): [DeclRefExpr] makeIterator() +#-----| getIteratorVar(): [PatternBindingDecl] var ... = ... +# 526| getInit(0): [CallExpr] call to makeIterator() +# 526| getFunction(): [MethodLookupExpr] .makeIterator() +# 526| getBase(): [BinaryExpr] ... ....(_:_:) ... +# 526| getFunction(): [MethodLookupExpr] ....(_:_:) +# 526| getBase(): [TypeExpr] Int.Type +# 526| getTypeRepr(): [TypeRepr] Int +# 526| getMethodRef(): [DeclRefExpr] ...(_:_:) +# 526| getArgument(0): [Argument] : 1 +# 526| getExpr(): [IntegerLiteralExpr] 1 +# 526| getArgument(1): [Argument] : 100 +# 526| getExpr(): [IntegerLiteralExpr] 100 +#-----| getMethodRef(): [DeclRefExpr] makeIterator() +# 526| getPattern(0): [NamedPattern] $i$generator # 526| getNextCall(): [CallExpr] call to next() # 526| getFunction(): [MethodLookupExpr] .next() # 526| getBase(): [DeclRefExpr] $i$generator @@ -3291,11 +3294,13 @@ cfg.swift: # 523| getPattern(0): [NamedPattern] stream # 533| getElement(1): [ForEachStmt] for ... in ... { ... } # 533| getPattern(): [NamedPattern] i -# 533| getSequence(): [CallExpr] call to makeAsyncIterator() -# 533| getFunction(): [MethodLookupExpr] .makeAsyncIterator() -# 533| getBase(): [DeclRefExpr] stream -# 533| getBase().getFullyConverted(): [LoadExpr] (AsyncStream) ... -#-----| getMethodRef(): [DeclRefExpr] makeAsyncIterator() +#-----| getIteratorVar(): [PatternBindingDecl] var ... = ... +# 533| getInit(0): [CallExpr] call to makeAsyncIterator() +# 533| getFunction(): [MethodLookupExpr] .makeAsyncIterator() +# 533| getBase(): [DeclRefExpr] stream +# 533| getBase().getFullyConverted(): [LoadExpr] (AsyncStream) ... +#-----| getMethodRef(): [DeclRefExpr] makeAsyncIterator() +# 533| getPattern(0): [NamedPattern] $i$generator # 533| getNextCall(): [CallExpr] call to next() # 533| getFunction(): [MethodLookupExpr] .next() # 533| getBase(): [DeclRefExpr] $i$generator @@ -3317,12 +3322,10 @@ cfg.swift: # 525| [NilLiteralExpr] nil # 526| [ConcreteVarDecl] i # 526| Type = Int -# 526| [NamedPattern] $i$generator # 526| [ConcreteVarDecl] $i$generator # 526| Type = IndexingIterator> # 533| [ConcreteVarDecl] i # 533| Type = Int -# 533| [NamedPattern] $i$generator # 533| [ConcreteVarDecl] $i$generator # 533| Type = AsyncStream.Iterator declarations.swift: @@ -6612,18 +6615,20 @@ statements.swift: # 9| Type = Int # 2| getElement(0): [ForEachStmt] for ... in ... { ... } # 2| getPattern(): [NamedPattern] i -# 2| getSequence(): [CallExpr] call to makeIterator() -# 2| getFunction(): [MethodLookupExpr] .makeIterator() -# 2| getBase(): [BinaryExpr] ... ....(_:_:) ... -# 2| getFunction(): [MethodLookupExpr] ....(_:_:) -# 2| getBase(): [TypeExpr] Int.Type -# 2| getTypeRepr(): [TypeRepr] Int -# 2| getMethodRef(): [DeclRefExpr] ...(_:_:) -# 2| getArgument(0): [Argument] : 1 -# 2| getExpr(): [IntegerLiteralExpr] 1 -# 2| getArgument(1): [Argument] : 5 -# 2| getExpr(): [IntegerLiteralExpr] 5 -#-----| getMethodRef(): [DeclRefExpr] makeIterator() +#-----| getIteratorVar(): [PatternBindingDecl] var ... = ... +# 2| getInit(0): [CallExpr] call to makeIterator() +# 2| getFunction(): [MethodLookupExpr] .makeIterator() +# 2| getBase(): [BinaryExpr] ... ....(_:_:) ... +# 2| getFunction(): [MethodLookupExpr] ....(_:_:) +# 2| getBase(): [TypeExpr] Int.Type +# 2| getTypeRepr(): [TypeRepr] Int +# 2| getMethodRef(): [DeclRefExpr] ...(_:_:) +# 2| getArgument(0): [Argument] : 1 +# 2| getExpr(): [IntegerLiteralExpr] 1 +# 2| getArgument(1): [Argument] : 5 +# 2| getExpr(): [IntegerLiteralExpr] 5 +#-----| getMethodRef(): [DeclRefExpr] makeIterator() +# 2| getPattern(0): [NamedPattern] $i$generator # 2| getNextCall(): [CallExpr] call to next() # 2| getFunction(): [MethodLookupExpr] .next() # 2| getBase(): [DeclRefExpr] $i$generator @@ -6768,7 +6773,6 @@ statements.swift: # 29| getPattern().getFullyUnresolved(): [BindingPattern] let ... # 2| [ConcreteVarDecl] i # 2| Type = Int -# 2| [NamedPattern] $i$generator # 2| [ConcreteVarDecl] $i$generator # 2| Type = IndexingIterator> # 21| [ConcreteVarDecl] error @@ -7044,10 +7048,6 @@ statements.swift: # 71| getBody(): [BraceStmt] { ... } # 71| getElement(0): [ForEachStmt] for ... in ... where ... { ... } # 71| getPattern(): [NamedPattern] number -# 71| getSequence(): [CallExpr] call to makeIterator() -# 71| getFunction(): [MethodLookupExpr] .makeIterator() -# 71| getBase(): [DeclRefExpr] numbers -#-----| getMethodRef(): [DeclRefExpr] makeIterator() # 71| getWhere(): [BinaryExpr] ... .==(_:_:) ... # 71| getFunction(): [MethodLookupExpr] .==(_:_:) # 71| getBase(): [TypeExpr] Int.Type @@ -7065,6 +7065,12 @@ statements.swift: # 71| getExpr(): [IntegerLiteralExpr] 2 # 71| getArgument(1): [Argument] : 0 # 71| getExpr(): [IntegerLiteralExpr] 0 +#-----| getIteratorVar(): [PatternBindingDecl] var ... = ... +# 71| getInit(0): [CallExpr] call to makeIterator() +# 71| getFunction(): [MethodLookupExpr] .makeIterator() +# 71| getBase(): [DeclRefExpr] numbers +#-----| getMethodRef(): [DeclRefExpr] makeIterator() +# 71| getPattern(0): [NamedPattern] $number$generator # 71| getNextCall(): [CallExpr] call to next() # 71| getFunction(): [MethodLookupExpr] .next() # 71| getBase(): [DeclRefExpr] $number$generator @@ -7073,7 +7079,6 @@ statements.swift: # 71| getBody(): [BraceStmt] { ... } # 71| [ConcreteVarDecl] number # 71| Type = Int -# 71| [NamedPattern] $number$generator # 71| [ConcreteVarDecl] $number$generator # 71| Type = IndexingIterator<[Int]> # 74| [StructDecl] HasModifyAccessorDecl diff --git a/swift/schema.py b/swift/schema.py index 05cc4482bcd..809d071442d 100644 --- a/swift/schema.py +++ b/swift/schema.py @@ -986,8 +986,8 @@ class DoStmt(LabeledStmt): class ForEachStmt(LabeledStmt): pattern: Pattern | child - sequence: Expr | child where: optional[Expr] | child + iteratorVar: optional[PatternBindingDecl] | child nextCall: optional[Expr] | child body: BraceStmt | child