Skip to content

[ADT] Use a range-based for loop instead of llvm::for_each (NFC) #149542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.
@llvmbot
Copy link
Member

llvmbot commented Jul 18, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.


Full diff: https://github.com/llvm/llvm-project/pull/149542.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/CombinationGenerator.h (+1-2)
diff --git a/llvm/include/llvm/ADT/CombinationGenerator.h b/llvm/include/llvm/ADT/CombinationGenerator.h
index 6100aa9812293..bbdbd9bfa1be3 100644
--- a/llvm/include/llvm/ADT/CombinationGenerator.h
+++ b/llvm/include/llvm/ADT/CombinationGenerator.h
@@ -118,10 +118,9 @@ class CombinationGenerator {
       : VariablesChoices(VariablesChoices_) {
 #ifndef NDEBUG
     assert(!VariablesChoices.empty() && "There should be some variables.");
-    llvm::for_each(VariablesChoices, [](ArrayRef<choice_type> VariableChoices) {
+    for (ArrayRef<choice_type> VariableChoices : VariablesChoices)
       assert(!VariableChoices.empty() &&
              "There must always be some choice, at least a placeholder one.");
-    });
 #endif
   }
 

@kazutakahirata kazutakahirata merged commit 796d5a8 into llvm:main Jul 18, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250718_llvm_for_each_llvm_ADT branch July 18, 2025 17:44
mdfazlay pushed a commit to mdfazlay/llvm-project that referenced this pull request Jul 18, 2025
…m#149542)

LLVM Coding Standards discourages llvm::for_each unless we already
have a callable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants