Uh oh!
There was an error while loading. Please reload this page.
C++: Add dataflow through NSDMI - #21611
Conversation
…ntation for positional parameters.
…losing callables being fields.
There was a problem hiding this comment.
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 “
thistype” computation to support IRFunctions generated fromFielddeclarations. - Generalize a few call/parameter-related APIs from
FunctiontoDeclarationto 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. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jketema
left a comment
There was a problem hiding this comment.
LGTM if the latest DCA is happy.
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 |
MathiasVP
commented
Mar 30, 2026
DCA was uneventful. Merging! |
Uh oh!
There was an error while loading. Please reload this page.
This PR adds dataflow through NSDMI which was left out of #21391.
The required changes are fairly simple:
FunctiontoDeclarationin a few places (for the same reason as we did in C++: Handle field initialization via NSDMI in IR generation #21391).getThisTypeto make it possible to obtain the type forthisin theIRFunctions generated from theField.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