<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>On May 18, 2011, at 11:24 AM, Ted Kremenek wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Andrew, Doug,<div><br></div><div>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.</div></div></blockquote></div><br></div><div><div>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. </div><div><br></div><div>I implemented for msvc and vi variants, here are the changes in TextDiagnosticPrinter.cpp for TextDiagnosticPrinter::HandleDiagnostic()</div><div><br></div><div><div><div><div> <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">        </span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #b50da1">if</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "> (DiagOpts->Format == </span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #3a00d6">1</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">) </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(20, 135, 11); "><span style="color: #000000">          </span>// msvc parsable format</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">          OS << PLoc.getFilename() << <span style="color: #3a00d6">'('</span> << LineNo << <span style="color: #c92524">") : "</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">        <span style="color: #b50da1">else</span> <span style="color: #b50da1">if</span> (DiagOpts->Format == <span style="color: #3a00d6">2</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(20, 135, 11); "><span style="color: #000000">          </span>// vi command line format</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">          OS << PLoc.getFilename() << <span style="color: #c92524">" +"</span> << LineNo << <span style="color: #3a00d6">':'</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">        <span style="color: #b50da1">else</span> </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(20, 135, 11); "><span style="color: #000000">          </span>// clang format</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">          OS << PLoc.getFilename() << <span style="color: #3a00d6">':'</span> << LineNo << <span style="color: #3a00d6">':'</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">        <span style="color: #b50da1">if</span> (DiagOpts->ShowColumn)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">          <span style="color: #b50da1">if</span> (<span style="color: #b50da1">unsigned</span> ColNo = PLoc.getColumn())</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">            OS << ColNo << <span style="color: #3a00d6">':'</span>;</div></div></div></div><div><br></div><div>Where the original code was:</div><div><br></div><div><div>        // Emit a Visual Studio compatible line number syntax.</div><div>        if (LangOpts && LangOpts->Microsoft) {</div><div>          OS << PLoc.getFilename() << '(' << LineNo << ')';</div><div>          OS << " : ";</div><div>        } else {</div><div>          OS << PLoc.getFilename() << ':' << LineNo << ':';</div><div>          if (DiagOpts->ShowColumn)</div><div>            if (unsigned ColNo = PLoc.getColumn())</div><div>              OS << ColNo << ':';</div><div>        }</div></div><div><br></div><div><br></div></div><div>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++.</div><div><br></div><div>Thanks,</div><div><br></div><div>Andrew</div></body></html>