From 12b29900a106ed1d7b146b5d8f79f32bbbbd7c59 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 30 Jul 2022 10:35:56 -0700 Subject: [PATCH] Use any_of (NFC) --- bolt/lib/Rewrite/RewriteInstance.cpp | 8 +++----- .../clang-tidy/bugprone/ParentVirtualCallCheck.cpp | 11 +++++------ clang-tools-extra/clangd/HeaderSourceSwitch.cpp | 16 ++++++---------- llvm/lib/CodeGen/SwiftErrorValueTracking.cpp | 5 ++--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 7 ++++--- llvm/tools/llvm-tapi-diff/DiffEngine.cpp | 20 ++++++++++---------- 6 files changed, 30 insertions(+), 37 deletions(-) diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index 07412b7..40aaba0 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -301,11 +301,9 @@ MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch, namespace { bool refersToReorderedSection(ErrorOr Section) { - auto Itr = - llvm::find_if(opts::ReorderData, [&](const std::string &SectionName) { - return (Section && Section->getName() == SectionName); - }); - return Itr != opts::ReorderData.end(); + return llvm::any_of(opts::ReorderData, [&](const std::string &SectionName) { + return Section && Section->getName() == SectionName; + }); } } // anonymous namespace diff --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp index 8f21678..3b8d205 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp @@ -28,12 +28,11 @@ static bool isParentOf(const CXXRecordDecl &Parent, if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl()) return true; const CXXRecordDecl *ParentCanonicalDecl = Parent.getCanonicalDecl(); - return ThisClass.bases_end() != - llvm::find_if(ThisClass.bases(), [=](const CXXBaseSpecifier &Base) { - auto *BaseDecl = Base.getType()->getAsCXXRecordDecl(); - assert(BaseDecl); - return ParentCanonicalDecl == BaseDecl->getCanonicalDecl(); - }); + return llvm::any_of(ThisClass.bases(), [=](const CXXBaseSpecifier &Base) { + auto *BaseDecl = Base.getType()->getAsCXXRecordDecl(); + assert(BaseDecl); + return ParentCanonicalDecl == BaseDecl->getCanonicalDecl(); + }); } static BasesVector getParentsByGrandParent(const CXXRecordDecl &GrandParent, diff --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp index b5f8bc9..039457d 100644 --- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp +++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp @@ -26,17 +26,13 @@ llvm::Optional getCorrespondingHeaderOrSource( llvm::StringRef PathExt = llvm::sys::path::extension(OriginalFile); // Lookup in a list of known extensions. - auto *SourceIter = - llvm::find_if(SourceExtensions, [&PathExt](PathRef SourceExt) { - return SourceExt.equals_insensitive(PathExt); - }); - bool IsSource = SourceIter != std::end(SourceExtensions); + bool IsSource = llvm::any_of(SourceExtensions, [&PathExt](PathRef SourceExt) { + return SourceExt.equals_insensitive(PathExt); + }); - auto *HeaderIter = - llvm::find_if(HeaderExtensions, [&PathExt](PathRef HeaderExt) { - return HeaderExt.equals_insensitive(PathExt); - }); - bool IsHeader = HeaderIter != std::end(HeaderExtensions); + bool IsHeader = llvm::any_of(HeaderExtensions, [&PathExt](PathRef HeaderExt) { + return HeaderExt.equals_insensitive(PathExt); + }); // We can only switch between the known extensions. if (!IsSource && !IsHeader) diff --git a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp index 2282d53..83a7063 100644 --- a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp +++ b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp @@ -202,11 +202,10 @@ void SwiftErrorValueTracking::propagateVRegs() { // downward defs. bool needPHI = VRegs.size() >= 1 && - llvm::find_if( + llvm::any_of( VRegs, [&](const std::pair &V) - -> bool { return V.second != VRegs[0].second; }) != - VRegs.end(); + -> bool { return V.second != VRegs[0].second; }); // If there is no upwards exposed used and we don't need a phi just // forward the swifterror vreg from the predecessor(s). diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index b78d68e..ef2edf2 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -9851,9 +9851,10 @@ static bool isEXTMask(ArrayRef M, EVT VT, bool &ReverseEXT, APInt ExpectedElt = APInt(MaskBits, *FirstRealElt + 1); // The following shuffle indices must be the successive elements after the // first real element. - const int *FirstWrongElt = std::find_if(FirstRealElt + 1, M.end(), - [&](int Elt) {return Elt != ExpectedElt++ && Elt != -1;}); - if (FirstWrongElt != M.end()) + bool FoundWrongElt = std::any_of(FirstRealElt + 1, M.end(), [&](int Elt) { + return Elt != ExpectedElt++ && Elt != -1; + }); + if (FoundWrongElt) return false; // The index of an EXT is the first element if it is not UNDEF. diff --git a/llvm/tools/llvm-tapi-diff/DiffEngine.cpp b/llvm/tools/llvm-tapi-diff/DiffEngine.cpp index 20f1dbc..9ebaadb 100644 --- a/llvm/tools/llvm-tapi-diff/DiffEngine.cpp +++ b/llvm/tools/llvm-tapi-diff/DiffEngine.cpp @@ -235,11 +235,11 @@ void findAndAddDiff(const std::vector &CollectedIRefVec, Result.Kind = AD_Str_Vec; for (const auto &IRef : CollectedIRefVec) for (auto Targ : IRef.targets()) { - auto FoundIRef = llvm::find_if(LookupIRefVec, [&](const auto LIRef) { + auto FoundIRef = llvm::any_of(LookupIRefVec, [&](const auto LIRef) { return llvm::is_contained(LIRef.targets(), Targ) && IRef.getInstallName() == LIRef.getInstallName(); }); - if (FoundIRef == LookupIRefVec.end()) + if (!FoundIRef) addDiffForTargSlice>( IRef.getInstallName(), Targ, Result, Order); @@ -266,13 +266,13 @@ void findAndAddDiff(InterfaceFile::const_symbol_range CollectedSyms, Result.Kind = AD_Sym_Vec; for (const auto *Sym : CollectedSyms) for (const auto Targ : Sym->targets()) { - auto FoundSym = llvm::find_if(LookupSyms, [&](const auto LSym) { - return Sym->getName() == LSym->getName() && - Sym->getKind() == LSym->getKind() && - Sym->getFlags() == LSym->getFlags() && - llvm::is_contained(LSym->targets(), Targ); + auto FoundSym = llvm::any_of(LookupSyms, [&](const auto LSym) { + return (Sym->getName() == LSym->getName() && + Sym->getKind() == LSym->getKind() && + Sym->getFlags() == LSym->getFlags() && + llvm::is_contained(LSym->targets(), Targ)); }); - if (FoundSym == LookupSyms.end()) + if (!FoundSym) addDiffForTargSlice(Sym, Targ, Result, Order); } } @@ -408,10 +408,10 @@ DiffEngine::findDifferences(const InterfaceFile *IFLHS, } for (auto DocRHS : IFRHS->documents()) { auto WasGathered = - llvm::find_if(DocsInserted, [&](const auto &GatheredDoc) { + llvm::any_of(DocsInserted, [&](const auto &GatheredDoc) { return (GatheredDoc == DocRHS->getInstallName()); }); - if (WasGathered == DocsInserted.end()) + if (!WasGathered) Docs.Values.push_back(std::make_unique(InlineDoc( DocRHS->getInstallName(), getSingleIF(DocRHS.get(), rhs)))); } -- 2.7.4