[PATCH] D91488: Consider reference, pointer, and pointer-to-membber TemplateArguments to be different if they have different types.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 15 15:11:34 PST 2020
rsmith added inline comments.
================
Comment at: clang/lib/AST/ItaniumMangle.cpp:4861
+ // We need correct types when the template-name is unresolved or when it
+ // might be overloaded.
+ if (!ResolvedTemplate)
----------------
Quuxplusone wrote:
> And from the PR summary:
>
> > namely mangling such template arguments as being cast to the parameter type in the case where the template name is unresolved or overloaded
>
> This phrasing worries me a little bit. Are you saying that you might mangle the name of `foo<SomeT>` in one way, when there's also a `foo<Some, Other, Args>` in scope, and in a different way, when there's not? That doesn't seem conforming. So I imagine it's more likely that I'm misunderstanding what you mean by "might be overloaded" / "is overloaded". Could you explain for my information, and perhaps also adjust the wording of these code comments to make the explanation less needed?
>
> Specifically, I think it would be non-conforming if the TU
>
> // https://godbolt.org/z/YjPqMd
> template<char *> void foo();
> char arr[6];
> extern template void foo<arr>(); // #1
> int main() { foo<arr>(); }
>
> could not be linked against the TU
>
> template<int> int foo();
> template<char *> void foo(); // is this "overloading"?
> extern char arr[6];
> template<> void foo<arr>() {} // #2
>
> because lines #1 and #2 disagreed about the way to mangle `foo<arr>`. (Again, I'm pretty sure you haven't made them disagree... but I remain unclear on what's meant by "overloading" in this PR, if it's //not// this.)
Well, technically, a single function template is considered overloaded all by itself :) ... but no, this is a typo in the change description. I meant "overloadable", not "overloaded". The proposed Itanium ABI rule applies to function templates (other than the call operator or conversion function of a generic lambda).
The "might be overloaded" here means "might be overloaded by some other (earlier or later or in a different TU) declaration", so I don't think that's wrong, but I'll rephrase it for the avoidance of any doubt.
(In principle the ABI rule also applies to cases where the template-name is unresolved, but it only makes a difference if the type of the template parameter is known and the template argument is not (eg, if it's the argument of a template template parameter). I suspect that's actually impossible, because the expression or type would need to be instantiation-dependent in that case, so we'd mangle the original syntax for the template argument not the result of converting it to the parameter type.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91488/new/
https://reviews.llvm.org/D91488
More information about the cfe-commits
mailing list