Update documentation with regards to template type diffing.

llvm-svn: 159249
This commit is contained in:
Richard Trieu 2012-06-27 02:00:20 +00:00
parent 46829f283b
commit e753f4bebd
5 changed files with 130 additions and 0 deletions

View File

@ -357,6 +357,11 @@ Clang:</p>
<tr><td>Example:</td><td><tt>"candidate found by name lookup is %q0"</tt></td></tr>
<tr><td>Class:</td><td>NamedDecl*</td></tr>
<tr><td>Description</td><td><p>This formatter indicates that the fully-qualified name of the declaration should be printed, e.g., "std::vector" rather than "vector".</p></td></tr>
<tr><td colspan="2"><b>"diff" format</b></td></tr>
<tr><td>Example:</td><td><tt>"no known conversion %diff{from | to | }1,2"</tt></td></tr>
<tr><td>Class:</td><td>QualType</td></tr>
<tr><td>Description</td><td><p>This formatter takes two QualTypes and attempts to print a template difference between the two. If tree printing is off, the entire text inside the the braces, with the formatted text replacing the pipes. If tree printing is on, the text is not printed and a type tree is printed after the diagnostic message.</p></td></tr>
</table>

View File

@ -121,6 +121,55 @@ int f(bool b) {
This functionality can be enabled or disabled separately from
<tt>-Wuninitialized</tt> with the <tt>-Wsometimes-uninitialized</tt> warning
flag.</li>
<li>Template type diffing improves the display of diagnostics with templated
types in them.
<pre>
int f(vector&lt;map&lt;int, double&gt;&gt;);
int x = f(vector&lt;map&lt;int, float&gt;&gt;());
</pre>
The error message is the same, but the note is different based on the options selected.
<pre>
<b>template-diff.cpp:5:9: <span class="error">error:</span> no matching function for call to 'f'</b>
int x = f(vector&lt;map&lt;int, float&gt;&gt;());
<span class="caret">^</span>
</pre>
Templated type diffing with type elision (default):
<pre>
<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;[...], <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
int f(vector&lt;map&lt;int, double&gt;&gt;);
<span class="caret">^</span>
</pre>
Templated type diffing without type elision (-fno-elide-type):
<pre>
<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion from 'vector&lt;map&lt;int, <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;int, <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
int f(vector&lt;map&lt;int, double&gt;&gt;);
<span class="caret">^</span>
</pre>
Templated tree printing with type elision (-fdiagnostics-show-template-tree):
<pre>
<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
vector&lt;
map&lt;
[...],
[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
int f(vector&lt;map&lt;int, double&gt;&gt;);
<span class="caret">^</span>
</pre>
Templated tree printing without type elision (-fdiagnostics-show-template-tree -fno-elide-type):
<pre>
<b>template-diff.cpp:4:5: <span class="note">note:</span></b> candidate function not viable: no known conversion for 1st argument;
vector&lt;
map&lt;
int,
[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
int f(vector&lt;map&lt;int, double&gt;&gt;);
<span class="caret">^</span>
</pre>
</li>
</ul>
<h4 id="tlsmodel">Support for <code>tls_model</code> attribute</h4>

View File

@ -417,6 +417,48 @@ quotes(as &quot;\&quot;&quot;) and non-printable characters (as octal
&quot;\xxx&quot;).</p>
</dd>
<dt id="opt_fno-elide-type">
<b>-fno-elide-type</b>:
Turns off elision in template type printing.</td>
<dd><p>The default for template type printing is to elide as many template
arguments as possible, removing those which are the same in both template types,
leaving only the differences. Adding this flag will print all the template
arguments. If supported by the terminal, highlighting will still appear on
differing arguments.</p>
Default:
<pre>
t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">float</span>, [...]&gt;&gt;&gt;' to 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">double</span>, [...]&gt;&gt;&gt;' for 1st argument;
</pre>
-fno-elide-type:
<pre>
t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;int, map&lt;<span class="template-highlight">float</span>, int&gt;&gt;&gt;' to 'vector&lt;map&lt;int, map&lt;<span class="template-highlight">double</span>, int&gt;&gt;&gt;' for 1st argument;
</pre>
</dd>
<dt id="opt_fdiagnostics-show-template-tree">
<b>-fdiagnostics-show-template-tree</b>:
Template type diffing prints a text tree.</td>
<dd><p>For diffing large templated types, this option will cause Clang to
display the templates as an indented text tree, one argument per line, with
differences marked inline. This is compatible with -fno-elide-type.</p>
Default:
<pre>
t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">float</span>, [...]&gt;&gt;&gt;' to 'vector&lt;map&lt;[...], map&lt;<span class="template-highlight">double</span>, [...]&gt;&gt;&gt;' for 1st argument;
</pre>
-fdiagnostics-show-template-tree
<pre>
t.cc:4:5: <span class="note">note</span>: candidate function not viable: no known conversion for 1st argument;
vector&lt;
map&lt;
[...],
map&lt;
[<span class="template-highlight">float</span> != <span class="template-highlight">float</span>],
[...]&gt;&gt;&gt;
</pre>
</dd>
</dl>

View File

@ -27,6 +27,7 @@ span.error { color:red }
span.warning { color:purple }
span.note { color:gray }
span.caret { color:green; font-weight:bold }
span.template-highlight { color:cyan }
/* Tables */
tr { vertical-align:top }

View File

@ -263,6 +263,39 @@ diagnostic.<p>
<span class="snip">template&lt;&gt; </span>
</pre>
<h2>Template Type Diffing</h2>
<p>Templates types can be long and difficult to read. Moreso when part of an
error message. Instead of just printing out the type name, Clang has enough
information to remove the common elements and highlight the differences. To
show the template structure more clearly, the templated type can also be
printed as an indented text tree.</p>
Default: template diff with type elision
<pre>
t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion from 'vector&lt;map&lt;[...], <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;[...], <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
</pre>
-fno-elide-type: template diff without elision
<pre>
t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion from 'vector&lt;map&lt;int, <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;int, <span class="template-highlight">double</span>&gt;&gt;' for 1st argument;
</pre>
-fdiagnostics-show-template-tree: template tree printing with elision
<pre>
t.cc:4:5: <span class="note">note:</span> candidate function not viable: no known conversion for 1st argument;
vector&lt;
map&lt;
[...],
[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
</pre>
-fdiagnostics-show-template-tree -fno-elide-type: template tree printing with no elision
<pre>
t.cc:4:5: <span class="note">note:M</span> candidate function not viable: no known conversion for 1st argument;
vector&lt;
map&lt;
int,
[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&gt;&gt;
</pre>
<h2>Automatic Macro Expansion</h2>
<p>Many errors happen in macros that are sometimes deeply nested. With