[PATCH] D41033: Use ErrorOS for log messages as well as error
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 14:14:52 PST 2017
sbc100 created this revision.
Herald added subscribers: llvm-commits, aheejin.
The log messages are also diagnostics so it seems like
they should to the same place as errors and debug
messages.
Without this change when I enable --verbose those messages
go to stdout, but when I enable "-mllvm -debug" those messages
go to stderr (because dbgs() goes to stderr by default).
So I end up having to do this a lot:
lld <args> > output_message 2>&1
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41033
Files:
Common/ErrorHandler.cpp
Index: Common/ErrorHandler.cpp
===================================================================
--- Common/ErrorHandler.cpp
+++ Common/ErrorHandler.cpp
@@ -25,7 +25,7 @@
using namespace lld;
// The functions defined in this file can be called from multiple threads,
-// but outs() or errs() are not thread-safe. We protect them using a mutex.
+// but errs() is not thread-safe. We protect them using a mutex.
static std::mutex Mu;
// Prints "\n" or does nothing, depending on Msg contents of
@@ -54,7 +54,6 @@
// build allows us to get the output of -time-passes.
llvm_shutdown();
- outs().flush();
errs().flush();
_exit(Val);
}
@@ -73,15 +72,13 @@
void ErrorHandler::log(const Twine &Msg) {
if (Verbose) {
std::lock_guard<std::mutex> Lock(Mu);
- outs() << LogName << ": " << Msg << "\n";
- outs().flush();
+ *ErrorOS << LogName << ": " << Msg << "\n";
}
}
void ErrorHandler::message(const Twine &Msg) {
std::lock_guard<std::mutex> Lock(Mu);
- outs() << Msg << "\n";
- outs().flush();
+ *ErrorOS << Msg << "\n";
}
void ErrorHandler::warn(const Twine &Msg) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41033.126208.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171208/76e6cc0d/attachment.bin>
More information about the llvm-commits
mailing list