[llvm] 06da452 - [Analysis] Use range-based for loops (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 3 09:36:59 PST 2024


Author: Kazu Hirata
Date: 2024-02-03T09:36:49-08:00
New Revision: 06da452ba7d8d4959cb5070727b842eea4c8af71

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

LOG: [Analysis] Use range-based for loops (NFC)

Added: 
    

Modified: 
    llvm/lib/Analysis/LoopInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index ab2e99f98170a..3075e5190f8ed 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -637,8 +637,8 @@ Loop::LocRange Loop::getLocRange() const {
     // We use the first DebugLoc in the header as the start location of the loop
     // and if there is a second DebugLoc in the header we use it as end location
     // of the loop.
-    for (unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i) {
-      if (DILocation *L = dyn_cast<DILocation>(LoopID->getOperand(i))) {
+    for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
+      if (DILocation *L = dyn_cast<DILocation>(MDO)) {
         if (!Start)
           Start = DebugLoc(L);
         else
@@ -1024,8 +1024,8 @@ MDNode *llvm::findOptionMDForLoopID(MDNode *LoopID, StringRef Name) {
   assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
 
   // Iterate over the metdata node operands and look for MDString metadata.
-  for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
-    MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
+  for (const MDOperand &MDO : llvm::drop_begin(LoopID->operands())) {
+    MDNode *MD = dyn_cast<MDNode>(MDO);
     if (!MD || MD->getNumOperands() < 1)
       continue;
     MDString *S = dyn_cast<MDString>(MD->getOperand(0));
@@ -1136,9 +1136,9 @@ MDNode *llvm::makePostTransformationMetadata(LLVMContext &Context,
   // Remove metadata for the transformation that has been applied or that became
   // outdated.
   if (OrigLoopID) {
-    for (unsigned i = 1, ie = OrigLoopID->getNumOperands(); i < ie; ++i) {
+    for (const MDOperand &MDO : llvm::drop_begin(OrigLoopID->operands())) {
       bool IsVectorMetadata = false;
-      Metadata *Op = OrigLoopID->getOperand(i);
+      Metadata *Op = MDO;
       if (MDNode *MD = dyn_cast<MDNode>(Op)) {
         const MDString *S = dyn_cast<MDString>(MD->getOperand(0));
         if (S)


        


More information about the llvm-commits mailing list