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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 08:56:01 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/143561

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


>From 0e97d8ed67c9d413c987b318f18764e37a6cd89f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 9 Jun 2025 00:38:37 -0700
Subject: [PATCH] [IPO] Use std::tie to implement operator< (NFC)

std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
---
 llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
   }
 };
 



More information about the llvm-commits mailing list