Author: Kazu Hirata Date: 2025-05-11T07:13:41-07:00 New Revision: 95335fefd8664ca76823928698570c741ebe9c72
URL: https://github.com/llvm/llvm-project/commit/95335fefd8664ca76823928698570c741ebe9c72 DIFF: https://github.com/llvm/llvm-project/commit/95335fefd8664ca76823928698570c741ebe9c72.diff LOG: [clang] Use std::tie to implement operator< (NFC) (#139438) Added: Modified: clang/include/clang/Driver/Compilation.h clang/lib/Frontend/FrontendAction.cpp clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Compilation.h b/clang/include/clang/Driver/Compilation.h index 36ae85c424514..26781fc676832 100644 --- a/clang/include/clang/Driver/Compilation.h +++ b/clang/include/clang/Driver/Compilation.h @@ -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; diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index f09eb9832e692..54a2e3eb297f5 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -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, diff --git a/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp index 667b19f8120ea..77cec7deffb84 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp @@ -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 { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits