Skip to content

Commit 6d2a7b4

Browse files
[clang] Use llvm::find_if (NFC) (#140983)
1 parent 287294d commit 6d2a7b4

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,38 +236,34 @@ class FactSet {
236236
}
237237

238238
iterator findLockIter(FactManager &FM, const CapabilityExpr &CapE) {
239-
return std::find_if(begin(), end(), [&](FactID ID) {
240-
return FM[ID].matches(CapE);
241-
});
239+
return llvm::find_if(*this,
240+
[&](FactID ID) { return FM[ID].matches(CapE); });
242241
}
243242

244243
const FactEntry *findLock(FactManager &FM, const CapabilityExpr &CapE) const {
245-
auto I = std::find_if(begin(), end(), [&](FactID ID) {
246-
return FM[ID].matches(CapE);
247-
});
244+
auto I =
245+
llvm::find_if(*this, [&](FactID ID) { return FM[ID].matches(CapE); });
248246
return I != end() ? &FM[*I] : nullptr;
249247
}
250248

251249
const FactEntry *findLockUniv(FactManager &FM,
252250
const CapabilityExpr &CapE) const {
253-
auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
254-
return FM[ID].matchesUniv(CapE);
255-
});
251+
auto I = llvm::find_if(
252+
*this, [&](FactID ID) -> bool { return FM[ID].matchesUniv(CapE); });
256253
return I != end() ? &FM[*I] : nullptr;
257254
}
258255

259256
const FactEntry *findPartialMatch(FactManager &FM,
260257
const CapabilityExpr &CapE) const {
261-
auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
258+
auto I = llvm::find_if(*this, [&](FactID ID) -> bool {
262259
return FM[ID].partiallyMatches(CapE);
263260
});
264261
return I != end() ? &FM[*I] : nullptr;
265262
}
266263

267264
bool containsMutexDecl(FactManager &FM, const ValueDecl* Vd) const {
268-
auto I = std::find_if(begin(), end(), [&](FactID ID) -> bool {
269-
return FM[ID].valueDecl() == Vd;
270-
});
265+
auto I = llvm::find_if(
266+
*this, [&](FactID ID) -> bool { return FM[ID].valueDecl() == Vd; });
271267
return I != end();
272268
}
273269
};

clang/lib/Format/MacroCallReconstructor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ MacroCallReconstructor::createUnwrappedLine(const ReconstructedLine &Line,
518518
// If we only have one child, and the child is due to a macro expansion
519519
// (either attached to a left parenthesis or comma), merge the child into
520520
// the current line to prevent forced breaks for macro arguments.
521-
auto *Child = std::find_if(
522-
N->Children.begin(), N->Children.end(),
523-
[](const auto &Child) { return !Child->Tokens.empty(); });
521+
auto *Child = llvm::find_if(N->Children, [](const auto &Child) {
522+
return !Child->Tokens.empty();
523+
});
524524
auto Line = createUnwrappedLine(**Child, Level);
525525
Result.Tokens.splice(Result.Tokens.end(), Line.Tokens);
526526
} else if (NumChildren > 0) {

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,8 @@ static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD,
970970
QualType DecompType,
971971
ArrayRef<BindingDecl *> Bindings,
972972
unsigned MemberCount) {
973-
auto BindingWithPackItr =
974-
std::find_if(Bindings.begin(), Bindings.end(),
975-
[](BindingDecl *D) -> bool { return D->isParameterPack(); });
973+
auto BindingWithPackItr = llvm::find_if(
974+
Bindings, [](BindingDecl *D) -> bool { return D->isParameterPack(); });
976975
bool HasPack = BindingWithPackItr != Bindings.end();
977976
bool IsValid;
978977
if (!HasPack) {

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static Attr *handleCodeAlignAttr(Sema &S, Stmt *St, const ParsedAttr &A) {
395395
template <typename LoopAttrT>
396396
static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) {
397397
auto FindFunc = [](const Attr *A) { return isa<const LoopAttrT>(A); };
398-
const auto *FirstItr = std::find_if(Attrs.begin(), Attrs.end(), FindFunc);
398+
const auto *FirstItr = llvm::find_if(Attrs, FindFunc);
399399

400400
if (FirstItr == Attrs.end()) // no attributes found
401401
return;

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7689,8 +7689,8 @@ static bool checkMutualExclusion(TypeProcessingState &state,
76897689
const FunctionProtoType::ExtProtoInfo &EPI,
76907690
ParsedAttr &Attr,
76917691
AttributeCommonInfo::Kind OtherKind) {
7692-
auto OtherAttr = std::find_if(
7693-
state.getCurrentAttributes().begin(), state.getCurrentAttributes().end(),
7692+
auto OtherAttr = llvm::find_if(
7693+
state.getCurrentAttributes(),
76947694
[OtherKind](const ParsedAttr &A) { return A.getKind() == OtherKind; });
76957695
if (OtherAttr == state.getCurrentAttributes().end() || OtherAttr->isInvalid())
76967696
return false;

0 commit comments

Comments
 (0)