<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I am trying to redirect the output emitted when running a tool through clang::tooling::runToolOnCode() to a buffer or string instead of stderr (llvm::errs()). I'm using clangTooling from release 3.9.</div><div class=""><br class=""></div><div class="">When looking at clangTooling code and following the execution flow, I have found the following:</div><div class=""><font face="Menlo" class="">clang::tooling::runToolOnCode()</font></div><div class="">calls <font face="Menlo" class="">clang::tooling::runToolOnCodeWithArgs()</font></div><div class="">which calls <font face="Menlo" class="">clang::tooling::ToolInvocation::run()</font></div><div class="">which contains the following :</div><div class=""><font face="Menlo" class="">TextDiagnosticPrinter DiagnosticPrinter(<b class="">llvm::errs()</b>, &*DiagOpts);</font></div><div class=""><font face="Menlo" class="">DiagnosticsEngine Diagnostics(<br class=""> IntrusiveRefCntPtr<clang::DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,<br class=""> DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);</font></div><div class=""><br class=""></div><div class="">So at this point I guess I'm stuck because everything is redirected to stderr…</div><div class=""><b class="">Did I miss something or is there really this limitation?</b></div><div class=""><br class=""></div><div class="">I also thought of redirecting stderr to somewhere else but… I can't see how it will fit my needs as in the end I want to call <span style="font-family: Menlo;" class="">clang::tooling::runToolOnCode()</span> on different files in parallel, all of it in the same process ; so I'll get stderr mixed with output from several executions. The best solution would obviously being able to provide the DiagnosticConsumer but at the moment everything looks hardcoded.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Best regards,</div><div class="">L. Soltic</div><div class=""><br class=""></div></body></html>