[cfe-commits] [Patch] Add highlighting and type eliding when two templates are used in a diagnostics. Also, template tree printing.
John McCall
rjmccall at apple.com
Tue Jun 26 09:54:07 PDT 2012
On Jun 25, 2012, at 7:55 PM, Richard Smith wrote:
> On Mon, Jun 25, 2012 at 7:47 PM, Richard Trieu <rtrieu at google.com> wrote:
> On Mon, Jun 25, 2012 at 2:09 PM, Richard Trieu <rtrieu at google.com> wrote:
> On Sun, Jun 24, 2012 at 2:57 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> Thanks, LGTM.
>
>
> Incidentally, for this example:
>
>
> template<typename ...T> struct S {};
> template<typename T> using U = S<int, char, T>;
> template<typename T> using V = U<U<T>>;
> int f(S<int, char, U<const double>>);
> int k = f(V<double>());
>
> I get:
>
> <stdin>:4:5: note: candidate function not viable: no known conversion from 'S<[2
> * ...], struct S<int, char, double>>' to 'S<[2 * ...], U<const
> double>>' for 1st argument;
>
> where I would have preferred:
>
> <stdin>:4:5: note: candidate function not viable: no known conversion from 'S<[2
> * ...], S<[2 * ...], double>>' to 'S<[2 * ...], S<[2 * ...], const
> double>>' for 1st argument;
>
> Any idea what's going on there?
>
>
> Looking into it. It looks like Clang has 'struct S<int, char, double>' as a SubstTemplateTypeParmType instead of a TemplateSpecializationType, causing the template diffing to handle it as a type without going deeper.
>
> Fixed.
>
> > + static const TemplateSpecializationType * GetTemplateSpecializationType(
>
> Extra space after *.
>
> > + if (const SubstTemplateTypeParmType *STTPT =
> > + Ty->getAs<SubstTemplateTypeParmType>())
> > + Ty = STTPT->getReplacementType();
>
> Is this necessary? Since you next do this:
Not only is it unnecessary, but getAs<SugaredType>() is basically just an
expensive dyn_cast, because the canonical-type check will never succeed.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120626/e926253d/attachment.html>
More information about the cfe-commits
mailing list