C#: Move handling of callables into shared control flow library#21743
C#: Move handling of callables into shared control flow library#21743hvitved merged 4 commits intogithub:mainfrom
Conversation
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
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>
|
DCA reported alert difference for C#, which happens because in some cases the same |
In preparation for adding parameters to the CFG, which we also want the shared CFG library to handle.