Skip to content

Guards: Generalise Guard.isEquality to use GuardValue. - #23164

Merged
aschackmull merged 2 commits into
github:mainfrom
aschackmull:guards/isequality
Nov 19, 2026
Merged

aschackmull merged 2 commits into
github:mainfrom
aschackmull:guards/isequality

Conversation

@aschackmull

Copy link
Copy Markdown
Contributor

No description provided.

@aschackmull
aschackmull marked this pull request as ready for review November 19, 2026 09:09
@aschackmull
aschackmull requested review from a team as code owners November 19, 2026 09:09
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 09:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 owen-mc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@aschackmull

aschackmull commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

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 guardEnsuresEq,guardEnsuresNeq were unchanged, so it would perhaps be a bit obscure in the Go context. Same goes for C++, actually (C++ has a bunch of language-specific comparesEq, ensuresEq, etc. predicates). But as I said, I have no strong opinion here - I can definitely add change notes for those languages as well.

@owen-mc

owen-mc commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

I don't think we need any more change notes. This should be transparent to almost all users.

@aschackmull
aschackmull merged commit 400e7ff into github:main Nov 19, 2026
120 checks passed
@aschackmull
aschackmull deleted the guards/isequality branch November 19, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants