<div dir="ltr"><div><div><div>Hi Ogzu,<br><br></div>It is customary, when replying to a mailing list reply, to "reply all" (or at the very least include the mailing list as well as the person that replied to you), so that other people a) can see any further discussion (it helps others) and b) perhaps reply if they feel like (either to help out or to correct something that went wrong).<br><br></div>Basically you need to use the clang::Diagnostic and related functionality. Depending on what you actually want to have your string output do, you may want to derive a class from clang::DiagnosticConsumer, and implement (at least) the HandleDiagnostic function in that derived class - there are some "already prepared" classes, such as TextDiagnosticBuffer that may well do what you want (I haven't looked closely into how this works).<br><br></div><div>There's a bit of discussion on "diagnostics" here:<br><a href="http://www.goldsborough.me/c++/clang/llvm/tools/2017/02/24/00-00-06-emitting_diagnostics_and_fixithints_in_clang_tools/">http://www.goldsborough.me/c++/clang/llvm/tools/2017/02/24/00-00-06-emitting_diagnostics_and_fixithints_in_clang_tools/</a><br><br></div><div>You probably want to read up about raw_ostream and raw_string_ostream too - as they are useful tools for capturing output from clang, and I'm sure I've seem such things in previous posts, but my search for that isn't going well.<br></div><div><br>--<br></div><div>Mats<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 August 2017 at 12:15, ogzu rasa <span dir="ltr"><<a href="mailto:karpalo1987@gmail.com" target="_blank">karpalo1987@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hello,<br></div>Thanks for response. <br></div>Sorry I didn't precise that i dev a tool with clang lib tooling and I want to redirect the clang message to bufffer (std::stringstream).<br></div>Is there any example/tutorial for write a driver for the compiler ?<br></div><br></div>thanks<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-08-17 11:14 GMT+02:00 mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>To a "buffer" (along the lines of `std::stringstream`) is also possible if you write your own "driver" for the compiler, but clang as an exectuable file has no concept of "buffer" as output destination.<br><br></div><div>I'm not going to look up exactly how to do write the necessary code to capture the output from the compiler components, but I know it's possible, and there have been posts about it in the past.<br><br>--<br></div><div>Mats<br></div></div><div class="m_3763838836873779072HOEnZb"><div class="m_3763838836873779072h5"><div class="gmail_extra"><br><div class="gmail_quote">On 17 August 2017 at 02:46, Jonas Devlieghere via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(7,55,99)">Hi O<span style="font-size:12.800000190734863px;font-family:arial,sans-serif;color:rgb(34,34,34)">gzu,</span></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(7,55,99)"><span style="font-size:12.800000190734863px;font-family:arial,sans-serif;color:rgb(34,34,34)"><br></span></div><div class="gmail_default"><span style="font-size:12.800000190734863px">Clang prints both errors and warnings to stderr. You could redirect stdout to a file and redirect stderr to stdout: clang foo.c </span>> file 2>&1</div><div class="gmail_default"><br></div><div class="gmail_default">Cheers,</div><div class="gmail_default">Jonas</div><div class="gmail_extra">
<br><div class="gmail_quote"><div><div class="m_3763838836873779072m_9069389996354039115h5">On Wed, Aug 16, 2017 at 4:39 PM, ogzu rasa via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_3763838836873779072m_9069389996354039115h5"><div dir="ltr"><div><div><div>Hello,<br></div>How can I redirect clang (version 3.8.1) warning/error message to a buffer ?<br></div><div><br></div>Thanks in advance for helps,<br></div>ogzu<br></div><div id="m_3763838836873779072m_9069389996354039115m_6012979265466226631m_7454206286853231618DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br> <table style="border-top:1px solid #d3d4de">
        <tbody><tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width:46px;height:29px" height="29" width="46"></a></td>
                <td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Garanti sans virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a>           </td>
        </tr>
</tbody></table>
<a href="#m_3763838836873779072_m_9069389996354039115_m_6012979265466226631_m_7454206286853231618_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
<br></div></div>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>