diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2025-07-21 16:55:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2025-07-24 07:44:49 +0000 |
commit | e5fcb8c32fbdf7208ab5e2b250bec6686141dfc7 (patch) | |
tree | ff0f067545bc913b25259eebb6f4fc6d5c8b2669 /share/man/man4/mlx.4 | |
parent | d9a1e54cb037706f53f12b488d8288b9f951b859 (diff) |
Merge commit 8ac140f39084 from llvm git (by Younan Zhang):stable/13
[Clang][NFCI] Cleanup the fix for default function argument substitution (#104911)
(This is one step towards tweaking `getTemplateInstantiationArgs()` as
discussed in https://github.com/llvm/llvm-project/pull/102922)
We don't always substitute into default arguments while transforming a
function parameter. In that case, we would preserve the uninstantiated
expression until after, e.g. building up a CXXDefaultArgExpr and
instantiate the expression there.
For member function instantiation, this algorithm used to cause a
problem in that the default argument of an out-of-line member function
specialization couldn't get properly instantiated. This is because, in
`getTemplateInstantiationArgs()`, we would give up visiting a function's
declaration context if the function is a specialization of a member
template. For example,
```cpp
template <class T>
struct S {
template <class U>
void f(T = sizeof(T));
};
template <> template <class U>
void S<int>::f(int) {}
```
The default argument `sizeof(U)` that lexically appears inside the
declaration would be copied to the function declaration in the class
template specialization `S<int>`, as well as to the function's
out-of-line definition. We use template arguments collected from the
out-of-line function definition when substituting into the default
arguments. We would therefore give up the traversal after the function,
resulting in a single-level template argument of the `f` itself. However
the default argument here could still reference the template parameters
of the primary template, hence the error.
In fact, this is similar to constraint checking in some respects: we
actually want the "whole" template arguments relative to the primary
template, not those relative to the function definition. So this patch
adds another flag to indicate `getTemplateInstantiationArgs()` for that.
This patch also consolidates the tests for default arguments and removes
some unnecessary tests.
This fixes a crash or assertion failure while building tests for the
devel/hpx port.
PR: 288352
MFC after: 3 days
(cherry picked from commit ffc5ee0f57d56459df93f4107b9835ae78a546b5)
Diffstat (limited to 'share/man/man4/mlx.4')
0 files changed, 0 insertions, 0 deletions