Skip to content

Commit 24ec819

Browse files
kazutakahiratatomtor
authored andcommitted
[llvm] Use std::tie to implement operator< (NFC) (llvm#143728)
std::tie facilitates lexicographical comparisons through std::tuple's built-in operator<.
1 parent 8eda418 commit 24ec819

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,9 @@ class RelocationValueRef {
202202
IsStubThumb == Other.IsStubThumb;
203203
}
204204
inline bool operator<(const RelocationValueRef &Other) const {
205-
if (SectionID != Other.SectionID)
206-
return SectionID < Other.SectionID;
207-
if (Offset != Other.Offset)
208-
return Offset < Other.Offset;
209-
if (Addend != Other.Addend)
210-
return Addend < Other.Addend;
211-
if (IsStubThumb != Other.IsStubThumb)
212-
return IsStubThumb < Other.IsStubThumb;
213-
return SymbolName < Other.SymbolName;
205+
return std::tie(SectionID, Offset, Addend, IsStubThumb, SymbolName) <
206+
std::tie(Other.SectionID, Other.Offset, Other.Addend,
207+
Other.IsStubThumb, Other.SymbolName);
214208
}
215209
};
216210

llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace {
253253
bool operator!=(Register R) const { return !operator==(R); }
254254
bool operator<(Register R) const {
255255
// For std::map.
256-
return Reg < R.Reg || (Reg == R.Reg && Sub < R.Sub);
256+
return std::tie(Reg, Sub) < std::tie(R.Reg, R.Sub);
257257
}
258258
llvm::Register Reg;
259259
unsigned Sub = 0;
@@ -298,11 +298,7 @@ namespace {
298298
return !operator==(Ex);
299299
}
300300
bool operator<(const ExtExpr &Ex) const {
301-
if (Rs != Ex.Rs)
302-
return Rs < Ex.Rs;
303-
if (S != Ex.S)
304-
return S < Ex.S;
305-
return !Neg && Ex.Neg;
301+
return std::tie(Rs, S, Neg) < std::tie(Ex.Rs, Ex.S, Ex.Neg);
306302
}
307303
};
308304

0 commit comments

Comments
 (0)