Codegen: Add Raw::getImmediateChild and Synth::getSynthParent#20790
Merged
hvitved merged 3 commits intogithub:mainfrom Nov 10, 2025
Merged
Codegen: Add Raw::getImmediateChild and Synth::getSynthParent#20790hvitved merged 3 commits intogithub:mainfrom
Raw::getImmediateChild and Synth::getSynthParent#20790hvitved merged 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds infrastructure for traversing parent-child relationships in the CodeQL Swift and Rust database schemas. The changes introduce helper methods to count indexed properties and get immediate children of elements.
Key Changes:
- Added
getNumberOf*()methods for all indexed properties to count elements - Added
getImmediateChild()infrastructure to retrieve children by index - Added
getSynthParent()method to get parents of synthetic elements - Updated code generation templates to produce the new helper methods
Reviewed Changes
Copilot reviewed 5 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
swift/ql/lib/codeql/swift/generated/Synth.qll |
Added getSynthParent() function and blank lines before doc comments for consistency |
swift/ql/lib/codeql/swift/generated/Raw.qll |
Added getNumberOf*() methods for indexed properties and getImmediateChild*() functions for parent-child traversal |
swift/ql/lib/codeql/swift/generated/ParentChild.qll |
Replaced max(int i | i = -1 or exists(...) | i) pattern with cleaner getNumberOf*() calls |
misc/codegen/templates/*.mustache |
Updated templates to generate the new helper methods |
swift/ql/.generated.list, rust/ql/.generated.list |
Updated checksums for regenerated files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
redsun82
approved these changes
Nov 10, 2025
Contributor
redsun82
left a comment
There was a problem hiding this comment.
Thanks! Also, nice simplification using getNumberOf... in ParentChild.qll 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #20770. Having the parent/child relation on raw elements is needed when one wants to refer to it in the definition of synthetic elements, to avoid empty or non-monotonic recursion.
DCA is uneventful.