[PATCH] D111283: [clang] template / auto deduction deduces common sugar
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 12 12:02:05 PDT 2022
ychen added a comment.
In D111283#3783338 <https://reviews.llvm.org/D111283#3783338>, @mizvekov wrote:
> In D111283#3783250 <https://reviews.llvm.org/D111283#3783250>, @ychen wrote:
>
>> Hi @mizvekov , I noticed that deduction for partial ordering also inherits this new behavior. Do you think partial ordering could opt out of this, or is it better for partial ordering to deal with the new sugared types?
>
> I would expect partial ordering to be performed only using canonical types, that type sugar should make no difference there.
>
> Note that previous to this patch, we would already produce sugar on deduction, but the behavior with regards to deducing the same template parameter from multiple places was pretty badly behaved: We would just keep the sugar from the first deduction, and ignore any subsequent ones. That meant that the deduction order had an effect on the result. With this patch, deduction becomes order agnostic.
I see. I think it is definitely a good thing. I'm still learning what the expected AST should look like during the partial ordering.
> What kind of difference are you seeing?
For
template <typename...> struct A {};
template <class T>
bool foo(A<T>);
template <class T, class... Args>
bool foo(A<T, Args...>);
template <class Tuple> bool bar()
{
return foo(Tuple{});
}
`A<T>` is currently modeled as ElaboratedType. It was `TemplateSpecializationType` before. Reading comments for `ElaboratedType`, it looks like sugar type might not be needed here?
ElaboratedType 0xd79c8f0 'A<T>' sugar dependent
`-TemplateSpecializationType 0xd79c8b0 'A<T>' dependent A
`-TemplateArgument type 'T'
`-TemplateTypeParmType 0xd79c7f0 'T' dependent depth 0 index 0
`-TemplateTypeParm 0xd79c768 'T'
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111283/new/
https://reviews.llvm.org/D111283
More information about the cfe-commits
mailing list