[llvm] [llvm] Use std::tie to implement operator< (NFC) (PR #139487)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 19:23:35 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/139487
None
>From 0af8e9cc037f139bcc26a6f0958eb839ec5109d3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 10 May 2025 09:21:24 -0700
Subject: [PATCH] [llvm] Use std::tie to implement operator< (NFC)
---
llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h | 7 ++-----
llvm/include/llvm/MC/MCContext.h | 17 +++++------------
.../lib/Transforms/IPO/AttributorAttributes.cpp | 4 +---
3 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
index 187642257cc52..19ec35c947c19 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
@@ -234,11 +234,8 @@ inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) {
/// the GSYM file.
inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) {
// First sort by address range
- if (LHS.Range != RHS.Range)
- return LHS.Range < RHS.Range;
- if (LHS.Inline == RHS.Inline)
- return LHS.OptLineTable < RHS.OptLineTable;
- return LHS.Inline < RHS.Inline;
+ return std::tie(LHS.Range, LHS.Inline, LHS.OptLineTable) <
+ std::tie(RHS.Range, RHS.Inline, RHS.OptLineTable);
}
raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R);
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index e97c890ce9135..73c6d57f107f7 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -259,13 +259,9 @@ class MCContext {
SelectionKey(SelectionKey), UniqueID(UniqueID) {}
bool operator<(const COFFSectionKey &Other) const {
- if (SectionName != Other.SectionName)
- return SectionName < Other.SectionName;
- if (GroupName != Other.GroupName)
- return GroupName < Other.GroupName;
- if (SelectionKey != Other.SelectionKey)
- return SelectionKey < Other.SelectionKey;
- return UniqueID < Other.UniqueID;
+ return std::tie(SectionName, GroupName, SelectionKey, UniqueID) <
+ std::tie(Other.SectionName, Other.GroupName, Other.SelectionKey,
+ Other.UniqueID);
}
};
@@ -279,11 +275,8 @@ class MCContext {
: SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
bool operator<(const WasmSectionKey &Other) const {
- if (SectionName != Other.SectionName)
- return SectionName < Other.SectionName;
- if (GroupName != Other.GroupName)
- return GroupName < Other.GroupName;
- return UniqueID < Other.UniqueID;
+ return std::tie(SectionName, GroupName, UniqueID) <
+ std::tie(Other.SectionName, Other.GroupName, Other.UniqueID);
}
};
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index a72c1d329e199..8b843634600be 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -10909,9 +10909,7 @@ struct AAPotentialValuesImpl : AAPotentialValues {
return II.I == I && II.S == S;
};
bool operator<(const ItemInfo &II) const {
- if (I == II.I)
- return S < II.S;
- return I < II.I;
+ return std::tie(I, S) < std::tie(II.I, II.S);
};
};
More information about the llvm-commits
mailing list