[clang] [clang] Use llvm::max_element (NFC) (PR #140435)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat May 17 22:26:55 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140435
None
>From b83d98ae890773513065cad304cf6a805e96138c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 17 May 2025 21:27:54 -0700
Subject: [PATCH] [clang] Use llvm::max_element (NFC)
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 3 +--
clang/lib/CodeGen/CodeGenPGO.cpp | 2 +-
clang/lib/Sema/SemaCUDA.cpp | 7 ++++---
clang/utils/TableGen/ClangOptionDocEmitter.cpp | 5 ++---
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 918b064c3cfd5..df6edee93f3bb 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10532,8 +10532,7 @@ getNDSWDS(const FunctionDecl *FD, ArrayRef<ParamAttrTy> ParamAttrs) {
}) &&
"Invalid size");
- return std::make_tuple(*std::min_element(std::begin(Sizes), std::end(Sizes)),
- *std::max_element(std::begin(Sizes), std::end(Sizes)),
+ return std::make_tuple(*llvm::min_element(Sizes), *llvm::max_element(Sizes),
OutputBecomesInput);
}
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index afa1d882545f0..8197c5f9d37ba 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -1486,7 +1486,7 @@ CodeGenFunction::createProfileWeights(ArrayRef<uint64_t> Weights) const {
return nullptr;
// Check for empty weights.
- uint64_t MaxWeight = *std::max_element(Weights.begin(), Weights.end());
+ uint64_t MaxWeight = *llvm::max_element(Weights);
if (MaxWeight == 0)
return nullptr;
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 45595068ea938..176d9322d3d2a 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -330,9 +330,10 @@ void SemaCUDA::EraseUnwantedMatches(
};
// Find the best call preference among the functions in Matches.
- CUDAFunctionPreference BestCFP = GetCFP(*std::max_element(
- Matches.begin(), Matches.end(),
- [&](const Pair &M1, const Pair &M2) { return GetCFP(M1) < GetCFP(M2); }));
+ CUDAFunctionPreference BestCFP =
+ GetCFP(*llvm::max_element(Matches, [&](const Pair &M1, const Pair &M2) {
+ return GetCFP(M1) < GetCFP(M2);
+ }));
// Erase all functions with lower priority.
llvm::erase_if(Matches,
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index b651820bb4ab5..e39b8c9434a13 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -336,9 +336,8 @@ void emitOption(const DocumentedOption &Option, const Record *DocInfo,
});
assert(!SphinxOptionIDs.empty() && "no flags for option");
static std::map<std::string, int> NextSuffix;
- int SphinxWorkaroundSuffix = NextSuffix[*std::max_element(
- SphinxOptionIDs.begin(), SphinxOptionIDs.end(),
- [&](const std::string &A, const std::string &B) {
+ int SphinxWorkaroundSuffix = NextSuffix[*llvm::max_element(
+ SphinxOptionIDs, [&](const std::string &A, const std::string &B) {
return NextSuffix[A] < NextSuffix[B];
})];
for (auto &S : SphinxOptionIDs)
More information about the cfe-commits
mailing list