[clang] Use any_of and none_of (NFC)

This commit is contained in:
Kazu Hirata 2022-06-12 10:17:12 -07:00
parent b8d728a098
commit f13019f836
4 changed files with 11 additions and 13 deletions

View File

@ -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;
});
}
}];
// FIXME: We should merge duplicates into a single nonnull attribute.

View File

@ -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;
}

View File

@ -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);

View File

@ -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;