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

Ted Kremenek kremenek at apple.com
Wed May 18 12:41:12 PDT 2011


I agree; if this is the only difference, then a new DiagnosticClient is overkill.

On May 18, 2011, at 12:33 PM, Andrew Fish wrote:

> On May 18, 2011, at 11:24 AM, Ted Kremenek wrote:
> 
>> Hi Andrew, Doug,
>> 
>> I'm wondering if support for Microsoft-style diagnostics should be implemented as a new DiagnosticClient (e.g., MSVCTextDiagnosticPrinter).  I'm not certain what the plan was, but putting this all into TextDiagnosticPrinter seems a little gross to me.  With a separate DiagnosticClient, we might not need extra bits in DiagnosticOptions.
> 
> I'm working on a patch to implement -fdiagnostic-format=xxx per Doug's suggestion, and will post the patch to mailing list for review shortly. 
> 
> I implemented for msvc and vi variants, here are the changes in TextDiagnosticPrinter.cpp for TextDiagnosticPrinter::HandleDiagnostic()
> 
>          if (DiagOpts->Format == 1) 
>           // msvc parsable format
>           OS << PLoc.getFilename() << '(' << LineNo << ") : ";
>         else if (DiagOpts->Format == 2) 
>           // vi command line format
>           OS << PLoc.getFilename() << " +" << LineNo << ':';
>         else 
>           // clang format
>           OS << PLoc.getFilename() << ':' << LineNo << ':';
>         if (DiagOpts->ShowColumn)
>           if (unsigned ColNo = PLoc.getColumn())
>             OS << ColNo << ':';
> 
> Where the original code was:
> 
>         // Emit a Visual Studio compatible line number syntax.
>         if (LangOpts && LangOpts->Microsoft) {
>           OS << PLoc.getFilename() << '(' << LineNo << ')';
>           OS << " : ";
>         } else {
>           OS << PLoc.getFilename() << ':' << LineNo << ':';
>           if (DiagOpts->ShowColumn)
>             if (unsigned ColNo = PLoc.getColumn())
>               OS << ColNo << ':';
>         }
> 
> 
> Seems like a bit of overkill to implement a new DiagnosticClient for one line of code? Maybe some method for abstracting filename, line number, and column printing would be better? Then again my brain thinks in C and not C++.
> 
> Thanks,
> 
> Andrew

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110518/9877486d/attachment.html>


More information about the cfe-dev mailing list