[cfe-dev] Need help designing a new diagnostic formatting command line option for use with x86_64-pc-win32

Andrew Fish afish at apple.com
Wed May 18 00:03:22 PDT 2011


For EFI firmware we use x86_64-pc-win32-darwin, but the default behavior for diagnostics on this triple is to suppress column number printing, and format line numbers to be compatible with Visual Studio. This breaks our Xcode IDE, and command line yank put. Attached is my first take at a patch to fix this. IMHO the default diagnostic output for clang, should be clangs native diagnostic output that matches the documentation. I understand the need to modify the output to match the IDE that is being used, as I'm fixing that reverse problem. It would seem OK to add a flag, like -fno-diagnostic-standard-format, when clang is being used with an incompatible IDE.  


-f[no-]diagnostics-standard-format: Print diagnostics in standard clang format, or a non standard OS specific format.
This option, which defaults to on, controls whether or not Clang uses the default diagnostic output format, or use an OS specific diagnostic format. For example, when this is disabled for the x86_64-pc-win32 triple, Clang will modify diagnostic output something like:
  test.c(2): error: unknown type name 'asdkjf' 
  asdkjf
  ^
Note: This changes the default behavior today so it would look like this (normal clang):

clang -ccc-host-triple x86_64-pc-win32  ve.c  -S 
ve.c:2:1: error: unknown type name 'asdkjf'
asdkjf  
^

To get the old behavior you need to add the new flag:

clang -ccc-host-triple x86_64-pc-win32  ve.c  -S -fno-diagnostics-standard-format
ve.c(2) :  error: unknown type name 'asdkjf'
asdkjf  
^


If I was doing this from scratch I would probably add a flag per IDE that was not compatible with the clang diagnostics format that would modify the clang diagnostic output to be compatible for that IDE. So something like  -fdiagnostics-ide=VisualStudio or -fdiagnostics-vi. I picked --fno-diagnostic-standard-format to better match what the currently code was doing:

 if (LangOpts && LangOpts->Microsoft) {

Given I'm a novice at clang, llvm, and C++ I figured changing as little as possible was a good plan. 

Andrew Fish

Patch to svn r131522.




PS -fdiagnostics-ide=vi looks like:
ve.c: +2: error: unknown type name 'asdkjf'
asdkjf  
^

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110518/05809517/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fno_diagnostic_standard_format.patch
Type: application/octet-stream
Size: 4721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110518/05809517/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110518/05809517/attachment-0001.html>


More information about the cfe-dev mailing list