C#: Move handling of callables into shared control flow library#21743
Open
hvitved wants to merge 3 commits intogithub:mainfrom
Open
C#: Move handling of callables into shared control flow library#21743hvitved wants to merge 3 commits intogithub:mainfrom
hvitved wants to merge 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors callable-handling in the shared control-flow library to support upcoming CFG parameter support, moving language-specific “multiple body parts” handling behind a shared interface.
Changes:
- Extends the shared CFG AST signature with a
CallableBodyPartContextandcallableGetBodyParthook. - Updates shared callable entry/exit and stepping logic to work with either a single callable body or multiple ordered body parts.
- Adapts Java and C# CFG inputs to provide an appropriate
CallableBodyPartContext(Voidfor Java,CompilationExtfor C#) and moves C# constructor/initializer body-part handling intocallableGetBodyPart.
Show a summary per file
| File | Description |
|---|---|
| shared/controlflow/codeql/controlflow/ControlFlowGraph.qll | Adds shared callable body-part abstraction and integrates it into shared CFG construction/consistency checks. |
| java/ql/lib/semmle/code/java/ControlFlowGraph.qll | Wires Java into the new shared callable body-part interface using Void as context. |
| csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowGraph.qll | Moves C# constructor/initializer callable handling to callableGetBodyPart and introduces CompilationExt as context. |
Copilot's findings
Comments suppressed due to low confidence (3)
shared/controlflow/codeql/controlflow/ControlFlowGraph.qll:470
- Wording in doc comment: "
indexth" is awkward; consider using "index-th" (or "indexth" without code formatting) to avoid the grammatical glitch.
* Gets the `index`th part of the body of `c` in context `ctx`.
*
shared/controlflow/codeql/controlflow/ControlFlowGraph.qll:472
- Doc comment is a bit ambiguous because
callableGetBodyis a function: instead of "must never both hold", consider wording like "must never both produce a result" / "must not both be defined" for the same callablec.
* `callableGetBodyPart(c, _, _)` and `callableGetBody(c)` must never both hold
* for a given callable `c`.
shared/controlflow/codeql/controlflow/ControlFlowGraph.qll:2183
- The comment "included in both
callableGetBodyandcallableGetBodyPart" is unclear (since these are relations/functions rather than collections). Consider rephrasing to explicitly state that it holds when bothcallableGetBody(c)has a result andcallableGetBodyPart(c, _, _)has a result for the samec.
/**
* Holds if `c` is included in both `callableGetBody` and `callableGetBodyPart`.
*/
- Files reviewed: 3/3 changed files
- Comments generated: 1
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
reviewed
Apr 22, 2026
aschackmull
requested changes
Apr 22, 2026
Contributor
aschackmull
left a comment
There was a problem hiding this comment.
Generally LGTM. I have a few slight preferences for some small tweaks, though.
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
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.
In preparation for adding parameters to the CFG, which we also want the shared CFG library to handle.