Skip to content

Commit 3dc2649

Browse files
committed
Update log_level for LLVM_DEBUG and associated macros
During the review of llvm#150855 we switched from 0 to 1 for the default log level used, but this macro wasn't updated.
1 parent 29067ac commit 3dc2649

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

llvm/include/llvm/Support/Debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void setCurrentDebugTypes(const char **Types, unsigned Count);
7171
/// is not specified, or is specified as "bitset".
7272
#define DEBUG_WITH_TYPE(TYPE, ...) \
7373
do { \
74-
if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) { \
74+
if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE, 1)) { \
7575
__VA_ARGS__; \
7676
} \
7777
} while (false)

llvm/unittests/Support/DebugTest.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,46 @@ TEST(DebugTest, CommaInDebugBlock) {
5050
});
5151
EXPECT_EQ("ZYX", os1.str());
5252
}
53+
54+
TEST(DebugTest, DebugWithType) {
55+
llvm::DebugFlag = true;
56+
57+
// Check if the DEBUG_WITH_TYPE macro is enabled for the given type.
58+
auto CheckDebugWithType = [](const char *Type) {
59+
bool Visited = false;
60+
DEBUG_WITH_TYPE(Type, { Visited = true; });
61+
return Visited;
62+
};
63+
64+
{
65+
static const char *DT[] = {"A", "B"};
66+
setCurrentDebugTypes(DT, sizeof(DT) / sizeof(DT[0]));
67+
EXPECT_TRUE(CheckDebugWithType("A"));
68+
EXPECT_TRUE(CheckDebugWithType("B"));
69+
EXPECT_FALSE(CheckDebugWithType("C"));
70+
}
71+
{
72+
static const char *DT[] = {"A:"};
73+
setCurrentDebugTypes(DT, sizeof(DT) / sizeof(DT[0]));
74+
EXPECT_FALSE(CheckDebugWithType("A"));
75+
EXPECT_TRUE(CheckDebugWithType("B"));
76+
EXPECT_TRUE(CheckDebugWithType("C"));
77+
}
78+
{
79+
static const char *DT[] = {"A:", "B"};
80+
setCurrentDebugTypes(DT, sizeof(DT) / sizeof(DT[0]));
81+
EXPECT_FALSE(CheckDebugWithType("A"));
82+
EXPECT_TRUE(CheckDebugWithType("B"));
83+
EXPECT_FALSE(CheckDebugWithType("C"));
84+
}
85+
{
86+
static const char *DT[] = {"A:3", "B:", "C"};
87+
setCurrentDebugTypes(DT, sizeof(DT) / sizeof(DT[0]));
88+
EXPECT_TRUE(CheckDebugWithType("A"));
89+
EXPECT_FALSE(isCurrentDebugType("A", 4));
90+
EXPECT_FALSE(CheckDebugWithType("B"));
91+
EXPECT_TRUE(isCurrentDebugType("C", 10));
92+
EXPECT_FALSE(CheckDebugWithType("D"));
93+
}
94+
}
5395
#endif

0 commit comments

Comments
 (0)