Skip to content

[llvm] Use std::tie to implement operator< (NFC) #139487

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 5 additions & 12 deletions llvm/include/llvm/MC/MCContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand All @@ -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);
}
};

Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
};

Expand Down
Loading