Skip to content

Commit 1ecba5b

Browse files
[llvm] Use std::tie to implement operator< (NFC) (llvm#139487)
1 parent 2c9a46c commit 1ecba5b

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,8 @@ inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) {
234234
/// the GSYM file.
235235
inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) {
236236
// First sort by address range
237-
if (LHS.Range != RHS.Range)
238-
return LHS.Range < RHS.Range;
239-
if (LHS.Inline == RHS.Inline)
240-
return LHS.OptLineTable < RHS.OptLineTable;
241-
return LHS.Inline < RHS.Inline;
237+
return std::tie(LHS.Range, LHS.Inline, LHS.OptLineTable) <
238+
std::tie(RHS.Range, RHS.Inline, RHS.OptLineTable);
242239
}
243240

244241
raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R);

llvm/include/llvm/MC/MCContext.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,9 @@ class MCContext {
259259
SelectionKey(SelectionKey), UniqueID(UniqueID) {}
260260

261261
bool operator<(const COFFSectionKey &Other) const {
262-
if (SectionName != Other.SectionName)
263-
return SectionName < Other.SectionName;
264-
if (GroupName != Other.GroupName)
265-
return GroupName < Other.GroupName;
266-
if (SelectionKey != Other.SelectionKey)
267-
return SelectionKey < Other.SelectionKey;
268-
return UniqueID < Other.UniqueID;
262+
return std::tie(SectionName, GroupName, SelectionKey, UniqueID) <
263+
std::tie(Other.SectionName, Other.GroupName, Other.SelectionKey,
264+
Other.UniqueID);
269265
}
270266
};
271267

@@ -279,11 +275,8 @@ class MCContext {
279275
: SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
280276

281277
bool operator<(const WasmSectionKey &Other) const {
282-
if (SectionName != Other.SectionName)
283-
return SectionName < Other.SectionName;
284-
if (GroupName != Other.GroupName)
285-
return GroupName < Other.GroupName;
286-
return UniqueID < Other.UniqueID;
278+
return std::tie(SectionName, GroupName, UniqueID) <
279+
std::tie(Other.SectionName, Other.GroupName, Other.UniqueID);
287280
}
288281
};
289282

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10909,9 +10909,7 @@ struct AAPotentialValuesImpl : AAPotentialValues {
1090910909
return II.I == I && II.S == S;
1091010910
};
1091110911
bool operator<(const ItemInfo &II) const {
10912-
if (I == II.I)
10913-
return S < II.S;
10914-
return I < II.I;
10912+
return std::tie(I, S) < std::tie(II.I, II.S);
1091510913
};
1091610914
};
1091710915

0 commit comments

Comments
 (0)