[cfe-dev] Fwd: warnings and error messages always go to standard error

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 28 13:03:11 PDT 2018


On 8/28/2018 12:51 PM, Geoff Levner via cfe-dev wrote:
> Greetings, clangspeople,
>
> 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.
>
> 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).

The DiagnosticsEngine you pass to the Driver is only used for 
diagnostics from the driver itself, not the resulting compilation.

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.)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180828/9723d69c/attachment.html>


More information about the cfe-dev mailing list