Rust: Use get(An){Arg,Param} helper predicates#19717
Merged
hvitved merged 1 commit intogithub:mainfrom Jun 10, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors various QL modules to use the new helper predicates (getParam, getArg, getAParam, getAnArg) in place of manually traversing ParamList and ArgList.
- Replace calls like
getParamList().getParam(n)withgetParam(n)(andgetArgList().getArg(n)withgetArg(n)). - Swap
getParamList().getAParam()forgetAParam()andgetArgList().getAnArg()forgetAnArg(). - Simplify
parameterExactAccessand related call sites to use these helpers.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
CaptureModels.qll |
Use c.getParam(...) helper instead of c.getParamList().getParam. |
TypeInference.qll |
Switch to getParam(0) and getArg(0) helpers for type and args. |
Type.qll |
Use function.getAParam() rather than function.getParamList().getAParam(). |
VariableImpl.qll |
Simplify parameter pattern checks via getAParam(). |
CallExprImpl.qll |
Replace getArgList().getArg(...) with getArg(...). |
ControlFlowGraphImpl.qll |
Use getParam(i-1) instead of getParamList().getParam(i-1). |
CfgNodes.qll |
Swap getArgList().getAnArg() for getAnArg(). |
| not exists(Function f | not f.hasBody() and f.getAParam().getPat() = pat) and | ||
| // exclude parameters from function pointer types (e.g. `x` in `fn(x: i32) -> i32`) | ||
| not exists(FnPtrTypeRepr fp | fp.getParamList().getParam(_).getPat() = pat) | ||
| not exists(FnPtrTypeRepr fp | fp.getParamList().getAParam().getPat() = pat) |
There was a problem hiding this comment.
[nitpick] For consistency with other modules, call fp.getAParam() directly instead of via getParamList(). This matches how Function.getAParam() is used above.
Suggested change
| not exists(FnPtrTypeRepr fp | fp.getParamList().getAParam().getPat() = pat) | |
| not exists(FnPtrTypeRepr fp | fp.getAParam().getPat() = pat) |
paldepind
approved these changes
Jun 10, 2025
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.
No description provided.