Skip to content

Conversation

@JDevlieghere
Copy link
Member

I suggested using a lambda in #126171 but I think @jasonmolenda missed it.

… (NFC)

I suggested using a lambda in llvm#126171 but I think Jason missed it.
@llvmbot
Copy link
Member

llvmbot commented Feb 7, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

I suggested using a lambda in #126171 but I think @jasonmolenda missed it.


Full diff: https://github.com/llvm/llvm-project/pull/126175.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+11-9)
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index af873339e002ec..d512d6143639cd 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1212,23 +1212,25 @@ bool DynamicLoaderDarwin::UseDYLDSPI(Process *process) {
 
   llvm::VersionTuple version = process->GetHostOSVersion();
   if (!version.empty()) {
-    const llvm::Triple::OSType os_type =
+    using namespace llvm;
+    const Triple::OSType os_type =
         process->GetTarget().GetArchitecture().GetTriple().getOS();
 
-    // Older than macOS 10.12
-    if (os_type == llvm::Triple::MacOSX && version < llvm::VersionTuple(10, 12))
+    auto OlderThan = [os_type, version](llvm::Triple::OSType o,
+                                        llvm::VersionTuple v) -> bool {
+      return os_type == o && version < v;
+    };
+
+    if (OlderThan(Triple::MacOSX, VersionTuple(10, 12)))
       use_new_spi_interface = false;
 
-    // Older than iOS 10
-    if (os_type == llvm::Triple::IOS && version < llvm::VersionTuple(10))
+    if (OlderThan(Triple::IOS, VersionTuple(10)))
       use_new_spi_interface = false;
 
-    // Older than tvOS 10
-    if (os_type == llvm::Triple::TvOS && version < llvm::VersionTuple(10))
+    if (OlderThan(Triple::TvOS, VersionTuple(10)))
       use_new_spi_interface = false;
 
-    // Older than watchOS 3
-    if (os_type == llvm::Triple::WatchOS && version < llvm::VersionTuple(3))
+    if (OlderThan(Triple::WatchOS, VersionTuple(3)))
       use_new_spi_interface = false;
 
     // llvm::Triple::BridgeOS and llvm::Triple::XROS always use the new

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is better, thanks, I should have done it myself.

@JDevlieghere JDevlieghere merged commit 99099cd into llvm:main Feb 7, 2025
7 of 8 checks passed
@JDevlieghere JDevlieghere deleted the DynamicLoaderDarwin-Lambda branch February 7, 2025 04:39
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants