Skip to content

Commit 94c0a0b

Browse files
[BOLT] Use std::tie to Implment operator< (NFC) (#139404)
1 parent d5b170c commit 94c0a0b

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

bolt/include/bolt/Passes/FrameAnalysis.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define BOLT_PASSES_FRAMEANALYSIS_H
1111

1212
#include "bolt/Passes/StackPointerTracking.h"
13+
#include <tuple>
1314

1415
namespace llvm {
1516
namespace bolt {
@@ -53,9 +54,7 @@ struct ArgInStackAccess {
5354
uint8_t Size;
5455

5556
bool operator<(const ArgInStackAccess &RHS) const {
56-
if (StackOffset != RHS.StackOffset)
57-
return StackOffset < RHS.StackOffset;
58-
return Size < RHS.Size;
57+
return std::tie(StackOffset, Size) < std::tie(RHS.StackOffset, RHS.Size);
5958
}
6059
};
6160

bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ struct MCInstInBBReference {
4343
return BB == RHS.BB && BBIndex == RHS.BBIndex;
4444
}
4545
bool operator<(const MCInstInBBReference &RHS) const {
46-
if (BB != RHS.BB)
47-
return BB < RHS.BB;
48-
return BBIndex < RHS.BBIndex;
46+
return std::tie(BB, BBIndex) < std::tie(RHS.BB, RHS.BBIndex);
4947
}
5048
operator MCInst &() const {
5149
assert(BB != nullptr);

bolt/include/bolt/Profile/DataReader.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,7 @@ struct BranchInfo {
9090
}
9191

9292
bool operator<(const BranchInfo &RHS) const {
93-
if (From < RHS.From)
94-
return true;
95-
96-
if (From == RHS.From)
97-
return (To < RHS.To);
98-
99-
return false;
93+
return std::tie(From, To) < std::tie(RHS.From, RHS.To);
10094
}
10195

10296
/// Merges branch and misprediction counts of \p BI with those of this object.

0 commit comments

Comments
 (0)