[clang] c2bb963 - Use llvm::any_of and llvm::all_of (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 11 11:54:43 PST 2021


Author: Kazu Hirata
Date: 2021-12-11T11:54:37-08:00
New Revision: c2bb9637d97029d4c97c256718ed1f771d02c232

URL: https://github.com/llvm/llvm-project/commit/c2bb9637d97029d4c97c256718ed1f771d02c232
DIFF: https://github.com/llvm/llvm-project/commit/c2bb9637d97029d4c97c256718ed1f771d02c232.diff

LOG: Use llvm::any_of and llvm::all_of (NFC)

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index fae3640d5ff7c..43820fc566e47 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -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 {

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3b71fb8d7a876..6fae41bc30de6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -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,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 1d88fb0674f00..92b7fdb8e7355 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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.

diff  --git a/clang/tools/diagtool/TreeView.cpp b/clang/tools/diagtool/TreeView.cpp
index 843bd377e574c..92d92aa90699b 100644
--- a/clang/tools/diagtool/TreeView.cpp
+++ b/clang/tools/diagtool/TreeView.cpp
@@ -40,11 +40,7 @@ class TreePrinter {
     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) {

diff  --git a/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp b/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
index cd1d872cc2194..284e469a1d2fe 100644
--- a/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
+++ b/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
@@ -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(

diff  --git a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
index 3874db5792d6e..c5d41219340a6 100644
--- a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
+++ b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
@@ -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(); }

diff  --git a/llvm/lib/Target/X86/X86FastTileConfig.cpp b/llvm/lib/Target/X86/X86FastTileConfig.cpp
index 87c04a07cd13e..47874e82ff3b3 100644
--- a/llvm/lib/Target/X86/X86FastTileConfig.cpp
+++ b/llvm/lib/Target/X86/X86FastTileConfig.cpp
@@ -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) {


        


More information about the cfe-commits mailing list