Use llvm::none_of (NFC)

This commit is contained in:
Kazu Hirata 2022-08-14 16:25:39 -07:00
parent 55f0a87ea4
commit f5a68feab3
10 changed files with 25 additions and 30 deletions

View File

@ -920,8 +920,7 @@ void ClangMoveTool::onEndOfTranslationUnit() {
return false; return false;
} }
}; };
if (std::none_of(UnremovedDeclsInOldHeader.begin(), if (llvm::none_of(UnremovedDeclsInOldHeader, IsSupportedKind) &&
UnremovedDeclsInOldHeader.end(), IsSupportedKind) &&
!Context->Spec.OldHeader.empty()) { !Context->Spec.OldHeader.empty()) {
auto &SM = RemovedDecls[0]->getASTContext().getSourceManager(); auto &SM = RemovedDecls[0]->getASTContext().getSourceManager();
moveAll(SM, Context->Spec.OldHeader, Context->Spec.NewHeader); moveAll(SM, Context->Spec.OldHeader, Context->Spec.NewHeader);

View File

@ -757,12 +757,12 @@ llvm::Expected<RenameResult> rename(const RenameInputs &RInputs) {
return StartOffset.takeError(); return StartOffset.takeError();
if (!EndOffset) if (!EndOffset)
return EndOffset.takeError(); return EndOffset.takeError();
if (llvm::find_if( if (llvm::none_of(
*MainFileRenameEdit, *MainFileRenameEdit,
[&StartOffset, &EndOffset](const clang::tooling::Replacement &R) { [&StartOffset, &EndOffset](const clang::tooling::Replacement &R) {
return R.getOffset() == *StartOffset && return R.getOffset() == *StartOffset &&
R.getLength() == *EndOffset - *StartOffset; R.getLength() == *EndOffset - *StartOffset;
}) == MainFileRenameEdit->end()) { })) {
return makeError(ReasonToReject::NoSymbolFound); return makeError(ReasonToReject::NoSymbolFound);
} }
RenameResult Result; RenameResult Result;

View File

@ -332,8 +332,7 @@ static void selectInterestingSourceRegion(std::string &SourceLine,
return; return;
// No special characters are allowed in CaretLine. // No special characters are allowed in CaretLine.
assert(CaretLine.end() == assert(llvm::none_of(CaretLine, [](char c) { return c < ' ' || '~' < c; }));
llvm::find_if(CaretLine, [](char c) { return c < ' ' || '~' < c; }));
// Find the slice that we need to display the full caret line // Find the slice that we need to display the full caret line
// correctly. // correctly.

View File

@ -844,8 +844,7 @@ void ProducersSection::addInfo(const WasmProducerInfo &info) {
{std::make_pair(&info.Languages, &languages), {std::make_pair(&info.Languages, &languages),
std::make_pair(&info.Tools, &tools), std::make_pair(&info.SDKs, &sDKs)}) std::make_pair(&info.Tools, &tools), std::make_pair(&info.SDKs, &sDKs)})
for (auto &producer : *producers.first) for (auto &producer : *producers.first)
if (producers.second->end() == if (llvm::none_of(*producers.second,
llvm::find_if(*producers.second,
[&](std::pair<std::string, std::string> seen) { [&](std::pair<std::string, std::string> seen) {
return seen.first == producer.first; return seen.first == producer.first;
})) }))

View File

@ -390,10 +390,10 @@ void RegionBase<Tr>::transferChildrenTo(RegionT *To) {
template <class Tr> template <class Tr>
void RegionBase<Tr>::addSubRegion(RegionT *SubRegion, bool moveChildren) { void RegionBase<Tr>::addSubRegion(RegionT *SubRegion, bool moveChildren) {
assert(!SubRegion->parent && "SubRegion already has a parent!"); assert(!SubRegion->parent && "SubRegion already has a parent!");
assert(llvm::find_if(*this, assert(llvm::none_of(*this,
[&](const std::unique_ptr<RegionT> &R) { [&](const std::unique_ptr<RegionT> &R) {
return R.get() == SubRegion; return R.get() == SubRegion;
}) == children.end() && }) &&
"Subregion already exists!"); "Subregion already exists!");
SubRegion->parent = static_cast<RegionT *>(this); SubRegion->parent = static_cast<RegionT *>(this);

View File

@ -1004,10 +1004,10 @@ public:
/// Create a section with the given name, protection flags, and alignment. /// Create a section with the given name, protection flags, and alignment.
Section &createSection(StringRef Name, MemProt Prot) { Section &createSection(StringRef Name, MemProt Prot) {
assert(llvm::find_if(Sections, assert(llvm::none_of(Sections,
[&](std::unique_ptr<Section> &Sec) { [&](std::unique_ptr<Section> &Sec) {
return Sec->getName() == Name; return Sec->getName() == Name;
}) == Sections.end() && }) &&
"Duplicate section name"); "Duplicate section name");
std::unique_ptr<Section> Sec(new Section(Name, Prot, Sections.size())); std::unique_ptr<Section> Sec(new Section(Name, Prot, Sections.size()));
Sections.push_back(std::move(Sec)); Sections.push_back(std::move(Sec));
@ -1349,9 +1349,8 @@ public:
assert(ExternalSymbols.count(&Sym) && "Symbol is not in the externals set"); assert(ExternalSymbols.count(&Sym) && "Symbol is not in the externals set");
ExternalSymbols.erase(&Sym); ExternalSymbols.erase(&Sym);
Addressable &Base = *Sym.Base; Addressable &Base = *Sym.Base;
assert(llvm::find_if(ExternalSymbols, assert(llvm::none_of(ExternalSymbols,
[&](Symbol *AS) { return AS->Base == &Base; }) == [&](Symbol *AS) { return AS->Base == &Base; }) &&
ExternalSymbols.end() &&
"Base addressable still in use"); "Base addressable still in use");
destroySymbol(Sym); destroySymbol(Sym);
destroyAddressable(Base); destroyAddressable(Base);
@ -1365,9 +1364,8 @@ public:
"Symbol is not in the absolute symbols set"); "Symbol is not in the absolute symbols set");
AbsoluteSymbols.erase(&Sym); AbsoluteSymbols.erase(&Sym);
Addressable &Base = *Sym.Base; Addressable &Base = *Sym.Base;
assert(llvm::find_if(ExternalSymbols, assert(llvm::none_of(ExternalSymbols,
[&](Symbol *AS) { return AS->Base == &Base; }) == [&](Symbol *AS) { return AS->Base == &Base; }) &&
ExternalSymbols.end() &&
"Base addressable still in use"); "Base addressable still in use");
destroySymbol(Sym); destroySymbol(Sym);
destroyAddressable(Base); destroyAddressable(Base);

View File

@ -712,7 +712,7 @@ struct SemiNCAInfo {
assert(IsPostDom && "This function is only for postdominators"); assert(IsPostDom && "This function is only for postdominators");
// The tree has only trivial roots -- nothing to update. // The tree has only trivial roots -- nothing to update.
if (std::none_of(DT.Roots.begin(), DT.Roots.end(), [BUI](const NodePtr N) { if (llvm::none_of(DT.Roots, [BUI](const NodePtr N) {
return HasForwardSuccessors(N, BUI); return HasForwardSuccessors(N, BUI);
})) }))
return; return;

View File

@ -7754,14 +7754,14 @@ static bool tryUnmergingGEPsAcrossIndirectBr(GetElementPtrInst *GEPI,
return false; return false;
// Check that GEP is used outside the block, meaning it's alive on the // Check that GEP is used outside the block, meaning it's alive on the
// IndirectBr edge(s). // IndirectBr edge(s).
if (find_if(GEPI->users(), [&](User *Usr) { if (llvm::none_of(GEPI->users(), [&](User *Usr) {
if (auto *I = dyn_cast<Instruction>(Usr)) { if (auto *I = dyn_cast<Instruction>(Usr)) {
if (I->getParent() != SrcBlock) { if (I->getParent() != SrcBlock) {
return true; return true;
} }
} }
return false; return false;
}) == GEPI->users().end()) }))
return false; return false;
// The second elements of the GEP chains to be unmerged. // The second elements of the GEP chains to be unmerged.
std::vector<GetElementPtrInst *> UGEPIs; std::vector<GetElementPtrInst *> UGEPIs;

View File

@ -412,11 +412,11 @@ static MDNode *stripDebugLocFromLoopID(MDNode *N) {
// MDNode. This loop also initializes DILocationReachable, later // MDNode. This loop also initializes DILocationReachable, later
// needed by updateLoopMetadataDebugLocationsImpl; the use of // needed by updateLoopMetadataDebugLocationsImpl; the use of
// count_if avoids an early exit. // count_if avoids an early exit.
if (!std::count_if(N->op_begin() + 1, N->op_end(), if (llvm::none_of(llvm::drop_begin(N->operands()),
[&Visited, &DILocationReachable](const MDOperand &Op) { [&Visited, &DILocationReachable](const MDOperand &Op) {
return isDILocationReachable( return isDILocationReachable(Visited, DILocationReachable,
Visited, DILocationReachable, Op.get()); Op.get());
})) }))
return N; return N;
// If there is only the debug location without any actual loop metadata, we // If there is only the debug location without any actual loop metadata, we

View File

@ -39,8 +39,8 @@ static void emitSCSPrologue(MachineFunction &MF, MachineBasicBlock &MBB,
// Do not save RA to the SCS if it's not saved to the regular stack, // Do not save RA to the SCS if it's not saved to the regular stack,
// i.e. RA is not at risk of being overwritten. // i.e. RA is not at risk of being overwritten.
std::vector<CalleeSavedInfo> &CSI = MF.getFrameInfo().getCalleeSavedInfo(); std::vector<CalleeSavedInfo> &CSI = MF.getFrameInfo().getCalleeSavedInfo();
if (std::none_of(CSI.begin(), CSI.end(), if (llvm::none_of(
[&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; })) CSI, [&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; }))
return; return;
Register SCSPReg = RISCVABI::getSCSPReg(); Register SCSPReg = RISCVABI::getSCSPReg();
@ -89,8 +89,8 @@ static void emitSCSEpilogue(MachineFunction &MF, MachineBasicBlock &MBB,
// See emitSCSPrologue() above. // See emitSCSPrologue() above.
std::vector<CalleeSavedInfo> &CSI = MF.getFrameInfo().getCalleeSavedInfo(); std::vector<CalleeSavedInfo> &CSI = MF.getFrameInfo().getCalleeSavedInfo();
if (std::none_of(CSI.begin(), CSI.end(), if (llvm::none_of(
[&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; })) CSI, [&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; }))
return; return;
Register SCSPReg = RISCVABI::getSCSPReg(); Register SCSPReg = RISCVABI::getSCSPReg();