Skip to content

[clang] Use llvm::find_if (NFC) #140983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions clang/lib/Analysis/ThreadSafety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Format/MacroCallReconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaStmtAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down