On Sun, Jun 12, 2022 at 10:17 AM Kazu Hirata via cfe-commits < cfe-commits@lists.llvm.org> wrote:
> > Author: Kazu Hirata > Date: 2022-06-12T10:17:12-07:00 > New Revision: f13019f8367a417075e70effb13dcf58024090b2 > > URL: > https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2 > DIFF: > https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2.diff > > LOG: [clang] Use any_of and none_of (NFC) > > Added: > > > Modified: > clang/include/clang/Basic/Attr.td > clang/lib/ExtractAPI/ExtractAPIConsumer.cpp > clang/lib/Sema/SemaDeclCXX.cpp > clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp > > Removed: > > > > > ################################################################################ > diff --git a/clang/include/clang/Basic/Attr.td > b/clang/include/clang/Basic/Attr.td > index d1f407259cb6e..16384969f68e4 100644 > --- a/clang/include/clang/Basic/Attr.td > +++ b/clang/include/clang/Basic/Attr.td > @@ -1926,9 +1926,9 @@ def NonNull : InheritableParamAttr { > bool isNonNull(unsigned IdxAST) const { > if (!args_size()) > return true; > - return args_end() != std::find_if( > - args_begin(), args_end(), > - [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; > }); > + return llvm::any_of(args(), [=](const ParamIdx &Idx) { > + return Idx.getASTIndex() == IdxAST; > + }); > Generally, I think for locally scoped lambdas (lambdas that don't escape their scope) we should prefer/default to default reference capture (`[&]`) - it simplifies changes in the future. Would that be OK for these sort of cleanups? > } > }]; > // FIXME: We should merge duplicates into a single nonnull attribute. > > diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp > b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp > index a7b0a1ac98a78..bffa66c2d9448 100644 > --- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp > +++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp > @@ -199,11 +199,11 @@ struct LocationFileChecker { > // Try to reduce the include name the same way we tried to include it. > bool IsQuoted = false; > if (auto IncludeName = getRelativeIncludeName(CI, FileName, > &IsQuoted)) > - if (llvm::find_if(KnownFiles, > - [&IsQuoted, &IncludeName](const auto &KnownFile) { > - return KnownFile.first.equals(*IncludeName) && > - KnownFile.second == IsQuoted; > - }) != KnownFiles.end()) { > + if (llvm::any_of(KnownFiles, > + [&IsQuoted, &IncludeName](const auto &KnownFile) { > + return KnownFile.first.equals(*IncludeName) && > + KnownFile.second == IsQuoted; > + })) { > KnownFileEntries.insert(File); > return true; > } > > diff --git a/clang/lib/Sema/SemaDeclCXX.cpp > b/clang/lib/Sema/SemaDeclCXX.cpp > index 569b226da9233..214332e53c0f0 100644 > --- a/clang/lib/Sema/SemaDeclCXX.cpp > +++ b/clang/lib/Sema/SemaDeclCXX.cpp > @@ -8617,10 +8617,10 @@ bool > Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD, > int(1))) > return true; > > - if (llvm::find_if(RD->friends(), [&](const FriendDecl *F) { > + if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) { > return FD->getCanonicalDecl() == > F->getFriendDecl()->getCanonicalDecl(); > - }) == RD->friends().end()) { > + })) { > Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend) > << int(DCK) << int(0) << RD; > Diag(RD->getCanonicalDecl()->getLocation(), diag::note_declared_at); > > diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp > b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp > index 528284ca89858..9ee6ef4f9519f 100644 > --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp > +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp > @@ -480,9 +480,7 @@ static void isOptionContainedIn(const > CmdLineOptionList &OptionList, > return Opt.OptionName == SuppliedOption; > }; > > - const auto *OptionIt = llvm::find_if(OptionList, SameOptName); > - > - if (OptionIt == OptionList.end()) { > + if (llvm::none_of(OptionList, SameOptName)) { > Diags.Report(diag::err_analyzer_checker_option_unknown) > << SuppliedChecker << SuppliedOption; > return; > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits