Skip to content

Ssa: Refactor DataFlowIntegration - #23070

Merged
aschackmull merged 8 commits into
github:mainfrom
aschackmull:ssa/expr-refactor2
Nov 11, 2026
Merged

aschackmull merged 8 commits into
github:mainfrom
aschackmull:ssa/expr-refactor2

Conversation

@aschackmull

Copy link
Copy Markdown
Contributor

The Expr type in DataFlowIntegration in SSA is was misleading - it wasn't really an expression, but rather a control flow node. This PR refactors the interface to get rid of this type and with it hopefully any associated mistakes.

Matching the resulting read nodes to data flow nodes ought to be done with a join on both control flow node and sourcevariable, but joining on node alone can be ok if there are no coinciding reads. I've generally left this alone, as most languages probably don't have coinciding reads, but I've updated C++ and the VariableCapture library in this regard. Unified already joined on both columns.

Review is intended commit-by-commit, but the changes aren't that big, so end-to-end is also doable if preferred.

@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Nov 10, 2026
@aschackmull
aschackmull requested review from a team as code owners November 10, 2026 08:56
Copilot AI auto review requested due to automatic review settings November 10, 2026 08:56

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.

🟡 Changes recommended

An unresolved documentation nit in Ssa.qll leaves the renamed read-node class summary and getSourceVariable() documentation using outdated expression-node terminology.

1 open issue
What changed in this PR

Refactors shared SSA data-flow integration to represent reads by control-flow node and source variable, replacing the misleading Expr abstraction across language integrations.

Changes:

  • Introduces ReadNode, PostUpdateReadNode, and readsAt APIs.
  • Simplifies post-update inputs and updates shared flow and guard logic.
  • Migrates language integrations and adds variable-aware joins for C++ iterator and variable-capture reads.
File Description
unified/​ql/​lib/​codeql/​unified/​internal/​dataflow/​LocalSsa.qll Adopts post-update inputs and new read-node mappings.
shared/​ssa/​codeql/​ssa/​Ssa.qll Defines read-node APIs and updates SSA flow logic.
shared/​dataflow/​codeql/​dataflow/​VariableCapture.qll Joins capture reads by CFG position and variable.
rust/​ql/​lib/​codeql/​rust/​dataflow/​internal/​SsaImpl.qll Removes the obsolete expression adapter.
rust/​ql/​lib/​codeql/​rust/​dataflow/​internal/​DataFlowImpl.qll Maps new read nodes through control-flow nodes.
ruby/​ql/​lib/​codeql/​ruby/​dataflow/​internal/​SsaImpl.qll Removes the obsolete expression adapter.
ruby/​ql/​lib/​codeql/​ruby/​dataflow/​internal/​DataFlowPrivate.qll Updates read and post-update conversions.
javascript/​ql/​lib/​semmle/​javascript/​dataflow/​internal/​sharedlib/​Ssa.qll Removes the obsolete expression adapter.
javascript/​ql/​lib/​semmle/​javascript/​dataflow/​internal/​DataFlowPrivate.qll Converts new SSA read types to data-flow nodes.
java/​ql/​lib/​semmle/​code/​java/​dataflow/​internal/​SsaImpl.qll Removes the obsolete expression adapter.
java/​ql/​lib/​semmle/​code/​java/​dataflow/​internal/​DataFlowNodes.qll Maps reads through expression control-flow nodes.
csharp/​ql/​lib/​semmle/​code/​csharp/​dataflow/​internal/​SsaImpl.qll Removes the obsolete expression adapter.
csharp/​ql/​lib/​semmle/​code/​csharp/​dataflow/​internal/​DataFlowPrivate.qll Updates mappings to the new read-node types.
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​dataflow/​internal/​SsaImpl.qll Removes the obsolete instruction-based expression adapter.
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​dataflow/​internal/​DataFlowPrivate.qll Removes the iterator adapter and makes read joins variable-aware.

Review effort: Max (auto)

Comment thread shared/ssa/codeql/ssa/Ssa.qll Resolved
@aschackmull

Copy link
Copy Markdown
Contributor Author

Dca is uneventful.

@asgerf asgerf 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.

face

@aschackmull
aschackmull merged commit dcdd612 into github:main Nov 11, 2026
120 of 121 checks passed
@aschackmull
aschackmull deleted the ssa/expr-refactor2 branch November 11, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# C++ DataFlow Library Java JS no-change-note-required This PR does not need a change note Ruby Rust Pull requests that update Rust code Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants