Skip to content

[clang] Use std::tie to implement operator< (NFC) #139438

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
10 changes: 2 additions & 8 deletions clang/include/clang/Driver/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,8 @@ class Compilation {
: TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}

bool operator<(const TCArgsKey &K) const {
if (TC < K.TC)
return true;
else if (TC == K.TC && BoundArch < K.BoundArch)
return true;
else if (TC == K.TC && BoundArch == K.BoundArch &&
DeviceOffloadKind < K.DeviceOffloadKind)
return true;
return false;
return std::tie(TC, BoundArch, DeviceOffloadKind) <
std::tie(K.TC, K.BoundArch, K.DeviceOffloadKind);
}
};
std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs;
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
unsigned Column;

bool operator<(const Position &other) const {
if (Line < other.Line)
return true;
if (Line > other.Line)
return false;
return Column < other.Column;
return std::tie(Line, Column) < std::tie(other.Line, other.Column);
}

static Position GetBeginSpelling(const SourceManager &SM,
Expand Down
7 changes: 2 additions & 5 deletions clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ class ZeroState {
}

bool operator<(const ZeroState &X) const {
if (BlockID != X.BlockID)
return BlockID < X.BlockID;
if (SFC != X.SFC)
return SFC < X.SFC;
return ZeroSymbol < X.ZeroSymbol;
return std::tie(BlockID, SFC, ZeroSymbol) <
std::tie(X.BlockID, X.SFC, X.ZeroSymbol);
}

void Profile(llvm::FoldingSetNodeID &ID) const {
Expand Down