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)
| private predicate constantCondition(AstNode n, ConditionalSuccessor t) { | ||
| n.(BooleanLiteral).getValue() = t.(BooleanSuccessor).getValue() | ||
| private predicate patternAlwaysMatches(AstNode pattern) { | ||
| Input1::patternIsExhaustive(pattern) |
Comment on lines
+1173
to
+1175
| predicate isAfterMatch(AstNode n) { | ||
| this.isAfterValue(n, any(MatchingSuccessor m | m.getValue() = true)) | ||
| } |
| result.isAfterMatch(pattern) | ||
| } | ||
|
|
||
| private predicate conjunctivePatternStep(PreControlFlowNode n1, PreControlFlowNode n2) { |
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
November 19, 2026 10:43
673da30 to
c42f271
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>
hvitved
force-pushed
the
hvitved-shared-cfg-library-split
branch
from
November 19, 2026 12:29
c42f271 to
b4e1bbb
Compare
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.



Summary
Extract shared CFG pattern support from #22864 into a standalone change against
main.The first commit adds the shared
Pattern,AndPattern,OrPattern, andNotPatternAPI and the corresponding nested-pattern control-flow handling. It also removes the old pattern-match-specific special case in shared CFG successor handling.The C# commit models its pattern expressions with the shared API and updates the affected CFG baselines. The Java commit models binding
instanceofand record patterns and includes the updated pattern-instanceof CFG expectation. Separate commits addNotPatternstubs for Actions, Go, Python, Ruby, and Unified. No Rust files are included.Validation
mainlibraries on the same extracted dataset; both versions produce identical results.