[lld] a6fa51f - [lld] Move handling of message separator to reportDiagnostic()
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 10:36:35 PST 2024
Author: Alexander Richardson
Date: 2024-12-02T10:36:32-08:00
New Revision: a6fa51f5ce8f31a088f04d7c14690bb0de3259f1
URL: https://github.com/llvm/llvm-project/commit/a6fa51f5ce8f31a088f04d7c14690bb0de3259f1
DIFF: https://github.com/llvm/llvm-project/commit/a6fa51f5ce8f31a088f04d7c14690bb0de3259f1.diff
LOG: [lld] Move handling of message separator to reportDiagnostic()
This ensures that it is also updated when calling log() and not just for
errors and warnings. This was noticed in the downstream CHERI fork where
a test using CHECK-NEXT was seeing empty lines after single-line log()
messages.
Reviewed By: MaskRay
Pull Request: https://github.com/llvm/llvm-project/pull/117587
Added:
Modified:
lld/Common/ErrorHandler.cpp
Removed:
################################################################################
diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp
index 6b60ebb18e8212..716bce54258ce7 100644
--- a/lld/Common/ErrorHandler.cpp
+++ b/lld/Common/ErrorHandler.cpp
@@ -219,6 +219,9 @@ void ErrorHandler::reportDiagnostic(StringRef location, Colors c,
}
os << msg << '\n';
errs() << buf;
+ // If msg contains a newline, ensure that the next diagnostic is preceded by
+ // a blank line separator.
+ sep = getSeparator(msg);
}
void ErrorHandler::log(const Twine &msg) {
@@ -247,7 +250,6 @@ void ErrorHandler::warn(const Twine &msg) {
std::lock_guard<std::mutex> lock(mu);
reportDiagnostic(getLocation(msg), Colors::MAGENTA, "warning", msg);
- sep = getSeparator(msg);
}
void ErrorHandler::error(const Twine &msg) {
@@ -278,7 +280,6 @@ void ErrorHandler::error(const Twine &msg) {
exit = exitEarly;
}
- sep = getSeparator(msg);
++errorCount;
}
More information about the llvm-commits
mailing list