C++: Implement MaD support for flow through perfect-forwarding functions - #22521
Draft
MathiasVP wants to merge 7 commits into
Draft
Conversation
MathiasVP
force-pushed
the
flow-through-forwards-using-callbacks-without-return-nodes-for-this
branch
2 times, most recently
from
September 8, 2026 11:18
8f8225a to
6edcabd
Compare
MathiasVP
force-pushed
the
flow-through-forwards-using-callbacks-without-return-nodes-for-this
branch
2 times, most recently
from
September 8, 2026 11:34
ccad487 to
f8d0434
Compare
In the upcoming commits we will add a new extensional predicate which allows us to model that a function forwards it arguments to the constructor of a given type. This initial commit adds the test YAML models for this new extensional predicate.
signature to implement the forwardsModel. So instead of recursing on the number of elements in the signature we will recurse on the number of elements in the type (or name) columns. For well-formed models this will be equivalent.
MathiasVP
force-pushed
the
flow-through-forwards-using-callbacks-without-return-nodes-for-this
branch
from
September 8, 2026 11:53
f8d0434 to
ada9784
Compare
…nd implement forwarding.
MathiasVP
force-pushed
the
flow-through-forwards-using-callbacks-without-return-nodes-for-this
branch
from
September 8, 2026 14:36
ada9784 to
232b29e
Compare
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.
This PR implements the necessary library changes to support MaD summaries for functions such as vector::emplace_back or make_unique. These functions receive a list of arguments and then forwards them to a constructor call.
@hvitved had a super cool implementation idea. Given:
we model a call such as
v.emplace_back(42)as:v.emplace_back(42, &Foo)and give
emplace_backtwo summaries:Argument[0] -> Argument[1].Parameter[0]Argument[1].Parameter[this] -> Argument[this].ElementThe first summary states that
42goes into the 0'th parameter of theFooconstructor, and the second summary states that thethisparameter of the constructed object goes into thethisargument ofvwith anElementcontent.(A few lines I told in the above paragraph:
forwardin MaD. I'm happy to change this name to something else if anyone has any strong opinions about this.)In order to know which constructor to forward to we need to know what type is being constructed. For example:
To know which type is constructed we add a new extensible called
forwardsModelwith rows very much like what we have for MaD summaries. For example, I've added this as row as a test:["", "Container<T>", True, "emplace<Args>", "(Args &&)", "", "0", "T", "manual"]this says that a call to
Container<T>::emplace(args0, ..., argsN)forwards its arguments to a call toT(args0, ..., argsN). The0specifies an offset so we can support cases likev.emplace(v.begin(), 42)where we need to ignore the first argument.This PR doesn't actually add any non-test MaD summaries. I'll delay that to a future PR.