Skip to content

Commit

Permalink
Use any_of (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jul 30, 2022
1 parent 16eaead commit 12b2990
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 37 deletions.
8 changes: 3 additions & 5 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,9 @@ MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
namespace {

bool refersToReorderedSection(ErrorOr<BinarySection &> 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
Expand Down
11 changes: 5 additions & 6 deletions clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 6 additions & 10 deletions clang-tools-extra/clangd/HeaderSourceSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ llvm::Optional<Path> 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)
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ void SwiftErrorValueTracking::propagateVRegs() {
// downward defs.
bool needPHI =
VRegs.size() >= 1 &&
llvm::find_if(
llvm::any_of(
VRegs,
[&](const std::pair<const MachineBasicBlock *, Register> &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).
Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9851,9 +9851,10 @@ static bool isEXTMask(ArrayRef<int> 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.
Expand Down
20 changes: 10 additions & 10 deletions llvm/tools/llvm-tapi-diff/DiffEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ void findAndAddDiff(const std::vector<InterfaceFileRef> &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<DiffStrVec,
DiffScalarVal<StringRef, AD_Diff_Scalar_Str>>(
IRef.getInstallName(), Targ, Result, Order);
Expand All @@ -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<DiffSymVec, SymScalar>(Sym, Targ, Result, Order);
}
}
Expand Down Expand Up @@ -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>(InlineDoc(
DocRHS->getInstallName(), getSingleIF(DocRHS.get(), rhs))));
}
Expand Down

0 comments on commit 12b2990

Please sign in to comment.