[lldb] Remove Log:Channel::GetLogIfAll
authorPavel Labath <pavel@labath.sk>
Thu, 3 Feb 2022 13:54:13 +0000 (14:54 +0100)
committerPavel Labath <pavel@labath.sk>
Fri, 4 Feb 2022 12:31:14 +0000 (13:31 +0100)
after the recent refactor, the function is unused.

lldb/include/lldb/Utility/Log.h
lldb/unittests/Utility/LogTest.cpp

index c0e5510..1ab12e0 100644 (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
index 51ca0fb..533f862 100644 (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));