• Home
  • Raw
  • Download

Lines Matching +full:clang +full:- +full:format +full:- +full:3

1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
5 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
6 <title>Clang - Expressive Diagnostics</title>
10 .loc { font-weight: bold; }
11 .err { color:red; font-weight: bold; }
12 .warn { color:magenta; font-weight: bold; }
13 .note { color:gray; font-weight: bold; }
14 .msg { font-weight: bold; }
15 .cmd { font-style: italic; }
17 .point { color:green; font-weight: bold; }
22 <!--#include virtual="menu.html.incl"-->
27 <!--=======================================================================-->
29 <!--=======================================================================-->
31 <p>In addition to being fast and functional, we aim to make Clang extremely user
32 friendly. As far as a command-line compiler goes, this basically boils down to
36 Clang output to GCC 4.9's output in some cases.
41 <p>First, all diagnostics produced by clang include full column number
42 information. The clang command-line compiler driver uses this information
44 (IDEs can use the information to display in-line error markup.)
54 $ <span class="cmd">gcc-4.9 -fsyntax-only -Wformat format-strings.c</span>
55 format-strings.c: In function 'void f()':
56format-strings.c:91:16: warning: field precision specifier '.*' expects a matching 'int' argument …
59 format-strings.c:91:16: warning: format '%d' expects a matching 'int' argument [-Wformat=]
60 $ <span class="cmd">clang -fsyntax-only format-strings.c</span>
61 …<span class="loc">format-strings.c:91:13:</span> <span class="warn">warning:</span> <span class="m…
66 <p>Note that modern versions of GCC have followed Clang's lead, and are
68 text in the result. However, Clang's column number is much more accurate,
69 pointing at the problematic format specifier, rather than the <tt>)</tt>
71 Also, Clang's diagnostic is colored by default, making it easier to
76 <p>Clang captures and accurately tracks range information for expressions,
80 understand what is wrong based on the Clang error. Because clang prints a
88 $ <span class="cmd">gcc-4.9 -fsyntax-only t.c</span>
93 $ <span class="cmd">clang -fsyntax-only t.c</span>
102 out of clang contain exactly the pertinent information about what is wrong and
115 $ <span class="cmd">gcc-4.9 -fsyntax-only t.c</span>
119 $ <span class="cmd">clang -fsyntax-only t.c</span>
127 <p>Many programmers use high-level user defined types, typedefs, and other
132 is going on. Clang aims to handle both cases well.<p>
138 $ <span class="cmd">clang -fsyntax-only t.c</span>
146 system "pid_t" typedef is defined, Clang helpfully displays it with "aka".</p>
149 $ <span class="cmd">clang -fsyntax-only t.c</span>
175 <p>and then compile it, we see that Clang is both providing accurate information and is retaining t…
178 $ <span class="cmd">clang -fsyntax-only t.cpp</span>
184 <p>Naturally, type preservation extends to uses of templates, and Clang retains information about h…
187 $ <span class="cmd">clang -fsyntax-only t.cpp</span>
193 <h2>Fix-it Hints</h2>
195 <p>"Fix-it" hints provide advice for fixing small, localized problems
196 in source code. When Clang produces a diagnostic about a particular
197 problem that it can work around (e.g., non-standard or redundant
200 problem. In the following example, Clang warns about the use of a GCC
206 $ <span class="cmd">clang t.c</span>
207 …:</span> <span class="warn">warning:</span> <span class="msg">use of GNU old-style field designato…
211 …:</span> <span class="warn">warning:</span> <span class="msg">use of GNU old-style field designato…
217 <p>"Fix-it" hints are most useful for
221 Clang provides the fix--add <code>template&lt;&gt;</code>--as part of the
225 $ <span class="cmd">clang t.cpp</span>
226 …<span class="loc">t.cpp:9:3:</span> <span class="err">error:</span> <span class="msg">template spe…
235 error message. Instead of just printing out the type name, Clang has enough
242 …ap&lt;[...], <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;[...], <s…
244 -fno-elide-type: template diff without elision
246 …t;map&lt;int, <span class="template-highlight">float</span>&gt;&gt;' to 'vector&lt;map&lt;int, <sp…
248 -fdiagnostics-show-template-tree: template tree printing with elision
254 …[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&…
256 -fdiagnostics-show-template-tree -fno-elide-type: template tree printing with no elision
262 …[<span class="template-highlight">float</span> != <span class="template-highlight">double</span>]&…
270 Clang helps you out by automatically printing instantiation information and
275 $ <span class="cmd">clang -fsyntax-only t.c</span>
276 …<span class="loc">t.c:80:3:</span> <span class="err">error:</span> <span class="msg">invalid opera…
288 $ <span class="cmd">clang -fsyntax-only t.c</span>
293 <span class="snip">#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */</span>
300 <p>In practice, we've found that Clang's treatment of macros is actually more useful in multiply ne…
317 $ <span class="cmd">gcc-4.9 t.cc</span>
321 $ <span class="cmd">clang t.cc</span>
322 …<span class="loc">t.cc:3:12:</span> <span class="err">error:</span> <span class="msg">expected ';'…
341 $ <span class="cmd">gcc-4.9 t.cc</span>
349 t.cc:6:8: error: expected primary-expression before '>' token
352 $ <span class="cmd">clang t.cc</span>