[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 7 10:01:53 PDT 2021


mizvekov added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:250
         Context.hasSameType(X.getAsType(), Y.getAsType()))
       return X;
 
----------------
mizvekov wrote:
> rsmith wrote:
> > I wonder if we can come up with a good heuristic for determining which of `X` and `Y` we want to return here. One thing that immediately springs to mind is: if either type is canonical, we should return the other one.
> I was thinking about the opposite actually, something along the lines of returning the common sugar between them. Starting from the cannonical type and going 'backwards' (adding back the sugar), we return the type just before adding sugar back would make them different.
I have a proposal for what to do here in this patch: https://reviews.llvm.org/D111283

I think it's ready except that it needs more manual labor to support digging down into more types.

Anyway, this patch above refines the behavior of the present one, by implementing a criteria to fold the type sugar when deduction happens from multiple arguments,
or in the case of deducing from auto returning function, to fold them from the multiple return statements.

Otherwise, as in the present patch, the sugar is considered only from the first argument deduced from.

So any stakeholders, please subscribe and provide feedback about the rules as they are implemented :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110216/new/

https://reviews.llvm.org/D110216



More information about the cfe-commits mailing list