[llvm] Add thread-local overrides for `llvm::errs()` and `llvm::outs()`. (PR #90374)

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 11:05:56 PDT 2024


zygoloid wrote:

LGTM. Not approving because I'd like this to be signed off by someone not involved in Carbon.

I have also looked through the `llvm::errs` and `llvm::outs` usage in Clang: There are some uses in the driver (eg, for `--version` and similar output) which look feasible to redirect into a custom stream. Then there are uses in `dump` functions and uses on the way to an `llvm_unreachable`, which are clearly only for debugging and so seem fine to not be redirectable. But then there's a long tail of other things -- `PrintStats` functions that should take a stream but don't, pragmas that dump information to `errs` when they really should be using a proper `remark` diagnostic, some flag-controlled modes in the frontend that produce output directly to stdout / stderr, and so on -- and cleaning all of that up would be a long process. I think we *should* eventually do that cleanup, and once that's done it *might* make sense to retire this functionality (depending on whether a similar cleanup is also reasonable to do in LLVM -- I only looked at Clang), but this PR makes sense to me at least in the shorter term. I don't see another reasonable way to make the driver-as-a-library use case work well, without imposing non-trivial churn across LLVM and Clang and substantial engineering cost.

https://github.com/llvm/llvm-project/pull/90374


More information about the llvm-commits mailing list