[clang] [clang] Use llvm::max_element (NFC) (PR #140435)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 17 22:27:27 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/140435.diff
4 Files Affected:
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-2)
- (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+1-1)
- (modified) clang/lib/Sema/SemaCUDA.cpp (+4-3)
- (modified) clang/utils/TableGen/ClangOptionDocEmitter.cpp (+2-3)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/140435
More information about the cfe-commits
mailing list