-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
There was a problem hiding this 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
, andDerefExpr
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 theMISSING:
placeholder), e.g.:// $ Operation Op=& Operands=1 RefExpr PrefixExpr
so thatRefExpr
is recognized as both an Operation and a prefix expression.
&x; // $ Operation Op=& Operands=1 RefExpr MISSING: PrefixExpr
There was a problem hiding this 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.
rust/ql/lib/codeql/rust/security/AccessInvalidPointerExtensions.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
Suggestions accepted, thanks for reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
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 forDerefExpr
which I found several uses for). I feel we should have these concepts, like other languages we support, rather than conspicuous gaps.