Skip to content

Commit 95335fe

Browse files
[clang] Use std::tie to implement operator< (NFC) (#139438)
1 parent 074c420 commit 95335fe

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

clang/include/clang/Driver/Compilation.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,8 @@ class Compilation {
9090
: TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
9191

9292
bool operator<(const TCArgsKey &K) const {
93-
if (TC < K.TC)
94-
return true;
95-
else if (TC == K.TC && BoundArch < K.BoundArch)
96-
return true;
97-
else if (TC == K.TC && BoundArch == K.BoundArch &&
98-
DeviceOffloadKind < K.DeviceOffloadKind)
99-
return true;
100-
return false;
93+
return std::tie(TC, BoundArch, DeviceOffloadKind) <
94+
std::tie(K.TC, K.BoundArch, K.DeviceOffloadKind);
10195
}
10296
};
10397
std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
100100
unsigned Column;
101101

102102
bool operator<(const Position &other) const {
103-
if (Line < other.Line)
104-
return true;
105-
if (Line > other.Line)
106-
return false;
107-
return Column < other.Column;
103+
return std::tie(Line, Column) < std::tie(other.Line, other.Column);
108104
}
109105

110106
static Position GetBeginSpelling(const SourceManager &SM,

clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ class ZeroState {
4141
}
4242

4343
bool operator<(const ZeroState &X) const {
44-
if (BlockID != X.BlockID)
45-
return BlockID < X.BlockID;
46-
if (SFC != X.SFC)
47-
return SFC < X.SFC;
48-
return ZeroSymbol < X.ZeroSymbol;
44+
return std::tie(BlockID, SFC, ZeroSymbol) <
45+
std::tie(X.BlockID, X.SFC, X.ZeroSymbol);
4946
}
5047

5148
void Profile(llvm::FoldingSetNodeID &ID) const {

0 commit comments

Comments
 (0)