Use any_of (NFC)

This commit is contained in:
Kazu Hirata 2022-07-22 01:05:17 -07:00
parent bf268a05cd
commit 70257fab68
10 changed files with 25 additions and 34 deletions

View File

@ -49,13 +49,11 @@ void MacroRepeatedPPCallbacks::MacroExpands(const Token &MacroNameTok,
// Bail out if the contents of the macro are containing keywords that are
// making the macro too complex.
if (std::find_if(
MI->tokens().begin(), MI->tokens().end(), [](const Token &T) {
return T.isOneOf(tok::kw_if, tok::kw_else, tok::kw_switch,
tok::kw_case, tok::kw_break, tok::kw_while,
tok::kw_do, tok::kw_for, tok::kw_continue,
tok::kw_goto, tok::kw_return);
}) != MI->tokens().end())
if (llvm::any_of(MI->tokens(), [](const Token &T) {
return T.isOneOf(tok::kw_if, tok::kw_else, tok::kw_switch, tok::kw_case,
tok::kw_break, tok::kw_while, tok::kw_do, tok::kw_for,
tok::kw_continue, tok::kw_goto, tok::kw_return);
}))
return;
for (unsigned ArgNo = 0U; ArgNo < MI->getNumParams(); ++ArgNo) {

View File

@ -604,9 +604,9 @@ int clangTidyMain(int argc, const char **argv) {
std::vector<ClangTidyError> Errors =
runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
FixNotes, EnableCheckProfile, ProfilePrefix);
bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
}) != Errors.end();
bool FoundErrors = llvm::any_of(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
});
// --fix-errors and --fix-notes imply --fix.
FixBehaviour Behaviour = FixNotes ? FB_FixNotes

View File

@ -196,10 +196,9 @@ static bool prefer(const SymbolLocation &L, const SymbolLocation &R) {
return true;
auto HasCodeGenSuffix = [](const SymbolLocation &Loc) {
constexpr static const char *CodegenSuffixes[] = {".proto"};
return std::any_of(std::begin(CodegenSuffixes), std::end(CodegenSuffixes),
[&](llvm::StringRef Suffix) {
return llvm::StringRef(Loc.FileURI).endswith(Suffix);
});
return llvm::any_of(CodegenSuffixes, [&](llvm::StringRef Suffix) {
return llvm::StringRef(Loc.FileURI).endswith(Suffix);
});
};
return HasCodeGenSuffix(L) && !HasCodeGenSuffix(R);
}

View File

@ -456,10 +456,8 @@ static bool violatesPrivateInclude(Module *RequestingModule,
&Header.getModule()->Headers[Module::HK_Private],
&Header.getModule()->Headers[Module::HK_PrivateTextual]};
for (auto *Hs : HeaderList)
IsPrivate |=
std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {
return H.Entry == IncFileEnt;
}) != Hs->end();
IsPrivate |= llvm::any_of(
*Hs, [&](const Module::Header &H) { return H.Entry == IncFileEnt; });
assert(IsPrivate && "inconsistent headers and roles");
}
#endif

View File

@ -15400,7 +15400,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
pty->getKind() == BuiltinType::Overload)) {
auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
std::any_of(OE->decls_begin(), OE->decls_end(), [](NamedDecl *ND) {
llvm::any_of(OE->decls(), [](NamedDecl *ND) {
return isa<FunctionTemplateDecl>(ND);
})) {
Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()

View File

@ -2520,7 +2520,7 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
continue;
// Cannot make a deduction guide when unparsed arguments are present.
if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
if (llvm::any_of(CD->parameters(), [](ParmVarDecl *P) {
return !P || P->hasUnparsedDefaultArg();
}))
continue;

View File

@ -290,14 +290,12 @@ public:
bool needsRelocations() {
if (config->extendedConst)
return false;
return llvm::find_if(internalGotSymbols, [=](Symbol *sym) {
return !sym->isTLS();
}) != internalGotSymbols.end();
return llvm::any_of(internalGotSymbols,
[=](Symbol *sym) { return !sym->isTLS(); });
}
bool needsTLSRelocations() {
return llvm::find_if(internalGotSymbols, [=](Symbol *sym) {
return sym->isTLS();
}) != internalGotSymbols.end();
return llvm::any_of(internalGotSymbols,
[=](Symbol *sym) { return sym->isTLS(); });
}
void generateRelocationCode(raw_ostream &os, bool TLS) const;

View File

@ -133,9 +133,9 @@ public:
}
bool isPoisoned() const {
return BBGuards &&
std::any_of(BBGuards->begin(), BBGuards->end(),
[](const auto &BB) { return BB.second.isPoisoned(); });
return BBGuards && llvm::any_of(*BBGuards, [](const auto &BB) {
return BB.second.isPoisoned();
});
}
static void printDiff(raw_ostream &out, const CFG &Before,

View File

@ -321,9 +321,8 @@ unsigned FlatAffineValueConstraints::insertVar(VarKind kind, unsigned pos,
}
bool FlatAffineValueConstraints::hasValues() const {
return llvm::find_if(values, [](Optional<Value> var) {
return var.has_value();
}) != values.end();
return llvm::any_of(
values, [](const Optional<Value> &var) { return var.has_value(); });
}
/// Checks if two constraint systems are in the same space, i.e., if they are

View File

@ -697,8 +697,7 @@ isl::set ScopBuilder::getPredecessorDomainConstraints(BasicBlock *BB,
// If the predecessor is in a region we used for propagation we can skip it.
auto PredBBInRegion = [PredBB](Region *PR) { return PR->contains(PredBB); };
if (std::any_of(PropagatedRegions.begin(), PropagatedRegions.end(),
PredBBInRegion)) {
if (llvm::any_of(PropagatedRegions, PredBBInRegion)) {
continue;
}