Skip to content

[lldb] Use std::tie to implement operator< (NFC) #141416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 25, 2025

@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)

Changes

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

3 Files Affected:

  • (modified) lldb/include/lldb/Symbol/CompilerDeclContext.h (+2-3)
  • (modified) lldb/include/lldb/Target/CoreFileMemoryRanges.h (+2-5)
  • (modified) lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h (+2-10)
diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h
index 89b4a9787688b..fe2ef215a8d19 100644
--- a/lldb/include/lldb/Symbol/CompilerDeclContext.h
+++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h
@@ -48,9 +48,8 @@ class CompilerDeclContext {
   explicit operator bool() const { return IsValid(); }
 
   bool operator<(const CompilerDeclContext &rhs) const {
-    if (m_type_system == rhs.m_type_system)
-      return m_opaque_decl_ctx < rhs.m_opaque_decl_ctx;
-    return m_type_system < rhs.m_type_system;
+    return std::tie(m_type_system, m_opaque_decl_ctx) <
+           std::tie(rhs.m_type_system, rhs.m_opaque_decl_ctx);
   }
 
   bool IsValid() const {
diff --git a/lldb/include/lldb/Target/CoreFileMemoryRanges.h b/lldb/include/lldb/Target/CoreFileMemoryRanges.h
index 0cc5433525ddc..78d01acca324e 100644
--- a/lldb/include/lldb/Target/CoreFileMemoryRanges.h
+++ b/lldb/include/lldb/Target/CoreFileMemoryRanges.h
@@ -30,11 +30,8 @@ struct CoreFileMemoryRange {
   }
 
   bool operator<(const CoreFileMemoryRange &rhs) const {
-    if (range < rhs.range)
-      return true;
-    if (range == rhs.range)
-      return lldb_permissions < rhs.lldb_permissions;
-    return false;
+    return std::tie(range, lldb_permissions) <
+           std::tie(rhs.range, rhs.lldb_permissions);
   }
 
   std::string Dump() const {
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index ffe9725fa6826..45de098c15f51 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -386,16 +386,8 @@ class ObjCLanguageRuntime : public LanguageRuntime {
     }
 
     bool operator<(const ClassAndSel &rhs) const {
-      if (class_addr < rhs.class_addr)
-        return true;
-      else if (class_addr > rhs.class_addr)
-        return false;
-      else {
-        if (sel_addr < rhs.sel_addr)
-          return true;
-        else
-          return false;
-      }
+      return std::tie(class_addr, sel_addr) <
+             std::tie(rhs.class_addr, rhs.sel_addr);
     }
 
     lldb::addr_t class_addr = LLDB_INVALID_ADDRESS;

@kazutakahirata kazutakahirata merged commit f314588 into llvm:main May 25, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250525_tie_compare branch May 25, 2025 18:03
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 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