[Lldb-commits] [lldb] faaff2c - [lldb] Fix deprecation warnings for hasValue and getValue in mac-only code paths

Nico Weber via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 28 17:13:14 PDT 2022


Author: Nico Weber
Date: 2022-09-28T20:12:32-04:00
New Revision: faaff2cdceac49d2e7c719fe994c5eee343ec818

URL: https://github.com/llvm/llvm-project/commit/faaff2cdceac49d2e7c719fe994c5eee343ec818
DIFF: https://github.com/llvm/llvm-project/commit/faaff2cdceac49d2e7c719fe994c5eee343ec818.diff

LOG: [lldb] Fix deprecation warnings for hasValue and getValue in mac-only code paths

No behavior change.

Added: 
    

Modified: 
    lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
    lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
    lldb/source/Utility/SelectHelper.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 191ce82d5245e..d610ac1280481 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -104,7 +104,7 @@ void PlatformAppleSimulator::GetStatus(Stream &strm) {
       strm << "   " << device.GetUDID() << ": " << device.GetName() << "\n";
     }
 
-    if (m_device.hasValue() && m_device->operator bool()) {
+    if (m_device.has_value() && m_device->operator bool()) {
       strm << "Current device: " << m_device->GetUDID() << ": "
            << m_device->GetName();
       if (m_device->GetState() == CoreSimulatorSupport::Device::State::Booted) {
@@ -226,13 +226,13 @@ PlatformAppleSimulator::DebugProcess(ProcessLaunchInfo &launch_info,
 FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() {
 #if defined(__APPLE__)
   std::lock_guard<std::mutex> guard(m_core_sim_path_mutex);
-  if (!m_core_simulator_framework_path.hasValue()) {
+  if (!m_core_simulator_framework_path.has_value()) {
     m_core_simulator_framework_path =
         FileSpec("/Library/Developer/PrivateFrameworks/CoreSimulator.framework/"
                  "CoreSimulator");
     FileSystem::Instance().Resolve(*m_core_simulator_framework_path);
   }
-  return m_core_simulator_framework_path.getValue();
+  return m_core_simulator_framework_path.value();
 #else
   return FileSpec();
 #endif
@@ -251,16 +251,17 @@ void PlatformAppleSimulator::LoadCoreSimulator() {
 
 #if defined(__APPLE__)
 CoreSimulatorSupport::Device PlatformAppleSimulator::GetSimulatorDevice() {
-  if (!m_device.hasValue()) {
+  if (!m_device.has_value()) {
     const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id = m_kind;
-    std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
+    std::string developer_dir =
+        HostInfo::GetXcodeDeveloperDirectory().GetPath();
     m_device = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
                    developer_dir.c_str())
                    .GetFanciest(dev_id);
   }
 
-  if (m_device.hasValue())
-    return m_device.getValue();
+  if (m_device.has_value())
+    return m_device.value();
   else
     return CoreSimulatorSupport::Device();
 }

diff  --git a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
index f8c3ed65372f8..46eec34206dd2 100644
--- a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
+++ b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
@@ -167,21 +167,21 @@ - (BOOL)spawnWithPath:(NSString *)path
 
 CoreSimulatorSupport::ModelIdentifier
 CoreSimulatorSupport::DeviceType::GetModelIdentifier() {
-  if (!m_model_identifier.hasValue()) {
+  if (!m_model_identifier.has_value()) {
     auto utf8_model_id = [[m_dev modelIdentifier] UTF8String];
     if (utf8_model_id && *utf8_model_id)
       m_model_identifier = ModelIdentifier(utf8_model_id);
   }
 
-  if (m_model_identifier.hasValue())
-    return m_model_identifier.getValue();
+  if (m_model_identifier.has_value())
+    return m_model_identifier.value();
   else
     return ModelIdentifier();
 }
 
 CoreSimulatorSupport::OSVersion
 CoreSimulatorSupport::DeviceRuntime::GetVersion() {
-  if (!m_os_version.hasValue()) {
+  if (!m_os_version.has_value()) {
     auto utf8_ver_string = [[m_dev versionString] UTF8String];
     auto utf8_build_ver = [[m_dev buildVersionString] UTF8String];
     if (utf8_ver_string && *utf8_ver_string && utf8_build_ver &&
@@ -190,8 +190,8 @@ - (BOOL)spawnWithPath:(NSString *)path
     }
   }
 
-  if (m_os_version.hasValue())
-    return m_os_version.getValue();
+  if (m_os_version.has_value())
+    return m_os_version.value();
   return OSVersion();
 }
 
@@ -218,18 +218,18 @@ - (BOOL)spawnWithPath:(NSString *)path
 }
 
 CoreSimulatorSupport::DeviceType CoreSimulatorSupport::Device::GetDeviceType() {
-  if (!m_dev_type.hasValue())
+  if (!m_dev_type.has_value())
     m_dev_type = DeviceType([m_dev deviceType]);
 
-  return m_dev_type.getValue();
+  return m_dev_type.value();
 }
 
 CoreSimulatorSupport::DeviceRuntime
 CoreSimulatorSupport::Device::GetDeviceRuntime() {
-  if (!m_dev_runtime.hasValue())
+  if (!m_dev_runtime.has_value())
     m_dev_runtime = DeviceRuntime([m_dev runtime]);
 
-  return m_dev_runtime.getValue();
+  return m_dev_runtime.value();
 }
 
 bool CoreSimulatorSupport::

diff  --git a/lldb/source/Utility/SelectHelper.cpp b/lldb/source/Utility/SelectHelper.cpp
index 05dbd1cce09d6..22d35bec0ef30 100644
--- a/lldb/source/Utility/SelectHelper.cpp
+++ b/lldb/source/Utility/SelectHelper.cpp
@@ -138,15 +138,15 @@ lldb_private::Status SelectHelper::Select() {
   llvm::SmallVector<fd_set, 1> write_fdset;
   llvm::SmallVector<fd_set, 1> error_fdset;
 
-  if (max_read_fd.hasValue()) {
+  if (max_read_fd.has_value()) {
     read_fdset.resize((nfds / FD_SETSIZE) + 1);
     read_fdset_ptr = read_fdset.data();
   }
-  if (max_write_fd.hasValue()) {
+  if (max_write_fd.has_value()) {
     write_fdset.resize((nfds / FD_SETSIZE) + 1);
     write_fdset_ptr = write_fdset.data();
   }
-  if (max_error_fd.hasValue()) {
+  if (max_error_fd.has_value()) {
     error_fdset.resize((nfds / FD_SETSIZE) + 1);
     error_fdset_ptr = error_fdset.data();
   }


        


More information about the lldb-commits mailing list