mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Add get(Immediate)Child predicate
This commit is contained in:
@@ -79,6 +79,11 @@ Element getImmediateParent(Element e) {
|
||||
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.
|
||||
*/
|
||||
Element getImmediateChild(Element e, int index) { result = Impl::getImmediateChild(e, index, _) }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -92,3 +97,10 @@ Element getImmediateChildAndAccessor(Element e, int index, string accessor) {
|
||||
Element getChildAndAccessor(Element e, int index, string accessor) {
|
||||
exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor).resolve() 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.
|
||||
*/
|
||||
Element getChild(Element e, int index) {
|
||||
result = Impl::getImmediateChild(e, index, _).resolve()
|
||||
}
|
||||
|
||||
2
rust/ql/.generated.list
generated
2
rust/ql/.generated.list
generated
@@ -577,7 +577,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b
|
||||
lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60
|
||||
lib/codeql/rust/elements/internal/generated/ParenPat.qll 4f168ef5d5bb87a903251cc31b2e44a759b099ec69c90af31783fbb15778c940 0e34f94a45a13396fd57d94c245dc64d1adde2ab0e22b56946f7e94c04e297fc
|
||||
lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 40ab5c592e7699c621787793743e33988de71ff42ca27599f5ab3ddb70e3f7d8 12c0a6eed2202ee3e892f61da3b3ce77ac3190854cdf3097e8d2be98aa3cb91d
|
||||
lib/codeql/rust/elements/internal/generated/ParentChild.qll 9858c29b5852292e87dedc9bc9105b17915f5eb8198b6a29a2d621e26b7440ef 17c1a3e7bb344c7f9584ee2f28de622eb0f17ca4d967231f6215aa36261eeec9
|
||||
lib/codeql/rust/elements/internal/generated/ParentChild.qll eec4e7672ef5f07752044348d45882f0a849b295dfb17169e910ed0bfca3c162 29a9cc9b2870b1c6240cc53a9a70c4623381219a8f88ea1656b6828d16ef51c7
|
||||
lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll c5fa328ea60d3a3333d7c7bb3480969c1873166c7ac8ebb9d0afad7a8099d1a8 2dbbb6200d96f7db7dea4a55bdeab8d67b14d39a43e0bd54ada019f7e466f163
|
||||
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
|
||||
lib/codeql/rust/elements/internal/generated/Path.qll 8e47e91aff3f8c60f1ee8cb3887b8e4936c38e4665d052f2c92a939a969aac29 2c28beb89cabd7c7c91a5bc65c874f414cb96bbefde37b25811b61089a8a0053
|
||||
|
||||
@@ -236,13 +236,11 @@ module Impl {
|
||||
this instanceof VariableScope or
|
||||
this instanceof VariableAccessCand or
|
||||
this instanceof LetStmt or
|
||||
getImmediateChildAndAccessor(this, _, _) instanceof RelevantElement
|
||||
getImmediateChild(this, _) instanceof RelevantElement
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private RelevantElement getChild(int index) {
|
||||
result = getImmediateChildAndAccessor(this, index, _)
|
||||
}
|
||||
private RelevantElement getChild(int index) { result = getImmediateChild(this, index) }
|
||||
|
||||
pragma[nomagic]
|
||||
private RelevantElement getImmediateChildMin(int index) {
|
||||
|
||||
@@ -4403,6 +4403,11 @@ Element getImmediateParent(Element e) {
|
||||
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.
|
||||
*/
|
||||
Element getImmediateChild(Element e, int index) { result = Impl::getImmediateChild(e, index, _) }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -4422,3 +4427,8 @@ Element getChildAndAccessor(Element e, int index, string accessor) {
|
||||
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.
|
||||
*/
|
||||
Element getChild(Element e, int index) { result = Impl::getImmediateChild(e, index, _).resolve() }
|
||||
|
||||
@@ -40,7 +40,7 @@ query predicate multiplePrimaryQlClasses(Element e, string s) {
|
||||
s = strictconcat(e.getPrimaryQlClasses(), ", ")
|
||||
}
|
||||
|
||||
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
|
||||
private Element getParent(Element child) { child = getChild(result, _) }
|
||||
|
||||
private predicate multipleParents(Element child) { strictcount(getParent(child)) > 1 }
|
||||
|
||||
@@ -56,8 +56,8 @@ query predicate multipleParents(Element child, string childClass, Element parent
|
||||
|
||||
/** Holds if `parent` has multiple children at the same index. */
|
||||
query predicate multipleChildren(Element parent, int index, Element child1, Element child2) {
|
||||
child1 = getChildAndAccessor(parent, index, _) and
|
||||
child2 = getChildAndAccessor(parent, index, _) and
|
||||
child1 = getChild(parent, index) and
|
||||
child2 = getChild(parent, index) and
|
||||
child1 != child2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user