[LLVMdev] [llvm-commits] [PATCH] Allow per-thread re-direction of outs()/errs()

Chris Lattner
2012-06-01T03:06:31Z

On May 31, 2012, at 2:39 PM, Justin Holewinski wrote:

> The attached patch add the ability to programmatically re-direct
outs()/errs() to an arbitrary raw_ostream instance, maintaining the raw_ostream
instances in a stack structure so clients can push/pop streams at will.  The
stack is also maintained in thread-local storage, so different threads can
re-direct individually.  This allows for two use cases:
>
> 1. Compilers can attach custom streams to outs()/errs() to intercept output
from LLVM without needing to play with STDOUT/STDERR.
> 2. Compilers can receive LLVM output from different threads individually,
instead of having all diagnostics dumped to a single stream.

This isn't the right approach.  Nothing in the library part of the compiler
should be hard coding a stream to write to.  What are you trying to accomplish?

-Chris