[llvm] Fix `DEBUGLOG_WITH_STREAM_TYPE_AND_FILE` broken in #150750 (PR #150920)
Ingo Müller via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 03:53:04 PDT 2025
https://github.com/ingomueller-net updated https://github.com/llvm/llvm-project/pull/150920
>From a79635cffa9bfd46bcc3397708d85ecc81d8f769 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Mon, 28 Jul 2025 10:29:29 +0000
Subject: [PATCH 1/2] Fix `DEBUGLOG_WITH_STREAM_TYPE_AND_FILE` broken in
#150750
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This PR fixes the `DEBUGLOG_WITH_STREAM_TYPE_AND_FILE` macro that got
broken in #150750. That PR introduces a more sophisitaced version of
that macro and refactored some code in that process, making the
`getShortFileName` a free function instead of a class member function,
but did not adapt this macro to the refactored code.
Signed-off-by: Ingo Müller <ingomueller at google.com>
---
llvm/include/llvm/Support/DebugLog.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Support/DebugLog.h b/llvm/include/llvm/Support/DebugLog.h
index 19d309865bbd4..5e308eb993036 100644
--- a/llvm/include/llvm/Support/DebugLog.h
+++ b/llvm/include/llvm/Support/DebugLog.h
@@ -40,8 +40,8 @@ namespace llvm {
DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, TYPE, __SHORT_FILE__)
#else
#define DEBUGLOG_WITH_STREAM_AND_TYPE(STREAM, TYPE) \
- DEBUGLOG_WITH_STREAM_TYPE_AND_FILE( \
- STREAM, TYPE, ::llvm::impl::LogWithNewline::getShortFileName(__FILE__))
+ DEBUGLOG_WITH_STREAM_TYPE_AND_FILE(STREAM, TYPE, \
+ ::llvm::impl::getShortFileName(__FILE__))
#endif
namespace impl {
>From c51eb1f9b400fc4198e6f3acbef98d58c06dd98b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Mon, 28 Jul 2025 10:50:59 +0000
Subject: [PATCH 2/2] make previously broken macro being tested
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As suggested by @joker-ehp, this commit undefines `__SHORTFILE__` in
`DebugLogTest.cpp` order to make the previously broken variant of
`DEBUGLOG_WITH_STREAM_AND_TYPE` being tested at least in this one test,
as it is otherwise never used in CI.
Signed-off-by: Ingo Müller <ingomueller at google.com>
---
llvm/unittests/Support/DebugLogTest.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/unittests/Support/DebugLogTest.cpp b/llvm/unittests/Support/DebugLogTest.cpp
index c34d888ab4cad..3217f63745c90 100644
--- a/llvm/unittests/Support/DebugLogTest.cpp
+++ b/llvm/unittests/Support/DebugLogTest.cpp
@@ -6,6 +6,11 @@
//
//===----------------------------------------------------------------------===//
+// This macro is defined in the LLVM build system, but we undefine it here
+// so that we test at least once in-tree the case where __SHORT_FILE__ is not
+// defined.
+#undef __SHORT_FILE__
+
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
More information about the llvm-commits
mailing list