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

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 10:04:11 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-wasm

Author: Alexander Richardson (arichardson)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/117587.diff


1 Files Affected:

- (modified) lld/Common/ErrorHandler.cpp (+1-2) 


``````````diff
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;
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list