-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Use std::tie to implement operator< (NFC) #143728
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
[llvm] Use std::tie to implement operator< (NFC) #143728
Conversation
std::tie facilitates lexicographical comparisons through std::tuple's built-in operator<.
@llvm/pr-subscribers-backend-hexagon Author: Kazu Hirata (kazutakahirata) Changesstd::tie facilitates lexicographical comparisons through std::tuple's Full diff: https://github.com/llvm/llvm-project/pull/143728.diff 2 Files Affected:
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index 24b03a058981a..89b20978c40e6 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -202,15 +202,9 @@ class RelocationValueRef {
IsStubThumb == Other.IsStubThumb;
}
inline bool operator<(const RelocationValueRef &Other) const {
- if (SectionID != Other.SectionID)
- return SectionID < Other.SectionID;
- if (Offset != Other.Offset)
- return Offset < Other.Offset;
- if (Addend != Other.Addend)
- return Addend < Other.Addend;
- if (IsStubThumb != Other.IsStubThumb)
- return IsStubThumb < Other.IsStubThumb;
- return SymbolName < Other.SymbolName;
+ return std::tie(SectionID, Offset, Addend, IsStubThumb, SymbolName) <
+ std::tie(Other.SectionID, Other.Offset, Other.Addend,
+ Other.IsStubThumb, Other.SymbolName);
}
};
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index f38e7b879e5f0..5dde47ab3de57 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -253,7 +253,7 @@ namespace {
bool operator!=(Register R) const { return !operator==(R); }
bool operator<(Register R) const {
// For std::map.
- return Reg < R.Reg || (Reg == R.Reg && Sub < R.Sub);
+ return std::tie(Reg, Sub) < std::tie(R.Reg, R.Sub);
}
llvm::Register Reg;
unsigned Sub = 0;
@@ -298,11 +298,7 @@ namespace {
return !operator==(Ex);
}
bool operator<(const ExtExpr &Ex) const {
- if (Rs != Ex.Rs)
- return Rs < Ex.Rs;
- if (S != Ex.S)
- return S < Ex.S;
- return !Neg && Ex.Neg;
+ return std::tie(Rs, S, Neg) < std::tie(Ex.Rs, Ex.S, Ex.Neg);
}
};
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/30538 Here is the relevant piece of the build log for the reference
|
std::tie facilitates lexicographical comparisons through std::tuple's built-in operator<.
std::tie facilitates lexicographical comparisons through std::tuple's built-in operator<.
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.