[clang] [clang] Use llvm::find_if (NFC) (PR #140983)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 21 19:21:22 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/140983.diff
5 Files Affected:
- (modified) clang/lib/Analysis/ThreadSafety.cpp (+9-13)
- (modified) clang/lib/Format/MacroCallReconstructor.cpp (+3-3)
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+2-3)
- (modified) clang/lib/Sema/SemaStmtAttr.cpp (+1-1)
- (modified) clang/lib/Sema/SemaType.cpp (+2-2)
``````````diff
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 156df51a71012..528fd09958578 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -236,38 +236,34 @@ class FactSet {
}
iterator findLockIter(FactManager &FM, const CapabilityExpr &CapE) {
- return std::find_if(begin(), end(), [&](FactID ID) {
- return FM[ID].matches(CapE);
- });
+ return llvm::find_if(*this,
+ [&](FactID ID) { return FM[ID].matches(CapE); });
}
const FactEntry *findLock(FactManager &FM, const CapabilityExpr &CapE) const {
- auto I = std::find_if(begin(), end(), [&](FactID ID) {
- return FM[ID].matches(CapE);
- });
+ auto I =
+ llvm::find_if(*this, [&](FactID ID) { return FM[ID].matches(CapE); });
return I != end() ? &FM[*I] : nullptr;
}
const FactEntry *findLockUniv(FactManager &FM,
const CapabilityExpr &CapE) const {
- auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
- return FM[ID].matchesUniv(CapE);
- });
+ auto I = llvm::find_if(
+ *this, [&](FactID ID) -> bool { return FM[ID].matchesUniv(CapE); });
return I != end() ? &FM[*I] : nullptr;
}
const FactEntry *findPartialMatch(FactManager &FM,
const CapabilityExpr &CapE) const {
- auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
+ auto I = llvm::find_if(*this, [&](FactID ID) -> bool {
return FM[ID].partiallyMatches(CapE);
});
return I != end() ? &FM[*I] : nullptr;
}
bool containsMutexDecl(FactManager &FM, const ValueDecl* Vd) const {
- auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
- return FM[ID].valueDecl() == Vd;
- });
+ auto I = llvm::find_if(
+ *this, [&](FactID ID) -> bool { return FM[ID].valueDecl() == Vd; });
return I != end();
}
};
diff --git a/clang/lib/Format/MacroCallReconstructor.cpp b/clang/lib/Format/MacroCallReconstructor.cpp
index f69a6aabc7d47..c9b618c6cb5b0 100644
--- a/clang/lib/Format/MacroCallReconstructor.cpp
+++ b/clang/lib/Format/MacroCallReconstructor.cpp
@@ -518,9 +518,9 @@ MacroCallReconstructor::createUnwrappedLine(const ReconstructedLine &Line,
// If we only have one child, and the child is due to a macro expansion
// (either attached to a left parenthesis or comma), merge the child into
// the current line to prevent forced breaks for macro arguments.
- auto *Child = std::find_if(
- N->Children.begin(), N->Children.end(),
- [](const auto &Child) { return !Child->Tokens.empty(); });
+ auto *Child = llvm::find_if(N->Children, [](const auto &Child) {
+ return !Child->Tokens.empty();
+ });
auto Line = createUnwrappedLine(**Child, Level);
Result.Tokens.splice(Result.Tokens.end(), Line.Tokens);
} else if (NumChildren > 0) {
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1bd9056cad812..fe92191b6a687 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -970,9 +970,8 @@ static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD,
QualType DecompType,
ArrayRef<BindingDecl *> Bindings,
unsigned MemberCount) {
- auto BindingWithPackItr =
- std::find_if(Bindings.begin(), Bindings.end(),
- [](BindingDecl *D) -> bool { return D->isParameterPack(); });
+ auto BindingWithPackItr = llvm::find_if(
+ Bindings, [](BindingDecl *D) -> bool { return D->isParameterPack(); });
bool HasPack = BindingWithPackItr != Bindings.end();
bool IsValid;
if (!HasPack) {
diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index cf1c597e90596..17da5fd8325be 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -395,7 +395,7 @@ static Attr *handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A) {
template <typename LoopAttrT>
static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) {
auto FindFunc = [](const Attr *A) { return isa<const LoopAttrT>(A); };
- const auto *FirstItr = std::find_if(Attrs.begin(), Attrs.end(), FindFunc);
+ const auto *FirstItr = llvm::find_if(Attrs, FindFunc);
if (FirstItr == Attrs.end()) // no attributes found
return;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 28d441234262b..3a618fd74276c 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7689,8 +7689,8 @@ static bool checkMutualExclusion(TypeProcessingState &state,
const FunctionProtoType::ExtProtoInfo &EPI,
ParsedAttr &Attr,
AttributeCommonInfo::Kind OtherKind) {
- auto OtherAttr = std::find_if(
- state.getCurrentAttributes().begin(), state.getCurrentAttributes().end(),
+ auto OtherAttr = llvm::find_if(
+ state.getCurrentAttributes(),
[OtherKind](const ParsedAttr &A) { return A.getKind() == OtherKind; });
if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/140983
More information about the cfe-commits
mailing list