FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cfg: Share more code for switch statements. by aschackmull · Pull Request #21441 · github/codeql · GitHub

/ codeql Public

Cfg: Share more code for switch statements. - #21441

Merged
aschackmull merged 4 commits into
github:mainfrom
aschackmull:cfg/switch-sharing
Mar 10, 2026
Merged

Cfg: Share more code for switch statements.#21441
aschackmull merged 4 commits into
github:mainfrom
aschackmull:cfg/switch-sharing

Conversation

Copy link
Copy Markdown
Contributor

Originally I implemented some of the complexity for switch statement control flow on the Java side, but C# needs the exact same thing (and it's plausible other languages will as well), so this PR moves those bits of code into the shared CFG library.

This PR only moves a few predicates and should be completely behaviour preserving.

aschackmull added the no-change-note-required This PR does not need a change note label Mar 10, 2026
Copilot AI review requested due to automatic review settings March 10, 2026 10:15
github-actions Bot added the Java label Mar 10, 2026

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR centralizes switch-statement control-flow handling in the shared CFG library so that multiple language front-ends (starting with Java and C#) can reuse the same logic.

Changes:

  • Extend the shared CFG AST signature for switches to support both “nested case body” and “flat statement list” switch representations.
  • Move switch case ordering/body-element handling from the Java CFG implementation into the shared CFG implementation.
  • Update Java’s AST signature implementation to conform to the new shared switch/case interface.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
shared/controlflow/codeql/controlflow/ControlFlowGraph.qll Adds shared switch/case APIs and shared predicates for case ordering and body extraction.
java/ql/lib/semmle/code/java/ControlFlowGraph.qll Removes Java-specific switch CFG helpers now provided by the shared library; implements new shared switch/case APIs.

You can also share your feedback on Copilot code review. Take the survey.

hvitved previously approved these changes Mar 10, 2026

hvitved 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👍

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aschackmull merged commit 6a6bb5e into github:main Mar 10, 2026
181 of 185 checks passed
aschackmull deleted the cfg/switch-sharing branch March 10, 2026 12:50
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

Labels

Java no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL