[llvm] 3df67e8 - Adjust LDBG output: surround DebugType between `[` and `]` (#150671)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 25 12:31:21 PDT 2025
Author: Mehdi Amini
Date: 2025-07-25T12:31:08-07:00
New Revision: 3df67e8a40671d53ab8f3f16ed3d16a4e8efc402
URL: https://github.com/llvm/llvm-project/commit/3df67e8a40671d53ab8f3f16ed3d16a4e8efc402
DIFF: https://github.com/llvm/llvm-project/commit/3df67e8a40671d53ab8f3f16ed3d16a4e8efc402.diff
LOG: Adjust LDBG output: surround DebugType between `[` and `]` (#150671)
This makes the output more readable by clearly showing the current debug
type as a keyword.
Added:
Modified:
llvm/include/llvm/Support/DebugLog.h
llvm/unittests/Support/DebugLogTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/DebugLog.h b/llvm/include/llvm/Support/DebugLog.h
index 9556bf2d6242d..3e53944edc905 100644
--- a/llvm/include/llvm/Support/DebugLog.h
+++ b/llvm/include/llvm/Support/DebugLog.h
@@ -38,8 +38,8 @@ class LogWithNewline {
raw_ostream &os)
: os(os) {
if (debug_type)
- os << debug_type << " ";
- os << "[" << file << ":" << line << "] ";
+ os << "[" << debug_type << "] ";
+ os << file << ":" << line << " ";
}
~LogWithNewline() { os << '\n'; }
template <typename T> raw_ostream &operator<<(const T &t) && {
diff --git a/llvm/unittests/Support/DebugLogTest.cpp b/llvm/unittests/Support/DebugLogTest.cpp
index 22dffd857613d..b26fa40cc8687 100644
--- a/llvm/unittests/Support/DebugLogTest.cpp
+++ b/llvm/unittests/Support/DebugLogTest.cpp
@@ -27,7 +27,7 @@ TEST(DebugLogTest, Basic) {
std::string str;
raw_string_ostream os(str);
DEBUGLOG_WITH_STREAM_AND_TYPE(os, nullptr) << "NoType";
- EXPECT_TRUE(StringRef(os.str()).starts_with('['));
+ EXPECT_FALSE(StringRef(os.str()).starts_with('['));
EXPECT_TRUE(StringRef(os.str()).ends_with("NoType\n"));
}
@@ -37,6 +37,7 @@ TEST(DebugLogTest, Basic) {
raw_string_ostream os(str);
DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << "A";
DEBUGLOG_WITH_STREAM_AND_TYPE(os, "B") << "B";
+ EXPECT_TRUE(StringRef(os.str()).starts_with('['));
EXPECT_THAT(os.str(), AllOf(HasSubstr("A\n"), HasSubstr("B\n")));
}
More information about the llvm-commits
mailing list