[Lldb-commits] [lldb] 4bd4650 - Use llvm::any_of and llvm::none_of (NFC)
Kazu Hirata via lldb-commits
lldb-commits at lists.llvm.org
Sun Oct 24 17:35:49 PDT 2021
Author: Kazu Hirata
Date: 2021-10-24T17:35:33-07:00
New Revision: 4bd46501c394ce221d34b60155f48ebbf6b6897d
URL: https://github.com/llvm/llvm-project/commit/4bd46501c394ce221d34b60155f48ebbf6b6897d
DIFF: https://github.com/llvm/llvm-project/commit/4bd46501c394ce221d34b60155f48ebbf6b6897d.diff
LOG: Use llvm::any_of and llvm::none_of (NFC)
Added:
Modified:
clang/include/clang/AST/DeclContextInternals.h
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Basic/Targets/AVR.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/NeonEmitter.cpp
lld/ELF/SyntheticSections.cpp
lld/wasm/Writer.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Utility/VMRange.cpp
llvm/lib/Analysis/AssumptionCache.cpp
llvm/lib/Analysis/LoopCacheAnalysis.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h
index 2eef2343b7500..9899fc29b82d6 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -78,8 +78,7 @@ class StoredDeclsList {
}
Data.setPointer(NewHead);
- assert(llvm::find_if(getLookupResult(), ShouldErase) ==
- getLookupResult().end() && "Still exists!");
+ assert(llvm::none_of(getLookupResult(), ShouldErase) && "Still exists!");
}
void erase(NamedDecl *ND) {
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 69b745c8b4518..8a3051a2f9eed 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -5912,7 +5912,7 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) {
// at least for now, but once we have better support for exceptions,
// we'd need to carefully handle the case when the throw is being
// immediately caught.
- if (std::any_of(Blk->begin(), Blk->end(), [](const CFGElement &Elm) {
+ if (llvm::any_of(*Blk, [](const CFGElement &Elm) {
if (Optional<CFGStmt> StmtElm = Elm.getAs<CFGStmt>())
if (isa<CXXThrowExpr>(StmtElm->getStmt()))
return true;
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index d6bb8cf673f75..b196ffa73cbfb 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -86,11 +86,9 @@ class CapExprSet : public SmallVector<CapabilityExpr, 4> {
public:
/// Push M onto list, but discard duplicates.
void push_back_nodup(const CapabilityExpr &CapE) {
- iterator It = std::find_if(begin(), end(),
- [=](const CapabilityExpr &CapE2) {
- return CapE.equals(CapE2);
- });
- if (It == end())
+ if (llvm::none_of(*this, [=](const CapabilityExpr &CapE2) {
+ return CapE.equals(CapE2);
+ }))
push_back(CapE);
}
};
diff --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index 38ce61386bb4c..50b0fc07b3118 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -313,10 +313,8 @@ static constexpr llvm::StringLiteral ValidFamilyNames[] = {
bool AVRTargetInfo::isValidCPUName(StringRef Name) const {
bool IsFamily = llvm::is_contained(ValidFamilyNames, Name);
- bool IsMCU =
- llvm::find_if(AVRMcus, [&](const MCUInfo &Info) {
- return Info.Name == Name;
- }) != std::end(AVRMcus);
+ bool IsMCU = llvm::any_of(
+ AVRMcus, [&](const MCUInfo &Info) { return Info.Name == Name; });
return IsFamily || IsMCU;
}
diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index f860623e2bc37..afbebd070c054 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -83,7 +83,7 @@ CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const CallExpr *E,
/* ParamsToSkip = */ 0);
// We don't know how to emit non-scalar varargs.
- if (std::any_of(Args.begin() + 1, Args.end(), [&](const CallArg &A) {
+ if (llvm::any_of(llvm::drop_begin(Args), [&](const CallArg &A) {
return !A.getRValue(*this).isScalar();
})) {
CGM.ErrorUnsupported(E, "non-scalar arg to printf");
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 8a11da600e4a1..2d11495b4ff0a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -751,13 +751,11 @@ struct CounterCoverageMappingBuilder
/// is already added to \c SourceRegions.
bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc,
bool isBranch = false) {
- return SourceRegions.rend() !=
- std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
- [&](const SourceMappingRegion &Region) {
- return Region.getBeginLoc() == StartLoc &&
- Region.getEndLoc() == EndLoc &&
- Region.isBranch() == isBranch;
- });
+ return llvm::any_of(
+ llvm::reverse(SourceRegions), [&](const SourceMappingRegion &Region) {
+ return Region.getBeginLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc && Region.isBranch() == isBranch;
+ });
}
/// Adjust the most recently visited location to \c EndLoc.
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index d5b5e3bb0bb84..c41801207fec1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4691,10 +4691,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasFlag(options::OPT_fdiscard_value_names,
options::OPT_fno_discard_value_names, !IsAssertBuild)) {
if (Args.hasArg(options::OPT_fdiscard_value_names) &&
- (std::any_of(Inputs.begin(), Inputs.end(),
- [](const clang::driver::InputInfo &II) {
- return types::isLLVMIR(II.getType());
- }))) {
+ llvm::any_of(Inputs, [](const clang::driver::InputInfo &II) {
+ return types::isLLVMIR(II.getType());
+ })) {
D.Diag(diag::warn_ignoring_fdiscard_for_bitcode);
}
CmdArgs.push_back("-discard-value-names");
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index ad4818aba6f60..ef1785bd54692 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1075,10 +1075,9 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
// If the line contains an '@' sign, the previous token might be an
// annotation, which can precede another identifier/value.
- bool HasAt = std::find_if(Line->Tokens.begin(), Line->Tokens.end(),
- [](UnwrappedLineNode &LineNode) {
- return LineNode.Tok->is(tok::at);
- }) != Line->Tokens.end();
+ bool HasAt = llvm::any_of(Line->Tokens, [](UnwrappedLineNode &LineNode) {
+ return LineNode.Tok->is(tok::at);
+ });
if (HasAt)
return;
}
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 4bdb73965bcac..4e5c0ac6c1c14 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -1068,8 +1068,8 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
// Ensure that any ellipsis was in the right place.
SourceLocation EllipsisLoc;
- if (std::any_of(std::begin(EllipsisLocs), std::end(EllipsisLocs),
- [](SourceLocation Loc) { return Loc.isValid(); })) {
+ if (llvm::any_of(EllipsisLocs,
+ [](SourceLocation Loc) { return Loc.isValid(); })) {
// The '...' should appear before the identifier in an init-capture, and
// after the identifier otherwise.
bool InitCapture = InitKind != LambdaCaptureInitKind::NoInit;
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index e28203e4e00b7..796590c26d3f5 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1634,7 +1634,7 @@ class UninitValsDiagReporter : public UninitVariablesHandler {
private:
static bool hasAlwaysUninitializedUse(const UsesVec* vec) {
- return std::any_of(vec->begin(), vec->end(), [](const UninitUse &U) {
+ return llvm::any_of(*vec, [](const UninitUse &U) {
return U.getKind() == UninitUse::Always ||
U.getKind() == UninitUse::AfterCall ||
U.getKind() == UninitUse::AfterDecl;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 03f7a95d0800d..ea7715bba7066 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -436,7 +436,7 @@ void Sema::CheckExtraCXXDefaultArguments(Declarator &D) {
}
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD) {
- return std::any_of(FD->param_begin(), FD->param_end(), [](ParmVarDecl *P) {
+ return llvm::any_of(FD->parameters(), [](ParmVarDecl *P) {
return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
});
}
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index bda6be195f212..c0bb310e64fb9 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -308,8 +308,7 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
}
return declaresSameEntity(Pack.first.get<NamedDecl *>(), LocalPack);
};
- if (std::find_if(LSI->LocalPacks.begin(), LSI->LocalPacks.end(),
- DeclaresThisPack) != LSI->LocalPacks.end())
+ if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
LambdaParamPackReferences.push_back(Pack);
}
@@ -328,8 +327,8 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
bool EnclosingStmtExpr = false;
for (unsigned N = FunctionScopes.size(); N; --N) {
sema::FunctionScopeInfo *Func = FunctionScopes[N-1];
- if (std::any_of(
- Func->CompoundScopes.begin(), Func->CompoundScopes.end(),
+ if (llvm::any_of(
+ Func->CompoundScopes,
[](sema::CompoundScopeInfo &CSI) { return CSI.IsStmtExpr; })) {
EnclosingStmtExpr = true;
break;
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 5d0fd8b9f6b8e..2a55a5eb59581 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2676,9 +2676,9 @@ static void emitAttrList(raw_ostream &OS, StringRef Class,
// Determines if an attribute has a Pragma spelling.
static bool AttrHasPragmaSpelling(const Record *R) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
- return llvm::find_if(Spellings, [](const FlattenedSpelling &S) {
- return S.variety() == "Pragma";
- }) != Spellings.end();
+ return llvm::any_of(Spellings, [](const FlattenedSpelling &S) {
+ return S.variety() == "Pragma";
+ });
}
namespace {
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 2945849382958..69ee9af0f259e 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -417,8 +417,7 @@ class Intrinsic {
/// Return true if the intrinsic takes an immediate operand.
bool hasImmediate() const {
- return std::any_of(Types.begin(), Types.end(),
- [](const Type &T) { return T.isImmediate(); });
+ return llvm::any_of(Types, [](const Type &T) { return T.isImmediate(); });
}
/// Return the parameter index of the immediate operand.
@@ -1271,9 +1270,8 @@ void Intrinsic::emitShadowedArgs() {
}
bool Intrinsic::protoHasScalar() const {
- return std::any_of(Types.begin(), Types.end(), [](const Type &T) {
- return T.isScalar() && !T.isImmediate();
- });
+ return llvm::any_of(
+ Types, [](const Type &T) { return T.isScalar() && !T.isImmediate(); });
}
void Intrinsic::emitBodyAsBuiltinCall() {
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 0423cb0455783..f5e153efed758 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3591,9 +3591,8 @@ void ARMExidxSyntheticSection::writeTo(uint8_t *buf) {
}
bool ARMExidxSyntheticSection::isNeeded() const {
- return llvm::find_if(exidxSections, [](InputSection *isec) {
- return isec->isLive();
- }) != exidxSections.end();
+ return llvm::any_of(exidxSections,
+ [](InputSection *isec) { return isec->isLive(); });
}
bool ARMExidxSyntheticSection::classof(const SectionBase *d) {
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 41d26e98ec148..454daaf34403f 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -468,8 +468,7 @@ void Writer::populateTargetFeatures() {
auto isTLS = [](InputChunk *segment) {
return segment->live && segment->isTLS();
};
- tlsUsed = tlsUsed ||
- std::any_of(file->segments.begin(), file->segments.end(), isTLS);
+ tlsUsed = tlsUsed || llvm::any_of(file->segments, isTLS);
}
if (inferFeatures)
@@ -950,10 +949,9 @@ bool Writer::needsPassiveInitialization(const OutputSegment *segment) {
}
bool Writer::hasPassiveInitializedSegments() {
- return std::find_if(segments.begin(), segments.end(),
- [this](const OutputSegment *s) {
- return this->needsPassiveInitialization(s);
- }) != segments.end();
+ return llvm::any_of(segments, [this](const OutputSegment *s) {
+ return this->needsPassiveInitialization(s);
+ });
}
void Writer::createSyntheticInitFunctions() {
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index eaa381d22c639..b7beddf4e0576 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -47,10 +47,9 @@ class SupportedArchList {
private:
void AddArch(const ArchSpec &spec) {
- auto iter = std::find_if(
- m_archs.begin(), m_archs.end(),
- [spec](const ArchSpec &rhs) { return spec.IsExactMatch(rhs); });
- if (iter != m_archs.end())
+ if (llvm::any_of(m_archs, [spec](const ArchSpec &rhs) {
+ return spec.IsExactMatch(rhs);
+ }))
return;
if (spec.IsValid())
m_archs.push_back(spec);
diff --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp
index 184531b4bb272..ddd2a67c29b26 100644
--- a/lldb/source/Utility/VMRange.cpp
+++ b/lldb/source/Utility/VMRange.cpp
@@ -23,16 +23,14 @@ using namespace lldb_private;
bool VMRange::ContainsValue(const VMRange::collection &coll,
lldb::addr_t value) {
- return llvm::find_if(coll, [&](const VMRange &r) {
- return r.Contains(value);
- }) != coll.end();
+ return llvm::any_of(coll,
+ [&](const VMRange &r) { return r.Contains(value); });
}
bool VMRange::ContainsRange(const VMRange::collection &coll,
const VMRange &range) {
- return llvm::find_if(coll, [&](const VMRange &r) {
- return r.Contains(range);
- }) != coll.end();
+ return llvm::any_of(coll,
+ [&](const VMRange &r) { return r.Contains(range); });
}
void VMRange::Dump(llvm::raw_ostream &s, lldb::addr_t offset,
diff --git a/llvm/lib/Analysis/AssumptionCache.cpp b/llvm/lib/Analysis/AssumptionCache.cpp
index 0d95b33601f92..0d8319ec37b81 100644
--- a/llvm/lib/Analysis/AssumptionCache.cpp
+++ b/llvm/lib/Analysis/AssumptionCache.cpp
@@ -132,9 +132,9 @@ void AssumptionCache::updateAffectedValues(AssumeInst *CI) {
for (auto &AV : Affected) {
auto &AVV = getOrInsertAffectedValues(AV.Assume);
- if (std::find_if(AVV.begin(), AVV.end(), [&](ResultElem &Elem) {
+ if (llvm::none_of(AVV, [&](ResultElem &Elem) {
return Elem.Assume == CI && Elem.Index == AV.Index;
- }) == AVV.end())
+ }))
AVV.push_back({CI, AV.Index});
}
}
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index b765ad0f83292..7b895d8a5dc2a 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -521,10 +521,9 @@ void CacheCost::calculateCacheFootprint() {
LLVM_DEBUG(dbgs() << "COMPUTING LOOP CACHE COSTS\n");
for (const Loop *L : Loops) {
- assert((std::find_if(LoopCosts.begin(), LoopCosts.end(),
- [L](const LoopCacheCostTy &LCC) {
- return LCC.first == L;
- }) == LoopCosts.end()) &&
+ assert(llvm::none_of(
+ LoopCosts,
+ [L](const LoopCacheCostTy &LCC) { return LCC.first == L; }) &&
"Should not add duplicate element");
CacheCostTy LoopCost = computeLoopCacheCost(*L, RefGroups);
LoopCosts.push_back(std::make_pair(L, LoopCost));
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 40d58d555d3d1..e4e26876857e4 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3297,7 +3297,7 @@ static bool checkForMustTailInVarArgFn(bool IsVarArg, const BasicBlock &BB) {
// Walk the block backwards, because tail calls usually only appear at the end
// of a block.
- return std::any_of(BB.rbegin(), BB.rend(), [](const Instruction &I) {
+ return llvm::any_of(llvm::reverse(BB), [](const Instruction &I) {
const auto *CI = dyn_cast<CallInst>(&I);
return CI && CI->isMustTailCall();
});
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 1574212a0df03..a9fd185ce8f67 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -110,9 +110,8 @@ struct llvm::TimeTraceProfiler {
// templates from within, we only want to add the topmost one. "topmost"
// happens to be the ones that don't have any currently open entries above
// itself.
- if (std::find_if(++Stack.rbegin(), Stack.rend(), [&](const Entry &Val) {
- return Val.Name == E.Name;
- }) == Stack.rend()) {
+ if (llvm::none_of(llvm::drop_begin(llvm::reverse(Stack)),
+ [&](const Entry &Val) { return Val.Name == E.Name; })) {
auto &CountAndTotal = CountAndTotalPerName[E.Name];
CountAndTotal.first++;
CountAndTotal.second += Duration;
diff --git a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp
index 54aa14849dd94..1a9adf8127ecb 100644
--- a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp
@@ -3252,7 +3252,7 @@ bool HexagonLoopRescheduling::processLoop(LoopCand &C) {
auto LoopInpEq = [G] (const PhiInfo &P) -> bool {
return G.Out.Reg == P.LR.Reg;
};
- if (llvm::find_if(Phis, LoopInpEq) == Phis.end())
+ if (llvm::none_of(Phis, LoopInpEq))
continue;
G.Inp.Reg = Inputs.find_first();
More information about the lldb-commits
mailing list