[lldb] Remove Log:Channel::GetLogIfAll

after the recent refactor, the function is unused.
This commit is contained in:
Pavel Labath 2022-02-03 14:54:13 +01:00
parent ae9c074064
commit 13b58f9710
2 changed files with 7 additions and 19 deletions

View File

@ -97,18 +97,7 @@ public:
// after (or concurrently with) this function returning a non-null Log
// pointer, it is still safe to attempt to write to the Log object -- the
// output will be discarded.
Log *GetLogIfAll(MaskType mask) {
Log *log = log_ptr.load(std::memory_order_relaxed);
if (log && log->GetMask().AllSet(mask))
return log;
return nullptr;
}
// This function is safe to call at any time. If the channel is disabled
// after (or concurrently with) this function returning a non-null Log
// pointer, it is still safe to attempt to write to the Log object -- the
// output will be discarded.
Log *GetLogIfAny(MaskType mask) {
Log *GetLog(MaskType mask) {
Log *log = log_ptr.load(std::memory_order_relaxed);
if (log && log->GetMask().AnySet(mask))
return log;
@ -246,7 +235,7 @@ template <typename Cat> Log::Channel &LogChannelFor() = delete;
template <typename Cat> Log *GetLog(Cat mask) {
static_assert(std::is_same<Log::MaskType, std::underlying_type_t<Cat>>::value,
"");
return LogChannelFor<Cat>().GetLogIfAny(Log::MaskType(mask));
return LogChannelFor<Cat>().GetLog(Log::MaskType(mask));
}
} // namespace lldb_private

View File

@ -158,16 +158,15 @@ TEST_F(LogChannelTest, Enable) {
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, error));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
EXPECT_EQ(nullptr, GetLog(TestChannel::BAR));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO | TestChannel::BAR));
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"bar"}, error));
EXPECT_NE(nullptr, test_channel.GetLogIfAll(
Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
EXPECT_NE(nullptr, GetLog(TestChannel::BAR));
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"baz"}, error));
EXPECT_NE(std::string::npos, error.find("unrecognized log category 'baz'"))
<< "error: " << error;
EXPECT_NE(nullptr, test_channel.GetLogIfAll(
Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
}
TEST_F(LogChannelTest, EnableOptions) {
@ -191,8 +190,8 @@ TEST_F(LogChannelTest, Disable) {
new llvm::raw_string_ostream(message));
std::string error;
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"foo", "bar"}, error));
EXPECT_NE(nullptr, test_channel.GetLogIfAll(
Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
EXPECT_NE(nullptr, GetLog(TestChannel::BAR));
EXPECT_TRUE(DisableChannel("chan", {"bar"}, error));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));