Skip to content

Commit 5a1c776

Browse files
joker-ephmahesh-attarde
authored andcommitted
Adjust LDBG output: surround DebugType between [ and ] (llvm#150671)
This makes the output more readable by clearly showing the current debug type as a keyword.
1 parent 0c1a4c1 commit 5a1c776

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/include/llvm/Support/DebugLog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class LogWithNewline {
3838
raw_ostream &os)
3939
: os(os) {
4040
if (debug_type)
41-
os << debug_type << " ";
42-
os << "[" << file << ":" << line << "] ";
41+
os << "[" << debug_type << "] ";
42+
os << file << ":" << line << " ";
4343
}
4444
~LogWithNewline() { os << '\n'; }
4545
template <typename T> raw_ostream &operator<<(const T &t) && {

llvm/unittests/Support/DebugLogTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST(DebugLogTest, Basic) {
2727
std::string str;
2828
raw_string_ostream os(str);
2929
DEBUGLOG_WITH_STREAM_AND_TYPE(os, nullptr) << "NoType";
30-
EXPECT_TRUE(StringRef(os.str()).starts_with('['));
30+
EXPECT_FALSE(StringRef(os.str()).starts_with('['));
3131
EXPECT_TRUE(StringRef(os.str()).ends_with("NoType\n"));
3232
}
3333

@@ -37,6 +37,7 @@ TEST(DebugLogTest, Basic) {
3737
raw_string_ostream os(str);
3838
DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << "A";
3939
DEBUGLOG_WITH_STREAM_AND_TYPE(os, "B") << "B";
40+
EXPECT_TRUE(StringRef(os.str()).starts_with('['));
4041
EXPECT_THAT(os.str(), AllOf(HasSubstr("A\n"), HasSubstr("B\n")));
4142
}
4243

0 commit comments

Comments
 (0)