Add some examples of Fix-it hints to our documentation

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2009-04-01 16:24:40 +00:00
Родитель e9b7d8ace8
Коммит eff49c675c
1 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@ -200,8 +200,37 @@ void addHTTPService(servers::Server const &server, ::services::WebService const
<h2>Fix-it Hints</h2> <h2>Fix-it Hints</h2>
<p>simple example + template&lt;&gt; example</p> <p>"Fix-it" hints provide advice for fixing small, localized problems
in source code. When Clang produces a diagnostic about a particular
problem that it can work around (e.g., non-standard or redundant
syntax, missing keywords, common mistakes, etc.), it may also provide
specific guidance in the form of a code transformation to correct the
problem. For example, here Clang warns about the use of a GCC
extension that has been considered obsolete since 1993:</p>
<pre>
$ <b>clang t.c</b>
t.c:5:28: warning: use of GNU old-style field designator extension
<font color="darkgreen">struct point origin = { x: 0.0, y: 0.0 };</font>
<font color="red">~~</font> <font color="blue">^</font>
<font color="darkgreen">.x = </font>
t.c:5:36: warning: use of GNU old-style field designator extension
<font color="darkgreen">struct point origin = { x: 0.0, y: 0.0 };</font>
<font color="red">~~</font> <font color="blue">^</font>
<font color="darkgreen">.y = </font>
</pre>
<p>The underlined code should be removed, then replaced with the code below the caret line (".x =" or ".y =", respectively). "Fix-it" hints are most useful for working around common user errors and misconceptions. For example, C++ users commonly forget the syntax for explicit specialization of class templates, as in the following error:</p>
<pre>
$ <b>clang t.cpp</b>
t.cpp:9:3: error: template specialization requires 'template&lt;&gt;'
struct iterator_traits&lt;file_iterator&gt; {
<font color="blue">^</font>
<font color="darkgreen">template&lt;&gt; </font>
</pre>
<p>Again, after describing the problem, Clang provides the fix--add <code>template&lt;&gt;</code>--as part of the diagnostic.<p>
<h2>Automatic Macro Expansion</h2> <h2>Automatic Macro Expansion</h2>