Skip to content

Rust: Use get(An){Arg,Param} helper predicates #19717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jun 10, 2025

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jun 10, 2025
@hvitved hvitved marked this pull request as ready for review June 10, 2025 14:30
@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 14:30
@hvitved hvitved requested a review from a team as a code owner June 10, 2025 14:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) with getParam(n) (and getArgList().getArg(n) with getArg(n)).
  • Swap getParamList().getAParam() for getAParam() and getArgList().getAnArg() for getAnArg().
  • Simplify parameterExactAccess and 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().

// 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)
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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)

Copilot uses AI. Check for mistakes.

@hvitved hvitved requested review from redsun82 and a team June 10, 2025 16:48
@hvitved hvitved merged commit 64ab7c7 into github:main Jun 10, 2025
16 checks passed
@hvitved hvitved deleted the rust/use-get-arg-param branch June 10, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants