[cfe-dev] -fdiagnostics-format= I have a quesiton about -fshow-column
Douglas Gregor
dgregor at apple.com
Sat May 21 10:14:46 PDT 2011
On May 20, 2011, at 9:25 AM, Andrew Fish wrote:
> I updated the -fdiagnostics-format implementation based on the feedback, and added a test case. When adding support for columns for msvc I ran into the issue that -fshow-column was not supported, as implied by the documentation, so I had to also fix that in the patch. I added -fshow-column to the test case, since it was obviously missing.
>
> The default behavior for -fms-extensions folks is the same as before.
>
> -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 default for this option is clang. If ifms-extensions is set then the default is changed to msvc and -fno-show-column is also set.
> For example, a format string warning will produce these three renditions based on the setting of this option, the fourth rendition shows default output when -fms-extensions is set:
>
> t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
> t.c(3,11) : warning: conversion specifies type 'char *' but the argument has type 'int'
> t.c +3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
> t.c(3) : warning: conversion specifies type 'char *' but the argument has type 'int'
>
>
> In this code from ParseDiagnosticArgs():
>
> if (Args.hasArg(OPT_fms_extensions)) {
> Opts.Format = DiagnosticOptions::Msvc;
> Opts.ShowColumn = Args.hasArg(OPT_fshow_column);
> } else
> Opts.Format = DiagnosticOptions::Clang;
>
> The call to Args.hasArg(OPT_fshow_column) always seems to return 0? Does this mean I did not add -fshow-column correctly?
hasFlag() is far better than hasArg() for what you're doing, since it handles both the positive (-fshow-column) and negative (-fno-show-column) arguments in one command. For example, I switched the ShowColumn computation to this:
Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,
OPT_fno_show_column,
/*Default=*/true);
I committed a slightly-tweaked version of your patch as Clang r131794, where I also got rid of the dependence on -fms-extensions. Thanks so much for working on this!
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110521/00912b6a/attachment.html>
More information about the cfe-dev
mailing list