Skip to content

Rust: Add more Operation subclasses #19562

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 7 commits into from
May 27, 2025
Merged

Rust: Add more Operation subclasses #19562

merged 7 commits into from
May 27, 2025

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented May 22, 2025

Add more Operation subclasses - ArithmeticOperation, BitwiseOperation, DerefExpr. Follows on from #19535, but I've kept these ones a bit simpler as they're not currently used (except for DerefExpr which I found several uses for). I feel we should have these concepts, like other languages we support, rather than conspicuous gaps.

@Copilot Copilot AI review requested due to automatic review settings May 22, 2025 14:24
@geoffw0 geoffw0 requested a review from a team as a code owner May 22, 2025 14:24
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label May 22, 2025
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

Adds new Operation subclasses for arithmetic, bitwise, and dereference expressions, then wires them into tests and existing modules.

  • Introduce ArithmeticOperation, BitwiseOperation, and DerefExpr with matching imports
  • Update type inference, pointer‐access, and variable modules to use DerefExpr
  • Extend test expectations and describe() logic to cover the new subclasses

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/ql/test/library-tests/operations/test.rs Updated expected classifications for arithmetic, bitwise, and deref tests
rust/ql/test/library-tests/operations/Operations.ql Extended describe() to handle the new Operation subclasses
rust/ql/lib/rust.qll Imported ArithmeticOperation, BitwiseOperation, and DerefExpr
rust/ql/lib/codeql/rust/security/AccessInvalidPointerExtensions.qll Swapped PrefixExpr "*" check for DerefExpr
rust/ql/lib/codeql/rust/internal/TypeInference.qll Replaced raw PrefixExpr deref checks with DerefExpr
rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll Excluded DerefExpr instead of hard‐coding "*" prefix checks
rust/ql/lib/codeql/rust/elements/internal/RefExprImpl.qll Made RefExpr implement Operation and provided operator/operand overrides
rust/ql/lib/codeql/rust/elements/DerefExpr.qll Added the DerefExpr class
rust/ql/lib/codeql/rust/elements/BitwiseOperation.qll Added abstract BitwiseOperationImpl and its concrete subclasses
rust/ql/lib/codeql/rust/elements/ArithmeticOperation.qll Added abstract ArithmeticOperationImpl and its concrete subclasses
Comments suppressed due to low confidence (1)

rust/ql/test/library-tests/operations/test.rs:53

  • Update this test comment to include PrefixExpr (and remove the MISSING: placeholder), e.g.: // $ Operation Op=& Operands=1 RefExpr PrefixExpr so that RefExpr is recognized as both an Operation and a prefix expression.
&x; // $ Operation Op=& Operands=1 RefExpr MISSING: PrefixExpr

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Really cleans things up. Two tiny suggestions but other it looks great.

Co-authored-by: Simon Friis Vindum <paldepind@github.com>
@geoffw0
Copy link
Contributor Author

geoffw0 commented May 27, 2025

Suggestions accepted, thanks for reviewing!

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

🎉

@geoffw0 geoffw0 merged commit c971737 into github:main May 27, 2025
17 checks passed
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