[clang] 6d9cd91 - Use llvm::all_of (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 14 16:25:50 PDT 2022
Author: Kazu Hirata
Date: 2022-08-14T16:25:36-07:00
New Revision: 6d9cd9199a6fdeab0412117bcefc28f625510b61
URL: https://github.com/llvm/llvm-project/commit/6d9cd9199a6fdeab0412117bcefc28f625510b61
DIFF: https://github.com/llvm/llvm-project/commit/6d9cd9199a6fdeab0412117bcefc28f625510b61.diff
LOG: Use llvm::all_of (NFC)
Added:
Modified:
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
clang-tools-extra/clangd/URI.cpp
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
lldb/source/Target/Platform.cpp
lldb/source/Utility/Event.cpp
lldb/tools/debugserver/source/RNBRemote.cpp
llvm/lib/Demangle/RustDemangle.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 047273946ed54..6e6308d6c7a8d 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -168,7 +168,7 @@ void ClangDocCommentVisitor::visitVerbatimLineComment(
}
bool ClangDocCommentVisitor::isWhitespaceOnly(llvm::StringRef S) const {
- return std::all_of(S.begin(), S.end(), isspace);
+ return llvm::all_of(S, isspace);
}
std::string ClangDocCommentVisitor::getCommandName(unsigned CommandID) const {
diff --git a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
index e5424c98a72ae..f8a4d6e95df0a 100644
--- a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
@@ -38,14 +38,10 @@ static char ValidDatePatternChars[] = {
// set of reserved characters. See:
// https://www.unicode.org/reports/tr35/tr35.html#Invalid_Patterns
bool isValidDatePattern(StringRef Pattern) {
- for (auto &PatternChar : Pattern) {
- if (isalpha(PatternChar)) {
- if (!llvm::is_contained(ValidDatePatternChars, PatternChar)) {
- return false;
- }
- }
- }
- return true;
+ return llvm::all_of(Pattern, [](const auto &PatternChar) {
+ return !isalpha(PatternChar) ||
+ llvm::is_contained(ValidDatePatternChars, PatternChar);
+ });
}
// Checks if the string pattern used as a date format specifier contains
diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp
index c94053cadd2ad..ca65df329aeeb 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -142,7 +142,7 @@ bool isValidScheme(llvm::StringRef Scheme) {
return false;
if (!llvm::isAlpha(Scheme[0]))
return false;
- return std::all_of(Scheme.begin() + 1, Scheme.end(), [](char C) {
+ return llvm::all_of(llvm::drop_begin(Scheme), [](char C) {
return llvm::isAlnum(C) || C == '+' || C == '.' || C == '-';
});
}
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 61688688b0a73..7dc0fec46d421 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3486,8 +3486,8 @@ unsigned FunctionDecl::getMinRequiredArguments() const {
bool FunctionDecl::hasOneParamOrDefaultArgs() const {
return getNumParams() == 1 ||
(getNumParams() > 1 &&
- std::all_of(param_begin() + 1, param_end(),
- [](ParmVarDecl *P) { return P->hasDefaultArg(); }));
+ llvm::all_of(llvm::drop_begin(parameters()),
+ [](ParmVarDecl *P) { return P->hasDefaultArg(); }));
}
/// The combination of the extern and inline keywords under MSVC forces
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1d9ec1162bafb..c703d7670abee 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3788,9 +3788,8 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// Variable is used if it has been marked as an array, array
// section, array shaping or the variable iself.
return StackComponents.size() == 1 ||
- std::all_of(
- std::next(StackComponents.rbegin()),
- StackComponents.rend(),
+ llvm::all_of(
+ llvm::drop_begin(llvm::reverse(StackComponents)),
[](const OMPClauseMappableExprCommon::
MappableComponent &MC) {
return MC.getAssociatedDeclaration() ==
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 45cab755ae5a7..622266ec7a745 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -853,8 +853,8 @@ std::unique_ptr<lto::LTO> createLTO(
// `__start_` and `__stop_` symbols.
bool isValidCIdentifier(StringRef S) {
return !S.empty() && (isAlpha(S[0]) || S[0] == '_') &&
- std::all_of(S.begin() + 1, S.end(),
- [](char C) { return C == '_' || isAlnum(C); });
+ llvm::all_of(llvm::drop_begin(S),
+ [](char C) { return C == '_' || isAlnum(C); });
}
Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles,
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index d6d2bb601c8fa..3afd87c698801 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -404,17 +404,14 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
if (!groupInPedantic(Group))
continue;
- unsigned ParentsInPedantic = 0;
const std::vector<Record*> &Parents = DiagGroupParents.getParents(Group);
- for (unsigned j = 0, ej = Parents.size(); j != ej; ++j) {
- if (groupInPedantic(Parents[j]))
- ++ParentsInPedantic;
- }
+ bool AllParentsInPedantic =
+ llvm::all_of(Parents, [&](Record *R) { return groupInPedantic(R); });
// If all the parents are in -Wpedantic, this means that this diagnostic
// group will be indirectly included by -Wpedantic already. In that
// case, do not add it directly to -Wpedantic. If the group has no
// parents, obviously it should go into -Wpedantic.
- if (Parents.size() > 0 && ParentsInPedantic == Parents.size())
+ if (Parents.size() > 0 && AllParentsInPedantic)
continue;
if (RecordVec *V = GroupsInPedantic.dyn_cast<RecordVec*>())
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index ce902a1a59d4d..5be2ff36f35c1 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -2060,10 +2060,9 @@ PlatformSP PlatformList::GetOrCreate(llvm::ArrayRef<ArchSpec> archs,
// the same platform supports all architectures then that's the obvious next
// best thing.
if (candidates.size() == archs.size()) {
- if (std::all_of(candidates.begin(), candidates.end(),
- [&](const PlatformSP &p) -> bool {
- return p->GetName() == candidates.front()->GetName();
- })) {
+ if (llvm::all_of(candidates, [&](const PlatformSP &p) -> bool {
+ return p->GetName() == candidates.front()->GetName();
+ })) {
return candidates.front();
}
}
diff --git a/lldb/source/Utility/Event.cpp b/lldb/source/Utility/Event.cpp
index 4c07293c92df7..5fca61b16df82 100644
--- a/lldb/source/Utility/Event.cpp
+++ b/lldb/source/Utility/Event.cpp
@@ -124,9 +124,7 @@ ConstString EventDataBytes::GetFlavor() const {
}
void EventDataBytes::Dump(Stream *s) const {
- size_t num_printable_chars =
- std::count_if(m_bytes.begin(), m_bytes.end(), llvm::isPrint);
- if (num_printable_chars == m_bytes.size())
+ if (llvm::all_of(m_bytes, llvm::isPrint))
s->Format("\"{0}\"", m_bytes);
else
s->Format("{0:$[ ]@[x-2]}", llvm::make_range(
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp
index ebb2125524e9c..ee5d93cb94506 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -4861,8 +4861,8 @@ rnb_err_t RNBRemote::HandlePacket_qHostInfo(const char *p) {
std::string maccatalyst_version = DNBGetMacCatalystVersionString();
if (!maccatalyst_version.empty() &&
- std::all_of(maccatalyst_version.begin(), maccatalyst_version.end(),
- [](char c) { return (c >= '0' && c <= '9') || c == '.'; }))
+ llvm::all_of(maccatalyst_version,
+ [](char c) { return (c >= '0' && c <= '9') || c == '.'; }))
strm << "maccatalyst_version:" << maccatalyst_version << ";";
#if defined(__LITTLE_ENDIAN__)
diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index 32b10db2a968d..e9724d0f1f247 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Demangle/Demangle.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Demangle/StringView.h"
#include "llvm/Demangle/Utility.h"
@@ -865,7 +866,7 @@ Identifier Demangler::parseIdentifier() {
StringView S = Input.substr(Position, Bytes);
Position += Bytes;
- if (!std::all_of(S.begin(), S.end(), isValid)) {
+ if (!llvm::all_of(S, isValid)) {
Error = true;
return {};
}
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index fd4b4170c0a75..a0a9b62d3c595 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -421,12 +421,11 @@ static MDNode *stripDebugLocFromLoopID(MDNode *N) {
// If there is only the debug location without any actual loop metadata, we
// can remove the metadata.
- if (std::all_of(
- N->op_begin() + 1, N->op_end(),
- [&Visited, &DILocationReachable](const MDOperand &Op) {
- return isDILocationReachable(Visited, DILocationReachable,
- Op.get());
- }))
+ if (llvm::all_of(llvm::drop_begin(N->operands()),
+ [&Visited, &DILocationReachable](const MDOperand &Op) {
+ return isDILocationReachable(Visited, DILocationReachable,
+ Op.get());
+ }))
return nullptr;
return updateLoopMetadataDebugLocationsImpl(
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
index 37aabcc8016af..fdf9f457c3e77 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
@@ -338,9 +338,9 @@ void SchedGroup::initSchedGroup() {
static bool canFitIntoPipeline(SUnit &SU, ScheduleDAGInstrs *DAG,
DenseSet<SUnit *> &ConflictedInstrs) {
- return std::all_of(
- ConflictedInstrs.begin(), ConflictedInstrs.end(),
- [DAG, &SU](SUnit *SuccSU) { return DAG->canAddEdge(SuccSU, &SU); });
+ return llvm::all_of(ConflictedInstrs, [DAG, &SU](SUnit *SuccSU) {
+ return DAG->canAddEdge(SuccSU, &SU);
+ });
}
void SchedGroup::initSchedGroup(std::vector<SUnit>::reverse_iterator RIter,
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 361dbc835cee5..85b0bc80b22d2 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -7679,10 +7679,9 @@ static SDValue LowerBUILD_VECTOR_i1(SDValue Op, SelectionDAG &DAG,
// extend that single value
SDValue FirstOp = Op.getOperand(0);
if (!isa<ConstantSDNode>(FirstOp) &&
- std::all_of(std::next(Op->op_begin()), Op->op_end(),
- [&FirstOp](SDUse &U) {
- return U.get().isUndef() || U.get() == FirstOp;
- })) {
+ llvm::all_of(llvm::drop_begin(Op->ops()), [&FirstOp](const SDUse &U) {
+ return U.get().isUndef() || U.get() == FirstOp;
+ })) {
SDValue Ext = DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, MVT::i32, FirstOp,
DAG.getValueType(MVT::i1));
return DAG.getNode(ARMISD::PREDICATE_CAST, dl, Op.getValueType(), Ext);
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index f1b457bb4f5ba..2f2579f27120e 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -722,8 +722,8 @@ static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix,
// Returns true if S is valid as a C language identifier.
static bool isValidCIdentifier(StringRef S) {
return !S.empty() && (isAlpha(S[0]) || S[0] == '_') &&
- std::all_of(S.begin() + 1, S.end(),
- [](char C) { return C == '_' || isAlnum(C); });
+ llvm::all_of(llvm::drop_begin(S),
+ [](char C) { return C == '_' || isAlnum(C); });
}
static bool isUndefined(ld_plugin_symbol &Sym) {
diff --git a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
index 49fbff12ad273..ec59fd60c7711 100644
--- a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -361,7 +361,7 @@ int main(int argc, char **argv) {
char32_t Codepoint = Entry.first;
const std::string &Name = Entry.second;
// Ignore names which are not valid.
- if (Name.empty() || !std::all_of(Name.begin(), Name.end(), [](char C) {
+ if (Name.empty() || !llvm::all_of(Name, [](char C) {
return llvm::is_contained(Letters, C);
})) {
continue;
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index 31d11c84c8772..012338b148a3e 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -399,13 +399,13 @@ static void mergeAndAlignVars(unsigned offset, FlatAffineValueConstraints *a,
assert(areVarsUnique(*a) && "A's values aren't unique");
assert(areVarsUnique(*b) && "B's values aren't unique");
- assert(std::all_of(a->getMaybeValues().begin() + offset,
- a->getMaybeValues().end(),
- [](Optional<Value> var) { return var.has_value(); }));
+ assert(
+ llvm::all_of(llvm::drop_begin(a->getMaybeValues(), offset),
+ [](const Optional<Value> &var) { return var.has_value(); }));
- assert(std::all_of(b->getMaybeValues().begin() + offset,
- b->getMaybeValues().end(),
- [](Optional<Value> var) { return var.has_value(); }));
+ assert(
+ llvm::all_of(llvm::drop_begin(b->getMaybeValues(), offset),
+ [](const Optional<Value> &var) { return var.has_value(); }));
SmallVector<Value, 4> aDimValues;
a->getValues(offset, a->getNumDimVars(), &aDimValues);
diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.cpp b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
index 0fe10479041f8..6c10be316b8cf 100644
--- a/mlir/lib/Tools/lsp-server-support/Protocol.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
@@ -121,7 +121,7 @@ static bool isValidScheme(StringRef scheme) {
return false;
if (!llvm::isAlpha(scheme[0]))
return false;
- return std::all_of(scheme.begin() + 1, scheme.end(), [](char c) {
+ return llvm::all_of(llvm::drop_begin(scheme), [](char c) {
return llvm::isAlnum(c) || c == '+' || c == '.' || c == '-';
});
}
More information about the cfe-commits
mailing list