[llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams

Dan Gohman gohman at apple.com
Wed Mar 2 13:13:23 PST 2011


On Mar 2, 2011, at 12:37 PM, Erik Olofsson wrote:
>> What's the purpose of the raw_output_streams class? Are you expecting
>> to migrate code that uses errs() and outs() to using it? If so,
>> that's quite invasive. If not, what's the purpose?
> 
> Most functions that I needed to override already takes an raw_ostream. Some functions however needs both errs and outs. I first implemented this by letting these functions take both errs and outs as arguments, but that resulted in asserts because there is check in place that prevents the application from calling outs() if you are for example outputting the results to stdout. That is why I need to virtualize calling outs() so you can replace it without actually calling the outs() function until it's actually needed.
> 
> See the attached patch for how I'm expecting to implement this in clang. FYI I will split this patch into refactoring and implementing the new feature before submitting it again to clang-commits.


Here's an idea for an alternate approach:

Add a function llvm::redirect_outs_and_errs_for_debugging()
(or with a better name). On non-Windows, it's a no-op. On Windows, it
sets a global boolean flag to true. Then add code to outs() and
errs() that checks the flag and returns the
OutputDebugString streams if it is true, on Windows. Do you think
that's feasible?

Otherwise, if you're only planning to update clang for all this, then
the code should all be in clang-specific headers, rather than in
llvm/Support/raw_ostream.h.

Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110302/816d4efa/attachment.html>


More information about the llvm-commits mailing list