[lld] [lld] Move handling of message separator to reportDiagnostic() (PR #117587)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 10:03:37 PST 2024


https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/117587

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.


>From 53ee5b83948a12c722adb79d3961c16a21928b09 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Mon, 25 Nov 2024 10:03:23 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 lld/Common/ErrorHandler.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp
index 6b60ebb18e8212..8ba2d9fe0c9079 100644
--- a/lld/Common/ErrorHandler.cpp
+++ b/lld/Common/ErrorHandler.cpp
@@ -219,6 +219,7 @@ void ErrorHandler::reportDiagnostic(StringRef location, Colors c,
   }
   os << msg << '\n';
   errs() << buf;
+  sep = getSeparator(msg);
 }
 
 void ErrorHandler::log(const Twine &msg) {
@@ -247,7 +248,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 +278,6 @@ void ErrorHandler::error(const Twine &msg) {
       exit = exitEarly;
     }
 
-    sep = getSeparator(msg);
     ++errorCount;
   }
 



More information about the llvm-commits mailing list