<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 12, 2022 at 10:17 AM Kazu Hirata via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Kazu Hirata<br>
Date: 2022-06-12T10:17:12-07:00<br>
New Revision: f13019f8367a417075e70effb13dcf58024090b2<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2.diff</a><br>
<br>
LOG: [clang] Use any_of and none_of (NFC)<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
clang/include/clang/Basic/Attr.td<br>
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp<br>
clang/lib/Sema/SemaDeclCXX.cpp<br>
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td<br>
index d1f407259cb6e..16384969f68e4 100644<br>
--- a/clang/include/clang/Basic/Attr.td<br>
+++ b/clang/include/clang/Basic/Attr.td<br>
@@ -1926,9 +1926,9 @@ def NonNull : InheritableParamAttr {<br>
bool isNonNull(unsigned IdxAST) const {<br>
if (!args_size())<br>
return true;<br>
- return args_end() != std::find_if(<br>
- args_begin(), args_end(),<br>
- [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });<br>
+ return llvm::any_of(args(), [=](const ParamIdx &Idx) {<br>
+ return Idx.getASTIndex() == IdxAST;<br>
+ });<br></blockquote><div><br>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?<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
}<br>
}];<br>
// FIXME: We should merge duplicates into a single nonnull attribute.<br>
<br>
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp<br>
index a7b0a1ac98a78..bffa66c2d9448 100644<br>
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp<br>
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp<br>
@@ -199,11 +199,11 @@ struct LocationFileChecker {<br>
// Try to reduce the include name the same way we tried to include it.<br>
bool IsQuoted = false;<br>
if (auto IncludeName = getRelativeIncludeName(CI, FileName, &IsQuoted))<br>
- if (llvm::find_if(KnownFiles,<br>
- [&IsQuoted, &IncludeName](const auto &KnownFile) {<br>
- return KnownFile.first.equals(*IncludeName) &&<br>
- KnownFile.second == IsQuoted;<br>
- }) != KnownFiles.end()) {<br>
+ if (llvm::any_of(KnownFiles,<br>
+ [&IsQuoted, &IncludeName](const auto &KnownFile) {<br>
+ return KnownFile.first.equals(*IncludeName) &&<br>
+ KnownFile.second == IsQuoted;<br>
+ })) {<br>
KnownFileEntries.insert(File);<br>
return true;<br>
}<br>
<br>
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp<br>
index 569b226da9233..214332e53c0f0 100644<br>
--- a/clang/lib/Sema/SemaDeclCXX.cpp<br>
+++ b/clang/lib/Sema/SemaDeclCXX.cpp<br>
@@ -8617,10 +8617,10 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,<br>
int(1)))<br>
return true;<br>
<br>
- if (llvm::find_if(RD->friends(), [&](const FriendDecl *F) {<br>
+ if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {<br>
return FD->getCanonicalDecl() ==<br>
F->getFriendDecl()->getCanonicalDecl();<br>
- }) == RD->friends().end()) {<br>
+ })) {<br>
Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)<br>
<< int(DCK) << int(0) << RD;<br>
Diag(RD->getCanonicalDecl()->getLocation(), diag::note_declared_at);<br>
<br>
diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp<br>
index 528284ca89858..9ee6ef4f9519f 100644<br>
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp<br>
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp<br>
@@ -480,9 +480,7 @@ static void isOptionContainedIn(const CmdLineOptionList &OptionList,<br>
return Opt.OptionName == SuppliedOption;<br>
};<br>
<br>
- const auto *OptionIt = llvm::find_if(OptionList, SameOptName);<br>
-<br>
- if (OptionIt == OptionList.end()) {<br>
+ if (llvm::none_of(OptionList, SameOptName)) {<br>
Diags.Report(diag::err_analyzer_checker_option_unknown)<br>
<< SuppliedChecker << SuppliedOption;<br>
return;<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>