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.
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?
This works as expected:
/Users/fish/work/Clang2/build/Release/bin/clang -fsyntax-only -ccc-host-triple x86_64-pc-win32 diag-format.c
diag-format.c(28) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif bad // extension!
^
//
1 warning generated.
This works:
/Users/fish/work/Clang2/build/Release/bin/clang -fsyntax-only -fdiagnostics-format=msvc -ccc-host-triple x86_64-pc-win32 diag-format.c
diag-format.c(28,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif bad // extension!
^
//
1 warning generated.
This one does not:
/Users/fish/work/Clang2/build/Release/bin/clang -fsyntax-only -ccc-host-triple x86_64-pc-win32 -fshow-column diag-format.c
diag-format.c(28) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
#endif bad // extension!
^
//
1 warning generated.
So what am I missing?
Andrew Fish
fdiagnostics-formant.patch (10.2 KB)