From: Chris Lattner
This section is generally an index into other sections. It does not go into
-depth on most. However, the first part introduces the language selection and
-other high level options like -c, -g, etc.
+depth on the ones that are covered by other sections. However, the first part
+introduces the language selection and other high level options like -c, -g, etc.
-Werror: Turn warnings into errors. -Werror=foo: Turn warning "foo" into an error. -Wno-error=foo: Turn warning "foo" into an warning even if -Werror is
+ specified. -Wfoo: Enable warning foo -Wno-foo: Disable warning foo -w: Disable all warnings. -pedantic: Warn on language extensions. -pedantic-errors: Error on language extensions. -Wsystem-headers: Enable warnings from system headers. Clang aims to produce beautiful diagnostics by default, particularly for new
+users that first come to Clang. However, different people have different
+preferences, and sometimes Clang is driven by another program, not a person. For
+these cases, Clang provides a wide range of options to control the exact output
+format of the diagnostics that it generates.
Options to Control Error and Warning Messages
+
+
+Formatting of Diagnostics
+
+
+
+
+
+
+ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ + // ++ +
When this is disabled, Clang will print "test.c:28: warning..." with no +column number.
+ + + ++ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ + // ++ +
When this is disabled, Clang will not print the "test.c:28:8: " part.
++ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ + // ++ +
When this is disabled, Clang will just print:
+ ++ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] ++ +
+ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ + // ++ +
Passing -fno-diagnostics-show-option will prevent Clang from printing +the [-Wextra-tokens] information in the +diagnostic. This information tells you the flag needed to enable or disable the +diagnostic, either from the command line or through #pragma GCC diagnostic.
+ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ + // ++ +
Passing -fno-diagnostics-fixit-info will prevent Clang from printing +the "//" line at the end of the message. This information is useful for users +who may not understand what is wrong, but can be confusing for machine +parsing.
++exprs.c:47:15:{47:8-47:14}{47:17-47:24}: error: invalid operands to binary expression ('int *' and '_Complex float') + P = (P-42) + Gamma*4; + ~~~~~~ ^ ~~~~~~~ ++ +
The {}'s are generated by -fprint-source-range-info.
+TODO: Generate this from tblgen. Define one anchor per warning group.
+ + ++ test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens] + #endif bad + ^ ++ +
These extra tokens are not strictly conforming, and are usually best handled +by commenting them out.
+ + +Clang provides a number of ways to control which code constructs cause it to +emit errors and warning messages. + +error and warning cases +