Repository navigation
Conversation
This commit should be read with `?w=1`.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Stale expected-result files will fail fixture comparisons, and unresolved inherited value_type aliases can cause forwarding flows to be missed.
2 open issues
What changed in this PR
This PR extends C++ model-as-data forwarding models to identify constructed types through nested aliases, avoiding the need to express complex template types directly in model rows.
Changes:
- Resolve named typedef members on the forwarding function’s declaring type.
- Update the container forwarding model to use
value_type. - Add scalar and pointer cases to the existing data-flow fixture.
| File | Description |
|---|---|
cpp/ql/test/library-tests/dataflow/external-models/test.cpp |
Adds value_type and scalar/pointer forwarding cases. |
cpp/ql/test/library-tests/dataflow/external-models/flow.ext.yml |
Switches the container model from T to value_type. |
cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll |
Adds nested typedef resolution for constructed types. |
Review effort: Balanced (auto)
jketema
approved these changes
Nov 4, 2026
|
|
||
| template<typename T> | ||
| struct Container { | ||
| using value_type = T; |
Contributor
There was a problem hiding this comment.
Nit: Indentation looks a bit funny here.
Contributor
Author
There was a problem hiding this comment.
Oops. I agree. I'll fix in a subsequent PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Consider a type such as:
We can model the fact that
insertcreates aTobject and inserts it into a value of typeContainerby using aforwardsmodel like:However, the value to construct can be more complex to identify than just the type name
T. For example, std::map constructs a value of typestd::pair<const Key, T>. And there's currently no way to identify such a complex type in the interpretation of theforwardsrows (nor do I think we should add support for identifying such complex types!)Instead, this PR makes it possible to simplify use the name of the nested type in the
forwardsmodel. For example, if we have:then we can model the fact that
insertcreates aWrapper<T>object and inserts it into a value of typeContainerby using aforwardsmodel like:Since we already had a suitable testcase for this I simply added a typedef and reused the existing testcase.
We still don't have any non-test forwards models. So I don't think this PR needs a DCA run.