Skip to content

[Serialization] Use traditional for loops (NFC) #102761

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

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

kazutakahirata
Copy link
Contributor

The use of _ requires either:

  • (void)_ and curly braces, or
  • [[maybe_unused]].

For simple repetitions like these, we can use traditional for loops
for readable warning-free code.

The use of _ requires either:

- (void)_ and curly braces, or
- [[maybe_unused]].

For simple repetitions like these, we can use traditional for loops
for readable warning-free code.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:modules C++20 modules and Clang Header Modules labels Aug 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 10, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: Kazu Hirata (kazutakahirata)

Changes

The use of _ requires either:

  • (void)_ and curly braces, or
  • [[maybe_unused]].

For simple repetitions like these, we can use traditional for loops
for readable warning-free code.


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

1 Files Affected:

  • (modified) clang/lib/Serialization/ASTReader.cpp (+2-6)
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 8ff7c82950dba..5f9cfa3cf4bfa 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -11468,10 +11468,8 @@ void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
   unsigned NumVars = C->varlist_size();
   SmallVector<Expr *, 16> Vars;
   Vars.reserve(NumVars);
-  for ([[maybe_unused]] auto _ : llvm::seq<unsigned>(NumVars)) {
-    (void)_;
+  for (unsigned I = 0; I != NumVars; ++I)
     Vars.push_back(Record.readSubExpr());
-  }
   C->setVarRefs(Vars);
 }
 
@@ -11481,10 +11479,8 @@ void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
   unsigned NumVars = C->varlist_size();
   SmallVector<Expr *, 16> Vars;
   Vars.reserve(NumVars);
-  for (auto _ : llvm::seq<unsigned>(NumVars)) {
-    (void)_;
+  for (unsigned I = 0; I != NumVars; ++I)
     Vars.push_back(Record.readSubExpr());
-  }
   C->setVarRefs(Vars);
 }
 

Copy link
Member

@alexey-bataev alexey-bataev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kazutakahirata kazutakahirata merged commit 4ce2f98 into llvm:main Aug 10, 2024
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_ASTReader branch August 10, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants