Skip to content

Commit a4f97dd

Browse files
committed
Swift: add comment about unique in getImmediateParent
1 parent bc0a32c commit a4f97dd

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

swift/codegen/templates/ql_parent.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ Element getAnImmediateChild(Element e) {
4141
* if `e` has conversions, `getImmediateParent(e)` will give the bottom conversion in the hidden AST.
4242
*/
4343
Element getImmediateParent(Element e) {
44+
// `unique` is used here to tell the optimizer that there is in fact only one result
45+
// this is tested by the `library-tests/parent/no_double_parents.ql` test
4446
result = unique(Element x | e = getAnImmediateChild(x) | x)
4547
}

swift/ql/lib/codeql/swift/generated/GetImmediateParent.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,7 @@ Element getAnImmediateChild(Element e) {
238238
* if `e` has conversions, `getImmediateParent(e)` will give the bottom conversion in the hidden AST.
239239
*/
240240
Element getImmediateParent(Element e) {
241+
// `unique` is used here to tell the optimizer that there is in fact only one result
242+
// this is tested by the `library-tests/parent/no_double_parents.ql` test
241243
result = unique(Element x | e = getAnImmediateChild(x) | x)
242244
}

0 commit comments

Comments
 (0)