`
.. option:: -pedantic
Warn on language extensions.
.. option:: -pedantic-errors
Error on language extensions.
.. option:: -Wsystem-headers
Enable warnings from system headers.
.. option:: -ferror-limit=123
Stop emitting diagnostics after 123 errors have been produced. The default is
20, and the error limit can be disabled with `-ferror-limit=0`.
.. option:: -ftemplate-backtrace-limit=123
Only emit up to 123 template instantiation notes within the template
instantiation backtrace for a single warning or error. The default is 10, and
the limit can be disabled with `-ftemplate-backtrace-limit=0`.
.. _cl_diag_formatting:
Formatting of Diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^
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 not by a human,
but by a program that wants consistent and easily parsable output. For
these cases, Clang provides a wide range of options to control the exact
output format of the diagnostics that it generates.
.. _opt_fshow-column:
**-f[no-]show-column**
Print column number in diagnostic.
This option, which defaults to on, controls whether or not Clang
prints the column number of a diagnostic. For example, when this is
enabled, Clang will print something like:
::
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.
The printed column numbers count bytes from the beginning of the
line; take care if your source contains multibyte characters.
.. _opt_fshow-source-location:
**-f[no-]show-source-location**
Print source file/line/column information in diagnostic.
This option, which defaults to on, controls whether or not Clang
prints the filename, line number and column number of a diagnostic.
For example, when this is enabled, Clang will print something like:
::
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.
.. _opt_fcaret-diagnostics:
**-f[no-]caret-diagnostics**
Print source line and ranges from source code in diagnostic.
This option, which defaults to on, controls whether or not Clang
prints the source line, source ranges, and caret when emitting a
diagnostic. For example, when this is enabled, Clang will print
something like:
::
test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif bad
^
//
**-f[no-]color-diagnostics**
This option, which defaults to on when a color-capable terminal is
detected, controls whether or not Clang prints diagnostics in color.
When this option is enabled, Clang will use colors to highlight
specific parts of the diagnostic, e.g.,
.. nasty hack to not lose our dignity
.. raw:: html
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:2:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif bad
^
//
**-fansi-escape-codes**
Controls whether ANSI escape codes are used instead of the Windows Console
API to output colored diagnostics. This option is only used on Windows and
defaults to off.
.. option:: -fdiagnostics-format=clang/msvc/vi
Changes diagnostic output format to better match IDEs and command line tools.
This option controls the output format of the filename, line number,
and column printed in diagnostic messages. The options, and their
affect on formatting a simple conversion diagnostic, follow:
**clang** (default)
::
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
**msvc**
::
t.c(3,11) : warning: conversion specifies type 'char *' but the argument has type 'int'
**vi**
::
t.c +3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
.. _opt_fdiagnostics-show-option:
**-f[no-]diagnostics-show-option**
Enable ``[-Woption]`` information in diagnostic line.
This option, which defaults to on, controls whether or not Clang
prints the associated :ref:`warning group `
option name when outputting a warning diagnostic. For example, in
this output:
::
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 [:ref:`-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
:ref:`#pragma GCC diagnostic `.
.. _opt_fdiagnostics-show-category:
.. option:: -fdiagnostics-show-category=none/id/name
Enable printing category information in diagnostic line.
This option, which defaults to "none", controls whether or not Clang
prints the category associated with a diagnostic when emitting it.
Each diagnostic may or many not have an associated category, if it
has one, it is listed in the diagnostic categorization field of the
diagnostic line (in the []'s).
For example, a format string warning will produce these three
renditions based on the setting of this option:
::
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String]
This category can be used by clients that want to group diagnostics
by category, so it should be a high level category. We want dozens
of these, not hundreds or thousands of them.
.. _opt_fdiagnostics-show-hotness:
**-f[no-]diagnostics-show-hotness**
Enable profile hotness information in diagnostic line.
This option, which defaults to off, controls whether Clang prints the
profile hotness associated with a diagnostics in the presence of
profile-guided optimization information. This is currently supported with
optimization remarks (see :ref:`Options to Emit Optimization Reports
`). The hotness information allows users to focus on the hot
optimization remarks that are likely to be more relevant for run-time
performance.
For example, in this output, the block containing the callsite of `foo` was
executed 3000 times according to the profile data:
::
s.c:7:10: remark: foo inlined into bar (hotness: 3000) [-Rpass-analysis=inline]
sum += foo(x, x - 2);
^
.. _opt_fdiagnostics-fixit-info:
**-f[no-]diagnostics-fixit-info**
Enable "FixIt" information in the diagnostics output.
This option, which defaults to on, controls whether or not Clang
prints the information on how to fix a specific diagnostic
underneath it when it knows. For example, in this output:
::
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.
.. _opt_fdiagnostics-print-source-range-info:
**-fdiagnostics-print-source-range-info**
Print machine parsable information about source ranges.
This option makes Clang print information about source ranges in a machine
parsable format after the file/line/column number information. The
information is a simple sequence of brace enclosed ranges, where each range
lists the start and end line/column locations. For example, in this output:
::
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 -fdiagnostics-print-source-range-info.
The printed column numbers count bytes from the beginning of the
line; take care if your source contains multibyte characters.
.. option:: -fdiagnostics-parseable-fixits
Print Fix-Its in a machine parseable form.
This option makes Clang print available Fix-Its in a machine
parseable format at the end of diagnostics. The following example
illustrates the format:
::
fix-it:"t.cpp":{7:25-7:29}:"Gamma"
The range printed is a half-open range, so in this example the
characters at column 25 up to but not including column 29 on line 7
in t.cpp should be replaced with the string "Gamma". Either the
range or the replacement string may be empty (representing strict
insertions and strict erasures, respectively). Both the file name
and the insertion string escape backslash (as "\\\\"), tabs (as
"\\t"), newlines (as "\\n"), double quotes(as "\\"") and
non-printable characters (as octal "\\xxx").
The printed column numbers count bytes from the beginning of the
line; take care if your source contains multibyte characters.
.. option:: -fno-elide-type
Turns off elision in template type printing.
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.
Default:
::
t.cc:4:5: note: candidate function not viable: no known conversion from 'vector