Skip to content

C++: Remove support for global variables as sources and sinks in MaD#22089

Open
MathiasVP wants to merge 6 commits into
github:mainfrom
MathiasVP:remove-mad-support-for-variables
Open

C++: Remove support for global variables as sources and sinks in MaD#22089
MathiasVP wants to merge 6 commits into
github:mainfrom
MathiasVP:remove-mad-support-for-variables

Conversation

@MathiasVP

@MathiasVP MathiasVP commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

When we added MaD support for C/C++ we added (partial) support for picking variables as flow sources or flow sinks. I was never really a fan of adding this kind of support with no clear use-case for it (see my comments here and here) and in the 2 years we've had MaD support we've never had a need for this particular feature, and the only occurrence of this has been in the tests we added 2 years ago. We've also never publicly documented this feature (as it was only ever partially implemented).

I am now adding support for access paths for MaD sources and sinks (because I've got a use-case for it coming up), and this feature variables as sources and sinks are making it harder to support this.

In conclusion: I think we should just remove this feature.

DCA was uneventful (as expected).

@github-actions github-actions Bot added the C++ label Jun 30, 2026
@MathiasVP MathiasVP force-pushed the remove-mad-support-for-variables branch from 85eee8c to 0e05ea5 Compare June 30, 2026 11:41
@MathiasVP MathiasVP marked this pull request as ready for review June 30, 2026 16:39
@MathiasVP MathiasVP requested a review from a team as a code owner June 30, 2026 16:39
Copilot AI review requested due to automatic review settings June 30, 2026 16:39

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.

Pull request overview

This PR removes the (previously partial/undocumented) ability for C/C++ Models-as-Data (MaD) to treat variables (global, namespace, and member variables) as flow sources/sinks, simplifying the MaD interpretation layer ahead of upcoming access-path work.

Changes:

  • Drops MaD “variable-as-element” interpretation paths in the C++ MaD implementation.
  • Updates the MaD C++ library tests and expected results to remove variable-based source/sink/summary cases.
  • Adds a breaking change note documenting the removal.
Show a summary per file
File Description
cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp Removes variable-based MaD source/sink/summary test cases (and related declarations).
cpp/ql/test/library-tests/dataflow/models-as-data/testModels.expected Updates expected interpreted elements to match the removal of variable-based models.
cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll Disables MaD input/output interpretation logic for variables.
cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll Removes element-resolution support for member variables and global/namespace variables.
cpp/ql/lib/change-notes/2026-06-30-variables-as-mad-sources-and-sinks.md Documents the breaking removal of variable sources/sinks in MaD.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp
Comment thread cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp
Comment thread cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp
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.

2 participants