<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 22 December 2016 at 21:19, Chandler Carruth via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: chandlerc<br>
Date: Thu Dec 22 23:19:47 2016<br>
New Revision: 290417<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=290417&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=290417&view=rev</a><br>
Log:<br>
Add an assert to catch improperly constructed %diff sequences in<br>
diagnostics and fix one such diagnostic.<br>
<br>
Sadly, this assert doesn't catch this bug because we have no tests that<br>
emit this diagnostic! Doh! I'm following up on the commit that<br>
introduces it to get that fixed. Then this assert will help in a more<br>
direct way.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Basic/<wbr>Diagnostic.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290417&r1=290416&r2=290417&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/<wbr>DiagnosticSemaKinds.td?rev=<wbr>290417&r1=290416&r2=290417&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td Thu Dec 22 23:19:47 2016<br>
@@ -3346,7 +3346,7 @@ def note_ovl_candidate_<wbr>inconsistent_dedu<br>
def note_ovl_candidate_<wbr>inconsistent_deduction_types : Note<<br>
"candidate template ignored: deduced values %diff{"<br>
"of conflicting types for parameter %0 (%1 of type $ vs. %3 of type $)|"<br>
- "%1 and %3 of conflicting types for parameter %0|}2,4">;<br>
+ "%1 and %3 of conflicting types for parameter %0}2,4">;<br>
def note_ovl_candidate_explicit_<wbr>arg_mismatch_named : Note<<br>
"candidate template ignored: invalid explicitly-specified argument "<br>
"for template parameter %0">;<br>
<br>
Modified: cfe/trunk/lib/Basic/<wbr>Diagnostic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=290417&r1=290416&r2=290417&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Basic/<wbr>Diagnostic.cpp?rev=290417&r1=<wbr>290416&r2=290417&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Basic/<wbr>Diagnostic.cpp (original)<br>
+++ cfe/trunk/lib/Basic/<wbr>Diagnostic.cpp Thu Dec 22 23:19:47 2016<br>
@@ -742,7 +742,10 @@ FormatDiagnostic(const char *DiagStr, co<br>
// "%diff{compare $ to $|other text}1,2"<br>
// treat it as:<br>
// "compare %1 to %2"<br>
- const char *Pipe = ScanFormat(Argument, Argument + ArgumentLen, '|');<br>
+ const char *ArgumentEnd = Argument + ArgumentLen;<br>
+ const char *Pipe = ScanFormat(Argument, ArgumentEnd, '|');<br>
+ assert(ScanFormat(Pipe + 1, ArgumentEnd, '|') == ArgumentEnd &&<br>
+ "Found too many '|'s in a %diff modifier!");<br></blockquote><div><br></div><div>This is the fallback path for the case where the types being diffed turn out to not both be types after all; your assert is unreachable for properly-emitted diagnostics. Perhaps we should instead replace this whole block with an llvm_unreachable and fix any cases where we're passing non-types into a %diff...</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
const char *FirstDollar = ScanFormat(Argument, Pipe, '$');<br>
const char *SecondDollar = ScanFormat(FirstDollar + 1, Pipe, '$');<br>
const char ArgStr1[] = { '%', static_cast<char>('0' + ArgNo) };<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>