Skip to content

Commit

Permalink
Use any_of (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jul 22, 2022
1 parent bf268a0 commit 70257fa
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions clang-tools-extra/clangd/index/Merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Lex/ModuleMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions lld/wasm/SyntheticSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,12 @@ class GlobalSection : public SyntheticSection {
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;

Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/Passes/StandardInstrumentations.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class PreservedCFGCheckerInstrumentation {
}

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,
Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions polly/lib/Analysis/ScopBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 70257fa

Please sign in to comment.