Fix Go expression-switch CFG migration to shared library#22035
Draft
Copilot wants to merge 5 commits into
Draft
Conversation
Copilot
AI
changed the title
[WIP] Refactor switchStmt to leverage shared cfg library
Investigation: switchStmt shared-CFG refactor blocked by missing prerequisite
Jun 22, 2026
Copilot
AI
changed the title
Investigation: switchStmt shared-CFG refactor blocked by missing prerequisite
Go CFG: move switch handling onto the shared CFG library
Jun 23, 2026
Copilot
AI
changed the title
Go CFG: move switch handling onto the shared CFG library
Adopt shared CFG library for Go switch statements (analysis + migration plan)
Jun 23, 2026
…to copilot/update-switch-stmt-usage
Copilot
AI
changed the title
Adopt shared CFG library for Go switch statements (analysis + migration plan)
Spike: migrate Go expression-switch CFG onto the shared library (investigation, no committed changes)
Jun 23, 2026
…h via fallsThrough
Copilot
AI
changed the title
Spike: migrate Go expression-switch CFG onto the shared library (investigation, no committed changes)
Migrate Go expression switch CFG to the shared control-flow library
Jun 23, 2026
Copilot
AI
changed the title
Migrate Go expression switch CFG to the shared control-flow library
Fix Go expression-switch CFG migration to shared library
Jun 23, 2026
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.
Continues migrating Go's expression-switch control-flow graph onto the shared CFG library (
shared/controlflow), fixing correctness bugs surfaced while verifying the new graph. No change notes added, per instruction.CFG construction
getChild(ControlFlowGraphShared.qll) now sees through the transparent expression-switch body block so case clauses remain children of the switch. The shared library's abrupt-completion propagation walks the AST child chain, so severing it droppedpanic-style edges from case bodies to the function's exceptional exit.simpleLeafNode(sharedControlFlowGraph.qll) now excludesSwitch. A childlessswitch {}was merged into a single before/after node, turning its explicit before→after step into a self-loop.Constant-case sanitizer
After testExpr.isSwitchCaseTestPassingEdgenow keys onpred.isAfter(cc)(public signature unchanged).TaintTrackingUtil.qll) now treats the body edge as constant-sanitizing only when all of a case's test expressions are constant, since every pattern of a case shares one matched edge — preserving precision for mixed const/non-const cases.Expected output
.expected(new[match]/[no-match]case-clause nodes; fallthrough flows to the next case body)..expectedfiles: location-only relocations (structure preserved; phi nodes now sit at the merge construct).Type-switch follow-up (investigation only)
Type switches fit the shared
Switch/Casemodel — pattern tests are already match/no-match rather than boolean, and operand/init/default/flattened bodies map onto existing hooks. The one gap is the implicit per-case binder inswitch x := y.(type), which has no unconditional slot between match and body. Recommended path: add adefault-nonegetCaseBinding(Case)hook (mirroringgetSwitchInit/fallsThrough) and then retire the bespoketypeSwitch/typeCaseClausepredicates. Not implemented here.Original prompt
Created from VS Code.