<div>On Mon Jan 06 2014 at 10:06:25 AM, Alp Toker <<a href="mailto:alp@nuanti.com">alp@nuanti.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 06/01/2014 17:34, Jordan Rose wrote:<br>
> This changes the message for templates in a way that is less informative.<br>
<br>
No change in output. Do you mean the string in the TableGen file is now<br>
less informative?<br>
<br>
> In other cases where we use tokens as diagnostic arguments, the message makes sense whether or not the token text is quoted. Here, that's not true: the problem isn't about the literal word "template" but about a particular template (like "vector"). Using tok::annot_template_id as if it were a real token seems wrong<br>

<br>
That was the reason I changed the "magic token kind" in use from<br>
tok::kw_template to tok::annot_template_id. tok::kw_template relates to<br>
"template" whereas tok::annot_template_id is a synonym for "template<br>
name" so this appears a better choice to use as the placeholder.<br></blockquote><div><br></div><div>It's a synonym for 'template id' (a template name followed by template arguments), not for 'template name'. Using it here is inappropriate.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The thought experiment here is that<br>
ExpectAndConsume(tok::annot_<u></u>template_id) would emit the correct<br>
diagnostic message, which it hopefully does at this point (other than<br>
that it would assert right now due to the special token check).<br>
<br>
> , particularly because the comment says it's intended for use with function template names.<br>
<br>
That's an interesting point but I didn't quite understand. Can you<br>
explain a bit further?<br>
<br>
><br>
> I'd rather have two variants for this diagnostic, or use an enum specifically marked as "keep in sync with this diagnostic" (slightly better than 0-1-2-3-4). Is there a reason you specifically wanted to change this one?<br>

<br>
Chose this diagnostic to demonstrate the new diagnostic printing<br>
facility introduced in the previous commit. It looked like a good<br>
candidate to upgrade first because of the odd use of tok::kw_template.<br>
<br>
The idea with the ongoing diagnostic effort is to make the messages more<br>
consistent, clearly written and easy to maintain so if it's missing the<br>
mark we should deal with that.<br>
<br>
Alp.<br>
<br>
<br>
><br>
> Jordan<br>
><br>
><br>
><br>
> On Jan 6, 2014, at 4:54 , Alp Toker <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>> wrote:<br>
><br>
>> Author: alp<br>
>> Date: Mon Jan  6 06:54:32 2014<br>
>> New Revision: 198605<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198605&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=198605&view=rev</a><br>
>> Log:<br>
>> Don't use magic constants in the digraph diagnostic<br>
>><br>
>> Modified:<br>
>>     cfe/trunk/include/clang/Basic/<u></u>DiagnosticParseKinds.td<br>
>>     cfe/trunk/lib/Parse/<u></u>ParseExprCXX.cpp<br>
>><br>
>> Modified: cfe/trunk/include/clang/Basic/<u></u>DiagnosticParseKinds.td<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=198605&r1=198604&r2=198605&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/include/<u></u>clang/Basic/<u></u>DiagnosticParseKinds.td?rev=<u></u>198605&r1=198604&r2=198605&<u></u>view=diff</a><br>

>> ==============================<u></u>==============================<u></u>==================<br>
>> --- cfe/trunk/include/clang/Basic/<u></u>DiagnosticParseKinds.td (original)<br>
>> +++ cfe/trunk/include/clang/Basic/<u></u>DiagnosticParseKinds.td Mon Jan  6 06:54:32 2014<br>
>> @@ -641,9 +641,7 @@ def err_ctor_init_missing_comma : Error<<br>
>> def err_friend_decl_defines_type : Error<<br>
>>    "cannot define a type in a friend declaration">;<br>
>> def err_missing_whitespace_digraph : Error<<br>
>> -  "found '<::' after a "<br>
>> -  "%select{template name|const_cast|dynamic_cast|<u></u>reinterpret_cast|static_cast}<u></u>0"<br>
>> -  " which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?">;<br>
>> +  "found '<::' after a %0 which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?">;<br>
>><br>
>> def ext_deleted_function : ExtWarn<<br>
>>    "deleted function definitions are a C++11 extension">, InGroup<CXX11>;<br>
>><br>
>> Modified: cfe/trunk/lib/Parse/<u></u>ParseExprCXX.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=198605&r1=198604&r2=198605&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/lib/Parse/<u></u>ParseExprCXX.cpp?rev=198605&<u></u>r1=198604&r2=198605&view=diff</a><br>

>> ==============================<u></u>==============================<u></u>==================<br>
>> --- cfe/trunk/lib/Parse/<u></u>ParseExprCXX.cpp (original)<br>
>> +++ cfe/trunk/lib/Parse/<u></u>ParseExprCXX.cpp Mon Jan  6 06:54:32 2014<br>
>> @@ -24,18 +24,6 @@<br>
>><br>
>> using namespace clang;<br>
>><br>
>> -static int SelectDigraphErrorMessage(tok:<u></u>:TokenKind Kind) {<br>
>> -  switch (Kind) {<br>
>> -    case tok::kw_template:         return 0;<br>
>> -    case tok::kw_const_cast:       return 1;<br>
>> -    case tok::kw_dynamic_cast:     return 2;<br>
>> -    case tok::kw_reinterpret_cast: return 3;<br>
>> -    case tok::kw_static_cast:      return 4;<br>
>> -    default:<br>
>> -      llvm_unreachable("Unknown type for digraph error message.");<br>
>> -  }<br>
>> -}<br>
>> -<br>
>> // Are the two tokens adjacent in the same source file?<br>
>> bool Parser::areTokensAdjacent(<u></u>const Token &First, const Token &Second) {<br>
>>    SourceManager &SM = PP.getSourceManager();<br>
>> @@ -56,8 +44,7 @@ static void FixDigraph(Parser &P, Prepro<br>
>>    Range.setBegin(DigraphToken.<u></u>getLocation());<br>
>>    Range.setEnd(ColonToken.<u></u>getLocation());<br>
>>    P.Diag(DigraphToken.<u></u>getLocation(), diag::err_missing_whitespace_<u></u>digraph)<br>
>> -      << SelectDigraphErrorMessage(<u></u>Kind)<br>
>> -      << FixItHint::CreateReplacement(<u></u>Range, "< ::");<br>
>> +      << Kind << FixItHint::CreateReplacement(<u></u>Range, "< ::");<br>
>><br>
>>    // Update token information to reflect their change in token type.<br>
>>    ColonToken.setKind(tok::<u></u>coloncolon);<br>
>> @@ -93,8 +80,8 @@ void Parser::<u></u>CheckForTemplateAndDigraph(<br>
>>                                Template, MemberOfUnknownSpecialization)<u></u>)<br>
>>      return;<br>
>><br>
>> -  FixDigraph(*this, PP, Next, SecondToken, tok::kw_template,<br>
>> -             /*AtDigraph*/false);<br>
>> +  FixDigraph(*this, PP, Next, SecondToken, tok::annot_template_id,<br>
>> +             /*AtDigraph*/ false);<br>
>> }<br>
>><br>
>> /// \brief Emits an error for a left parentheses after a double colon.<br>
>><br>
>><br>
>> ______________________________<u></u>_________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
<br>
--<br>
<a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
the browser experts<br>
<br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote>