[llvm] e6785fd - [Scalar] Fix a warning

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun May 12 23:02:43 PDT 2024


Author: Kazu Hirata
Date: 2024-05-12T23:02:37-07:00
New Revision: e6785fd75284f53b9e23db6f249598e09f3fc39f

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

LOG: [Scalar] Fix a warning

This patch fixes:

  llvm/lib/Transforms/Scalar/GVNSink.cpp:270:33: error: lambda capture
  'this' is not used [-Werror,-Wunused-lambda-capture]

While I am at it, this patch replaces llvm::for_each with a
range-based for loop.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/GVNSink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index ddf01dc612bb5..95a4c644a91ad 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -267,13 +267,13 @@ class ModelledPHI {
     };
     assert(llvm::is_sorted(Blocks, ComesBefore));
     int C = 0;
-    llvm::for_each(Values, [&C, this](const Value *V) {
+    for (const Value *V : Values) {
       if (!isa<UndefValue>(V)) {
-        const Instruction *I = cast<Instruction>(V);
-        assert(I->getParent() == this->Blocks[C]);
+        assert(cast<Instruction>(V)->getParent() == Blocks[C]);
+        (void)C;
       }
       C++;
-    });
+    }
   }
   /// Create a PHI from an array of incoming values and incoming blocks.
   ModelledPHI(SmallVectorImpl<Instruction *> &V,


        


More information about the llvm-commits mailing list