Rust: Add more Operation subclasses#19562
Merged
geoffw0 merged 7 commits intogithub:mainfrom May 27, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds new Operation subclasses for arithmetic, bitwise, and dereference expressions, then wires them into tests and existing modules.
- Introduce
ArithmeticOperation,BitwiseOperation, andDerefExprwith 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 theMISSING:placeholder), e.g.:// $ Operation Op=& Operands=1 RefExpr PrefixExprso thatRefExpris recognized as both an Operation and a prefix expression.
&x; // $ Operation Op=& Operands=1 RefExpr MISSING: PrefixExpr
paldepind
requested changes
May 23, 2025
Contributor
paldepind
left a comment
There was a problem hiding this comment.
Thanks for working on this. Really cleans things up. Two tiny suggestions but other it looks great.
rust/ql/lib/codeql/rust/security/AccessInvalidPointerExtensions.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
Contributor
Author
|
Suggestions accepted, thanks for reviewing! |
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.
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 forDerefExprwhich I found several uses for). I feel we should have these concepts, like other languages we support, rather than conspicuous gaps.