-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Add Operation class #19454
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
base: main
Are you sure you want to change the base?
Rust: Add Operation class #19454
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
This PR introduces a unified Operation
class in the Rust QL library, letting all unary, binary, assignment, and logical expressions share a consistent interface with getOperatorName()
and getAnOperand()
.
- Defined
OperationImpl::Operation
and aliased it asOperation
- Updated
PrefixExpr
andBinaryExpr
implementations to mix inOperation
- Added imports of
Operation
in query modules and extended tests to exercise the new API
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
File | Description |
---|---|
rust/ql/lib/codeql/rust/elements/Operation.qll | Added the abstract Operation class and alias |
rust/ql/lib/codeql/rust/elements/internal/PrefixExprImpl.qll | Extended PrefixExpr to implement Operation |
rust/ql/lib/codeql/rust/elements/internal/BinaryExprImpl.qll | Extended BinaryExpr to implement Operation |
rust/ql/test/library-tests/operations/test.rs | Expanded inline tests for various operators |
Comments suppressed due to low confidence (1)
rust/ql/test/library-tests/operations/test.rs:54
- No inline expectation is provided for the
?
try operator. Consider adding an expectation comment, for example:// $ Operation Op=? Operands=1 PrefixExpr
to validate its classification and operands.
res?;
DCA shows nothing interesting, which is what we'd expect for a change like this. |
Unify various classes representing operations under a single
Operation
class, providing a single consistent interface (withgetOperatorName()
andgetAnOperand()
) for reasoning about them.The idea is to get things in order before I follow up with another PR that will add new subclasses, allowing us to find things like the dereference expression (
*
) and comparison operations more easily.