<div dir="ltr">We have the same problem when using the C interface, however. When clang_parseTranslationUnit() fails, there seems to be no way to recover the diagnostics, which are printed to standard error. Apparently clang_getDiagnosticSetFromTU() is there to give you access to diagnostics, but it is only of use if you have a translation unit for it...<div><br></div><div>Geoff<br><br><div class="gmail_quote"><div dir="ltr">On Tue, 28 Aug 2018 at 22:37, Geoff Levner <<a href="mailto:glevner@gmail.com">glevner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Aha! Thank you very much, Eli. That does the trick.<div><br></div><div>[Actually, though, you have to pass createDiagnostics() a DiagnosticConsumer, which in my case is my TextDiagnosticPrinter.]</div><div><br></div><div>Geoff</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 28 Aug 2018 at 22:03, Friedman, Eli <<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div class="m_-2045675789311790451m_-7146172031307308724moz-cite-prefix">On 8/28/2018 12:51 PM, Geoff Levner via
cfe-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">
<div>Greetings, clangspeople,</div>
<div><br>
</div>
<div>We are using Clang and LLVM in an application to
compile and execute C++ code on the fly. If the code fails
to compile, I would like to be able to pop up a dialog box
telling the user why. But warnings and error messages go
straight to standard error.</div>
<div><br>
</div>
<div>I have tried passing a raw_string_ostream to
TextDiagnosticPrinter instead of errs(), but that seems to
have no effect. What is that stream actually used for? Am
I doing something wrong? I have attached the code we use
to compile (simplified a bit).</div>
</div>
</div>
</div>
</blockquote>
<br>
The DiagnosticsEngine you pass to the Driver is only used for
diagnostics from the driver itself, not the resulting compilation.<br>
<br>
createDiagnostics() takes a DiagnosticsEngine as a parameter. (If
you don't explicitly pass one, it will create one for you, which
prints diagnostics to stderr.)<br>
<br>
-Eli<br>
<pre class="m_-2045675789311790451m_-7146172031307308724moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</div>
</blockquote></div>
</blockquote></div></div></div>