Skip to content

Conversation

ingomueller-net
Copy link
Contributor

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.

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

@llvm/pr-subscribers-llvm-support

Author: Ingo Müller (ingomueller-net)

Changes

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.


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

1 Files Affected:

  • (modified) llvm/include/llvm/Support/DebugLog.h (+2-2)
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 {

Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
We don't exercise this code path upstream right now.

What about adding this diff to your PR:

diff --git a/llvm/unittests/Support/DebugLogTest.cpp b/llvm/unittests/Support/DebugLogTest.cpp
index 8356ae856be2..3c82376734b9 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/ADT/Sequence.h"
 #include "llvm/Support/raw_ostream.h"

@ingomueller-net
Copy link
Contributor Author

Sounds good! Will update the PR shortly.

This PR fixes the `DEBUGLOG_WITH_STREAM_TYPE_AND_FILE` macro that got
broken in llvm#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 <[email protected]>
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 <[email protected]>
Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@ingomueller-net ingomueller-net merged commit a2fcf18 into llvm:main Jul 28, 2025
9 checks passed
@ingomueller-net ingomueller-net deleted the fix-ldbg-macro branch July 28, 2025 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants