Skip to content

[IPO] Use std::tie to implement operator< (NFC) #143561

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

std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.

std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.


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

1 Files Affected:

  • (modified) llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h (+1-1)
diff --git a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
index d34473f03c8de..7a03405b4f462 100644
--- a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
@@ -113,7 +113,7 @@ struct TypeMemberInfo {
   uint64_t Offset;
 
   bool operator<(const TypeMemberInfo &other) const {
-    return Bits < other.Bits || (Bits == other.Bits && Offset < other.Offset);
+    return std::tie(Bits, Offset) < std::tie(other.Bits, other.Offset);
   }
 };
 

@kazutakahirata kazutakahirata merged commit 1befb24 into llvm:main Jun 10, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250610_operator_less_llvm branch June 10, 2025 18:32
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants