Use llvm::any_of and llvm::all_of (NFC)
authorKazu Hirata <kazu@google.com>
Sat, 11 Dec 2021 19:54:36 +0000 (11:54 -0800)
committerKazu Hirata <kazu@google.com>
Sat, 11 Dec 2021 19:54:37 +0000 (11:54 -0800)
clang/lib/AST/Comment.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/diagtool/TreeView.cpp
llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
llvm/lib/Target/X86/X86FastTileConfig.cpp

index fae3640..43820fc 100644 (file)
@@ -108,12 +108,7 @@ Comment::child_iterator Comment::child_end() const {
 }
 
 bool TextComment::isWhitespaceNoCache() const {
-  for (StringRef::const_iterator I = Text.begin(), E = Text.end();
-       I != E; ++I) {
-    if (!clang::isWhitespace(*I))
-      return false;
-  }
-  return true;
+  return llvm::all_of(Text, clang::isWhitespace);
 }
 
 bool ParagraphComment::isWhitespaceNoCache() const {
index 3b71fb8..6fae41b 100644 (file)
@@ -2040,11 +2040,7 @@ static bool ContainsCompileOrAssembleAction(const Action *A) {
       isa<AssembleJobAction>(A))
     return true;
 
-  for (const Action *Input : A->inputs())
-    if (ContainsCompileOrAssembleAction(Input))
-      return true;
-
-  return false;
+  return llvm::any_of(A->inputs(), ContainsCompileOrAssembleAction);
 }
 
 void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
index 1d88fb0..92b7fdb 100644 (file)
@@ -976,11 +976,7 @@ static bool ContainsCompileAction(const Action *A) {
   if (isa<CompileJobAction>(A) || isa<BackendJobAction>(A))
     return true;
 
-  for (const auto &AI : A->inputs())
-    if (ContainsCompileAction(AI))
-      return true;
-
-  return false;
+  return llvm::any_of(A->inputs(), ContainsCompileAction);
 }
 
 /// Check if -relax-all should be passed to the internal assembler.
index 843bd37..92d92aa 100644 (file)
@@ -40,11 +40,7 @@ public:
     if (!Group.diagnostics().empty())
       return false;
 
-    for (const GroupRecord &GR : Group.subgroups())
-      if (!unimplemented(GR))
-        return false;
-
-    return true;
+    return llvm::all_of(Group.subgroups(), unimplemented);
   }
 
   static bool enabledByDefault(const GroupRecord &Group) {
index cd1d872..284e469 100644 (file)
@@ -57,11 +57,7 @@ bool MetadataVerifier::verifyArray(
   auto &Array = Node.getArray();
   if (Size && Array.size() != *Size)
     return false;
-  for (auto &Item : Array)
-    if (!verifyNode(Item))
-      return false;
-
-  return true;
+  return llvm::all_of(Array, verifyNode);
 }
 
 bool MetadataVerifier::verifyEntry(
index 3874db5..c5d4121 100644 (file)
@@ -251,10 +251,7 @@ namespace {
       SetVector<MachineInstr *> &Predicates = PredicatedInsts[MI]->Predicates;
       if (Exclusive && Predicates.size() != 1)
         return false;
-      for (auto *PredMI : Predicates)
-        if (isVCTP(PredMI))
-          return true;
-      return false;
+      return llvm::any_of(Predicates, isVCTP);
     }
 
     // Is the VPST, controlling the block entry, predicated upon a VCTP.
@@ -351,10 +348,7 @@ namespace {
     }
 
     bool containsVCTP() const {
-      for (auto *MI : Insts)
-        if (isVCTP(MI))
-          return true;
-      return false;
+      return llvm::any_of(Insts, isVCTP);
     }
 
     unsigned size() const { return Insts.size(); }
index 87c04a0..47874e8 100644 (file)
@@ -134,11 +134,7 @@ bool X86FastTileConfig::isAMXInstr(MachineInstr &MI) {
   if (MI.getOpcode() == X86::PLDTILECFGV || MI.isDebugInstr())
     return false;
 
-  for (MachineOperand &MO : MI.operands())
-    if (isTilePhysReg(MO))
-      return true;
-
-  return false;
+  return llvm::any_of(MI.operands(), isTilePhysReg);
 }
 
 MachineInstr *X86FastTileConfig::getKeyAMXInstr(MachineInstr *MI) {