Repository navigation
Guards: Generalise Guard.isEquality to use GuardValue. - #23164
Conversation
5eb503c to
f97118f
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The shared public Guard.isEquality parameter contract changes across languages, requiring downstream compatibility review and coordinated migration beyond the scope of a contract-preserving mechanical review.
No open issues 🎉
What changed in this PR
Generalizes the shared Guard.isEquality API to accept GuardValue instead of boolean, updating Java, Go, and C# consumers while preserving boolean interfaces where needed.
Changes:
- Migrates equality checks and related control-flow logic to
GuardValue. - Adds boolean adapters for range analyses and updates affected test queries.
- Documents the breaking API change and migration options for Java and C#.
| File | Description |
|---|---|
shared/controlflow/codeql/controlflow/Guards.qll |
Changes isEquality to accept GuardValue and updates its internal caller. |
java/ql/test/library-tests/guards12/guard.ql |
Uses guard values for equality and branch-control tests. |
java/ql/src/Likely Bugs/Comparison/UselessComparisonTest.ql |
Uses guard values and their duals to determine redundant comparisons. |
java/ql/lib/semmle/code/java/security/ArithmeticCommon.qll |
Migrates arithmetic bound checks to value-based barrier guards. |
java/ql/lib/semmle/code/java/security/AndroidIntentRedirection.qll |
Uses value-based control checks in intent sanitizers. |
java/ql/lib/semmle/code/java/os/OSCheck.qll |
Adapts boolean OS checks to the new equality API. |
java/ql/lib/semmle/code/java/dataflow/RangeAnalysis.qll |
Adds a boolean equality adapter for range analysis. |
java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll |
Preserves the boolean equality interface for sign analysis. |
java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll |
Preserves the boolean equality interface for modulus analysis. |
java/ql/lib/change-notes/2026-11-19-guards-isequality.md |
Documents Java’s breaking API change and migration options. |
go/ql/lib/semmle/go/controlflow/Guards.qll |
Adapts boolean equality and inequality helpers to guard values. |
csharp/ql/test/query-tests/Nullness/EqualityCheck.ql |
Updates the equality test query to use GuardValue. |
csharp/ql/test/library-tests/dataflow/barrier-guards/barrier-flow.ql |
Passes guard values directly to equality checks. |
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll |
Adapts boolean range-analysis polarity to the new API. |
csharp/ql/lib/change-notes/2026-11-19-guards-isequality.md |
Documents C#’s breaking API change and migration options. |
Review effort: Balanced (adaptive)
owen-mc
left a comment
There was a problem hiding this comment.
The go change looks fine. Any reason why the other languages get a change note, but not go? But then, maybe all languages using the guards library would need a change note. Do we do change notes for the shared libraries, in the shared folder?
I'm definitely open to input on that. I figured that the Go Guards instantiation was sufficiently recent and that the Go-specific |
|
I don't think we need any more change notes. This should be transparent to almost all users. |
No description provided.