llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) <details> <summary>Changes</summary> llvm::is_contained is shorter than llvm::all_of plus a lambda. --- Full diff: https://github.com/llvm/llvm-project/pull/145843.diff 7 Files Affected: - (modified) clang/lib/AST/ExprCXX.cpp (+1-1) - (modified) clang/lib/AST/StmtOpenACC.cpp (+1-1) - (modified) clang/lib/Analysis/FlowSensitive/CNFFormula.cpp (+2-3) - (modified) clang/lib/Basic/Attributes.cpp (+2-4) - (modified) clang/lib/Driver/ToolChains/Arch/LoongArch.cpp (+5-5) - (modified) clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp (+1-2) - (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+1-2) ``````````diff diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 063eb1738a046..764e20a54dc89 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1208,7 +1208,7 @@ CXXConstructExpr::CXXConstructExpr( Stmt **TrailingArgs = getTrailingArgs(); llvm::copy(Args, TrailingArgs); - assert(llvm::all_of(Args, [](const Stmt *Arg) { return Arg != nullptr; })); + assert(!llvm::is_contained(Args, nullptr)); // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo. if (SC == CXXConstructExprClass) diff --git a/clang/lib/AST/StmtOpenACC.cpp b/clang/lib/AST/StmtOpenACC.cpp index bc5072187b891..07e3de8eeb00d 100644 --- a/clang/lib/AST/StmtOpenACC.cpp +++ b/clang/lib/AST/StmtOpenACC.cpp @@ -209,7 +209,7 @@ OpenACCWaitConstruct *OpenACCWaitConstruct::Create( ArrayRef<Expr *> QueueIdExprs, SourceLocation RParenLoc, SourceLocation End, ArrayRef<const OpenACCClause *> Clauses) { - assert(llvm::all_of(QueueIdExprs, [](Expr *E) { return E != nullptr; })); + assert(!llvm::is_contained(QueueIdExprs, nullptr)); void *Mem = C.Allocate( OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>( diff --git a/clang/lib/Analysis/FlowSensitive/CNFFormula.cpp b/clang/lib/Analysis/FlowSensitive/CNFFormula.cpp index 39c46d73e9dda..d067e4ee6b001 100644 --- a/clang/lib/Analysis/FlowSensitive/CNFFormula.cpp +++ b/clang/lib/Analysis/FlowSensitive/CNFFormula.cpp @@ -49,8 +49,7 @@ struct CNFFormulaBuilder { // Contains literals of the simplified clause. llvm::SmallVector<Literal> Simplified; for (auto L : Literals) { - assert(L != NullLit && - llvm::all_of(Simplified, [L](Literal S) { return S != L; })); + assert(L != NullLit && !llvm::is_contained(Simplified, L)); auto X = var(L); if (trueVars.contains(X)) { // X must be true if (isPosLit(L)) @@ -103,7 +102,7 @@ CNFFormula::CNFFormula(Variable LargestVar) } void CNFFormula::addClause(ArrayRef<Literal> lits) { - assert(llvm::all_of(lits, [](Literal L) { return L != NullLit; })); + assert(!llvm::is_contained(lits, NullLit)); if (lits.empty()) KnownContradictory = true; diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index 004e5209a44a7..81b186f844b8a 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -260,8 +260,7 @@ static constexpr const char *AttrScopeSpellingList[] = { std::optional<StringRef> AttributeCommonInfo::tryGetCorrectedScopeName(StringRef ScopeName) const { if (ScopeName.size() > 0 && - llvm::none_of(AttrScopeSpellingList, - [&](const char *S) { return S == ScopeName; })) { + !llvm::is_contained(AttrScopeSpellingList, ScopeName)) { SimpleTypoCorrection STC(ScopeName); for (const auto &Scope : AttrScopeSpellingList) STC.add(Scope); @@ -275,8 +274,7 @@ AttributeCommonInfo::tryGetCorrectedScopeName(StringRef ScopeName) const { std::optional<StringRef> AttributeCommonInfo::tryGetCorrectedAttrName( StringRef ScopeName, StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts) const { - if (llvm::none_of(AttrSpellingList, - [&](const char *A) { return A == AttrName; })) { + if (!llvm::is_contained(AttrSpellingList, AttrName)) { SimpleTypoCorrection STC(AttrName); for (const auto &Attr : AttrSpellingList) STC.add(Attr); diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp index 33a655870b01b..ee7b0d10c24ba 100644 --- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp +++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp @@ -214,16 +214,16 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D, if (MSIMD == "lsx") { // Option -msimd=lsx depends on 64-bit FPU. // -m*-float and -mfpu=none/0/32 conflict with -msimd=lsx. - if (llvm::find(Features, "-d") != Features.end()) + if (llvm::is_contained(Features, "-d")) D.Diag(diag::err_drv_loongarch_wrong_fpu_width) << /*LSX*/ 0; else Features.push_back("+lsx"); } else if (MSIMD == "lasx") { // Option -msimd=lasx depends on 64-bit FPU and LSX. // -m*-float, -mfpu=none/0/32 and -mno-lsx conflict with -msimd=lasx. - if (llvm::find(Features, "-d") != Features.end()) + if (llvm::is_contained(Features, "-d")) D.Diag(diag::err_drv_loongarch_wrong_fpu_width) << /*LASX*/ 1; - else if (llvm::find(Features, "-lsx") != Features.end()) + else if (llvm::is_contained(Features, "-lsx")) D.Diag(diag::err_drv_loongarch_invalid_simd_option_combination); // The command options do not contain -mno-lasx. @@ -232,9 +232,9 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D, Features.push_back("+lasx"); } } else if (MSIMD == "none") { - if (llvm::find(Features, "+lsx") != Features.end()) + if (llvm::is_contained(Features, "+lsx")) Features.push_back("-lsx"); - if (llvm::find(Features, "+lasx") != Features.end()) + if (llvm::is_contained(Features, "+lasx")) Features.push_back("-lasx"); } else { D.Diag(diag::err_drv_loongarch_invalid_msimd_EQ) << MSIMD; diff --git a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp index 683d9070b1dcf..1cdb5397aa577 100644 --- a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp +++ b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp @@ -299,8 +299,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) { ScanTool.getDependencyFile(CommandLine, CWD).moveInto(DepFile), llvm::Failed()); - EXPECT_TRUE(llvm::find(InterceptFS->StatPaths, OtherPath) == - InterceptFS->StatPaths.end()); + EXPECT_TRUE(!llvm::is_contained(InterceptFS->StatPaths, OtherPath)); EXPECT_EQ(InterceptFS->ReadFiles, std::vector<std::string>{"test.m"}); } diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index b28cb2c09ac5c..17078e2bc1505 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1657,8 +1657,7 @@ void clang::EmitClangDiagsEnums(const RecordKeeper &Records, raw_ostream &OS, llvm::SmallVector<std::string> EnumeratorNames; for (auto &Enumerator : Enumeration.second) { - if (llvm::find(EnumeratorNames, Enumerator.second) != - EnumeratorNames.end()) + if (llvm::is_contained(EnumeratorNames, Enumerator.second)) PrintError(&R, "Duplicate enumerator name '" + Enumerator.second + "'"); EnumeratorNames.push_back(Enumerator.second); `````````` </details> https://github.com/llvm/llvm-project/pull/145843 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits