[clang] [clang] Use std::tie to implement operator< (NFC) (PR #139438)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 10 23:15:07 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/139438.diff
3 Files Affected:
- (modified) clang/include/clang/Driver/Compilation.h (+2-8)
- (modified) clang/lib/Frontend/FrontendAction.cpp (+1-5)
- (modified) clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp (+2-5)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/139438
More information about the cfe-commits
mailing list