[PATCH] D81156: [Support] Create a tied stream class and use it for errs()
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 04:19:47 PDT 2020
labath added a comment.
In D81156#2079144 <https://reviews.llvm.org/D81156#2079144>, @jhenderson wrote:
> In D81156#2074078 <https://reviews.llvm.org/D81156#2074078>, @MaskRay wrote:
>
> > Sorry, undo LGTM. Is it worth making tied_to an opt-in feature? i.e. for command line utilities, they can run `errs().tie(outs())`.
>
>
> The issue with that is that all tools that want it (most of them?) will have to explicitly do the work for that. One of the motivations to change `errs()` is to prevent the need to require code in llvm-dwarfdump (and other tools) to be used to prevent stream interleaving. @dblaikie/@JDevlieghere etc what are your opinions? Is it acceptable to require tools to specify the one-line change here?
>
> > We can probably even fold the TiedTo field into `raw_fd_ostream`. Just a thought.
>
> Folding it into raw_fd_ostream would be reasonable. We could have an Optional stream as the tied-to stream for this, and it would probably simplify the required code (no need to provide a template parameter etc to identify the base stream). `tie` and `untie` could be provided to set/unset the tied-to stream.
>
> If we went with that approach, we could always have `errs()` and `outs()` tied as proposed in the current patch, but with the ability for tools to opt-out if they don't want the behaviour. What do you think?
I don't think it's necessary, but that approach makes sense to me -- though I'd go with `tie(nullptr)` instead of `untie()` for symmetry with `std::basic_ios`.
================
Comment at: llvm/unittests/Support/raw_ostream_test.cpp:365
+ TiedTo << "a";
+ std::error_code EC;
+
----------------
This appears to be unused.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81156/new/
https://reviews.llvm.org/D81156
More information about the llvm-commits
mailing list