Skip to content

C++: Add dataflow through NSDMI#21611

Merged
MathiasVP merged 8 commits intogithub:mainfrom
MathiasVP:nsdmi-dataflow-3
Mar 30, 2026
Merged

C++: Add dataflow through NSDMI#21611
MathiasVP merged 8 commits intogithub:mainfrom
MathiasVP:nsdmi-dataflow-3

Conversation

@MathiasVP
Copy link
Copy Markdown
Contributor

@MathiasVP MathiasVP commented Mar 30, 2026

This PR adds dataflow through NSDMI which was left out of #21391.

The required changes are fairly simple:

I did two small improvements in between those changes: In eb35fa0 I did a small refactoring of the parameter classes to avoid having duplicate implementations of isSourceParameterOf, and in 78c0c7c I excluded some dataflow nodes tests since it doesn't make sense to test these particular nodes.

Fixes: #21032

@MathiasVP MathiasVP requested a review from a team as a code owner March 30, 2026 10:22
Copilot AI review requested due to automatic review settings March 30, 2026 10:22
@github-actions github-actions bot added the C++ label Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing IR dataflow support for non-static data member initializers (NSDMI), completing the work started in #21391 by ensuring this typing and callable handling work for IRFunctions generated from fields.

Changes:

  • Extend IR “this type” computation to support IRFunctions generated from Field declarations.
  • Generalize a few call/parameter-related APIs from Function to Declaration to cover generated callables.
  • Update C++ dataflow library-tests and expected outputs to reflect the new IR flows and adjusted node typing checks.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll Updates getThisType and its doc to support IRFunctions generated from declarations beyond member functions.
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll Generalizes static call target plumbing from Function to Declaration.
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowNodes.qll Refactors parameter-node logic (incl. this) and generalizes APIs to Declaration.
cpp/ql/test/library-tests/dataflow/fields/C.cpp Updates inline expectations to reflect new IR flow for s2 via NSDMI.
cpp/ql/test/library-tests/dataflow/fields/ir-path-flow.expected Updates expected IR path flow edges/nodes/subpaths to include s2 flows.
cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp Updates inline expectations for NSDMI test to reflect new IR flow.
cpp/ql/test/library-tests/dataflow/dataflow-tests/test-source-sink.expected Updates expected IR source→sink flows for NSDMI scenario.
cpp/ql/test/library-tests/dataflow/dataflow-tests/type-bugs.ql Excludes FlowSummaryNode from the “node has exactly one type” check.
cpp/ql/test/library-tests/dataflow/dataflow-tests/type-bugs.expected Updates expected results after excluding summary nodes from the IR type-bugs query.

MathiasVP and others added 2 commits March 30, 2026 11:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jketema
jketema previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if the latest DCA is happy.

@MathiasVP
Copy link
Copy Markdown
Contributor Author

MathiasVP commented Mar 30, 2026

Oh. Some unexpected consistency issues in the IR folder (I always forget that we also have dataflow consistency checks in that folder!)

I'll have a quick look.

Edit: Fixed by 5db069e. This consistency violation was already present on main, and the new code just made it more noisy. I've now fixed the underlying problem.

@MathiasVP
Copy link
Copy Markdown
Contributor Author

DCA was uneventful. Merging!

@MathiasVP MathiasVP merged commit b83d4e0 into github:main Mar 30, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++] data flow node not found

3 participants