Guards: Refactor EqualityTest interface.#19884
Merged
aschackmull merged 1 commit intogithub:mainfrom Jun 26, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Refactors the equality-check interface in the Guards library by replacing the old EqualityTest class with a versatile predicate and updating all its usages.
- Introduce
predicate equalityTest(...)and remove theEqualityTestclass in the shared QL signature. - Add
equalityTestSymmetricand replaceeqtestHasOperandscalls in the shared controlflow module. - Remove Java-specific
EqualityTestclass and implementequalityTestpredicate covering==/!=and.equals(...)patterns.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| shared/controlflow/codeql/controlflow/Guards.qll | Remove EqualityTest class, add equalityTest predicate, update to use equalityTestSymmetric |
| java/ql/lib/semmle/code/java/controlflow/Guards.qll | Drop Java EqualityTest class, add equalityTest predicate to unify J::EqualityTest and equals calls |
Comments suppressed due to low confidence (2)
shared/controlflow/codeql/controlflow/Guards.qll:353
- [nitpick] The parameter name
eqvalis ambiguous; consider renaming it topolarityto match the fourth parameter ofequalityTestand improve clarity.
private predicate equalityTestSymmetric(Expr eqtest, Expr e1, Expr e2, boolean eqval) {
java/ql/lib/semmle/code/java/controlflow/Guards.qll:299
- The predicate references class
EqualityTest, but that class was removed earlier in this PR; this will cause a QL compilation error. You should refer directly to the built-inJ::EqualityTestAST type (or reintroduce a local alias) before calling itsgetLeftOperand(),getRightOperand(), andpolarity()methods.
exists(EqualityTest eq | eq = eqtest |
hvitved
approved these changes
Jun 26, 2025
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.
A minor refactor in the interface to the Guards library. This is necessary to facilitate instantiation in C# where a single expression might correspond to multiple equality checks. E.g.
x.compareTo(y) == 0is a single expression that both acts as an equality check between the comparison and 0, andxandy.