Repository navigation
Conversation
hvitved
marked this pull request as draft
November 19, 2026 10:09
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Missing exhaustiveness handling allows an already-successful pattern match to take a no-match shortcut, skipping binding children while still entering the true branch.
3 open issues
What changed in this PR
Prepares the shared control-flow graph framework for the Rust migration by extracting reusable pattern support, without changing Rust files or multipleSuccessors.
Changes:
- Adds pattern types, matching-outcome helpers, exhaustiveness hooks, and conjunctive/disjunctive control flow.
- Adds empty pattern adapters for seven existing consumers, keeping Python’s current pattern handling separate as
PythonPattern.
| File | Description |
|---|---|
unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll |
Adds empty pattern adapter classes. |
shared/controlflow/codeql/controlflow/ControlFlowGraph.qll |
Implements shared pattern APIs and control-flow construction. |
ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll |
Adds empty pattern adapter classes. |
python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll |
Renames the existing pattern wrapper and adds separate shared-pattern stubs. |
java/ql/lib/semmle/code/java/ControlFlowGraph.qll |
Adds empty pattern adapter classes. |
go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll |
Adds empty pattern adapter classes. |
csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll |
Adds empty pattern adapter classes. |
actions/ql/lib/codeql/actions/controlflow/internal/Cfg.qll |
Adds empty pattern adapter classes. |
Review effort: Max (adaptive)
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
4 times, most recently
from
November 20, 2026 15:25
3bd07eb to
23da6a7
Compare
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
3 times, most recently
from
November 23, 2026 19:28
b0e5b03 to
cbe8c49
Compare
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
November 24, 2026 10:00
cbe8c49 to
c043336
Compare
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
2 times, most recently
from
November 30, 2026 09:05
5f427d2 to
c2467c6
Compare
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
December 1, 2026 19:46
c2467c6 to
7da0317
Compare
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
8 times, most recently
from
December 3, 2026 09:39
0a210b0 to
b6faaac
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
December 3, 2026 10:27
b6faaac to
d79a10f
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
December 3, 2026 10:47
d79a10f to
cbce3e3
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical pattern-control-flow bugs remove reachable branches and disconnect following code, alongside regressions in modulus and non-null guard inference.
8 open issues
Treat slices as exhaustive unless nested patterns fail · New Do not mark nullable pattern tests exhaustive · New Exclude negated patterns from true-to-true propagation · New Restore non-null inference for successful disjunctions · New Preserve GuardValue in modulo guard analysis · New Preserve equality GuardValues in modulus flow · New Include array type tests in null-guard reasoning · New Preserve condition associations for pattern branches · New
3 resolved since last review
Review effort: Max (adaptive)
This branch has not been deployed
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.



Shared CFG
Model patterns explicitly, with match and no-match successors. Nested patterns are evaluated left to right with short-circuiting for conjunctions, disjunctions, and negation. Binding and exhaustive patterns avoid impossible failure paths.
A
PatternMatchExprnow evaluates its scrutinee followed by its pattern. The pattern’s match and no-match outcomes lead directly to the expression’s true and false outcomes, removing the synthetic intermediate match node:CFG before
flowchart TD 1["Entry"] 10["After ...instanceof... [false]"] 11["After ...instanceof... [true]"] 12["Before ...instanceof..."] 13["After { ... }"] 14["{ ... }"] 15["After chk(...)"] 16["Before chk(...)"] 17["chk(...)"] 18["<Expr>;"] 19["After <Expr>;"] 2["Exit"] 3["Normal Exit"] 4["After { ... }"] 5["{ ... }"] 6["After if (...)"] 7["if (...)"] 8["o"] 9["...instanceof..."] 1 --> 5 3 --> 2 4 --> 3 5 --> 7 6 --> 4 7 --> 12 8 --> 9 9 -- false --> 10 9 -- true --> 11 10 --> 6 11 --> 14 12 --> 8 13 --> 6 14 --> 18 15 --> 19 16 --> 17 17 --> 15 18 --> 16 19 --> 13CFG after
flowchart TD 1["Entry"] 10["After ...instanceof... [false]"] 11["After ...instanceof... [true]"] 12["After String [match]"] 13["After String [no-match]"] 14["String"] 15["After { ... }"] 16["{ ... }"] 17["After chk(...)"] 18["Before chk(...)"] 19["chk(...)"] 2["Exit"] 20["<Expr>;"] 21["After <Expr>;"] 3["Normal Exit"] 4["After { ... }"] 5["{ ... }"] 6["After if (...)"] 7["if (...)"] 8["o"] 9["...instanceof..."] 1 --> 5 3 --> 2 4 --> 3 5 --> 7 6 --> 4 7 --> 9 8 --> 14 9 --> 8 10 --> 6 11 --> 16 12 -- true --> 11 13 -- false --> 10 14 -- match --> 12 14 -- no-match --> 13 15 --> 6 16 --> 20 17 --> 21 18 --> 19 19 --> 17 20 --> 18 21 --> 15Guards and nullness
Update the guards library to reason about pattern outcomes and propagate them through nested patterns. A successful match is treated as an equality-like guard between the scrutinee and the applicable pattern.
Patterns known not to match
nullare included inNonNullExpr. This lets the existing equality-based guard logic infer non-nullness from successful matches, while null patterns use the same constant-equality reasoning. Consequently, several language-specific null-guard cases are no longer needed.The C# and Java integrations adopt the new CFG and guard behavior; other language adapters are updated for the expanded API.