<div dir="ltr"><div>This is where we get the Integral type from the TemplateArgument - <a href="https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/TemplateBase.cpp#L55" target="_blank">https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/TemplateBase.cpp#L55</a>. </div><div><br></div><div>I tried - </div><div><font face="monospace">bool flag = false;</font></div><div><font face="monospace">if (auto *autoT = T->getAs<AutoType>()) {</font></div><div><font face="monospace"> flag = true;</font></div><div><font face="monospace">}</font></div><div><br></div><div>But <font face="monospace">flag</font> is not <font face="monospace">true</font> for the example - </div><div><div><font face="monospace">template<auto N> struct S {};</font></div><div><font face="monospace">template<> struct S<1> { using type = int };</font></div><div><font face="monospace">S<1L>::type t;</font></div></div><div><br></div><div>Am I making a mistake in getting the AutoType?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 22 Jul 2020 at 20:23, David Rector <<a href="mailto:davrecthreads@gmail.com" target="_blank">davrecthreads@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>The issue may be that the proper sugar isn’t being stored in the integral type when the TemplateArgument is created, so that there is no way to distinguish a non-deduced BuiltInType from a deduced one.<div><div><br></div><div>The type of the NonTypeTemplateParmDecl N in </div><div><span style="font-family:Menlo;font-size:x-small"><br></span></div><div><span style="font-family:Menlo;font-size:x-small">template<</span><span style="font-family:Menlo;font-size:x-small">auto </span><span style="font-family:Menlo;font-size:x-small">N> </span><span style="font-family:Menlo;font-size:x-small">struct </span><span style="font-family:Menlo;font-size:x-small">S {}` </span>is an AutoType — so far so good.</div><div><div><br></div><div>But the type of the integral TemplateArgument '1' in S<1>, though, seems to be a BuiltInType — no sugar atop it, nothing to distinguish it from the situation where N had a BuiltInType instead of an AutoType.  </div><div><br></div><div>If I understand DeducedTypes correctly, when they are substituted, they should remain as sugar atop the substitution (someone correct me if I’m wrong), and that does not seem to happen here.</div><div><br></div><div>If others agree this is the issue, I would imagine you will have to dig around to figure out where the template argument is being created, and wrap the integral’s type in an AutoType.  Then testing if getAs<DeducedType>() before testing getAs<BuiltInType>() should tell you when your BuiltInType was deduced.  </div><div><br></div><div>That’s my last best guess anyway.  Good luck,</div><div><br></div><div>Dave</div><div><br><blockquote type="cite"><div>On Jul 22, 2020, at 3:53 AM, Pratyush Das <<a href="mailto:reikdas@gmail.com" target="_blank">reikdas@gmail.com</a>> wrote:</div><br><div><div dir="ltr">That change does not work :( <div><br></div><div>Thanks though! </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 21 Jul 2020 at 23:30, David Rector <<a href="mailto:davrecthreads@gmail.com" target="_blank">davrecthreads@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><font face="Menlo, Consolas, Monaco, monospace"><span style="background-color:rgba(151,234,151,0.6)"><br></span></font><div>I would try replacing</div><br><font face="Menlo" size="1"> else if (auto *DT = T->getContainedDeducedType())</font><br><br>with<br><br><font face="Menlo" size="1">  else if (auto *DT = T->getAs<DeducedType>())</font></div><div><br></div><div>I think that is what you want anyway, since getContainedDeducedType seems to look not only through type sugar but through pointee types, array element types, etc.</div><div><br></div><div>To be sure, your example still should have worked using getContainedDeducedType but I think GetContainedDeducedTypeVisitor may have a problem in its implementation: it doesn’t handle all the possible sugar types.   In this case, you probably have a SubstTemplateTypeParmType, and I don’t see a VisitSubstTemplateTypeParmType implementation in there anywhere, so it is probably returning nullptr instead of desugaring and continuing to search.  That’s my best guess anyway from my perusal.</div><div><br></div><div>If this change works, it is probably another reason to replace stuff like GetContainedDeducedTypeVisitor with a more advanced getAs<T>(), with an extra template param that would allow you to look through e.g. pointee types, element types, function return types etc. when desired.</div><div><div><br></div><div>If that doesn’t work though, disregard.  Good luck,</div><div><br></div><div>Dave</div><div><br><blockquote type="cite"><div>On Jul 21, 2020, at 9:06 AM, Pratyush Das via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr">Hi, <div><br></div><div>I am a little stuck with <a href="https://reviews.llvm.org/D77598" target="_blank">https://reviews.llvm.org/D77598</a> and would really appreciate any help.</div><div><br></div><div>I am trying to get the proper suffixes in the error messages for the following two examples - <br></div><div><br></div><div><font face="monospace">template<auto N> struct S {};</font></div><div><font face="monospace">template<> struct S<1> { using type = int };</font></div><div><font face="monospace">S<1L>::type t;</font></div><div><br></div><div>which should give the error message with a suffix - </div><div><font face="monospace">error: no type named 'type' in 'S<1L>'; did you mean 'S<1>::type'?</font></div><div><br></div><div>and</div><div><br></div><div><font face="monospace">template <unsigned long long N> struct enable_if_unsigned_long_long {};<br>template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; <br>void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } </font><br></div><div><br></div><div>which should give no suffix in the error message - </div><div><font face="monospace">error: no type named 'type' in 'enable_if_unsigned_int<2>'; did you mean 'enable_if_unsigned_int<1>::type'?</font><br></div><div><br></div><div>I am trying to find the correct combination that would enable suffix in the first case, but not in the second case. I have been tinkering with checks for DeducedType and DependentType, but always either the suffixes are disabled for both the cases, or enabled for both the cases. </div><div><br></div><div>Can anyone please provide any insight on how to proceed?</div><div><br clear="all"><div>Thanks!</div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>Pratyush Das(Reik)<br></div></div></div></div></div></div></div>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>Pratyush Das(Reik)<br></div></div></div></div></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div>Pratyush Das(Reik)<br></div></div></div></div></div>