[NFC] Fix -Wrange-loop-analysis warnings.

Remove unnecessary `&` from loop variables.

Fix warnings: "loop variable is always a copy because the range does not
return a reference".

```
[240/2862] Building CXX object tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/TypeDefGen.cpp.o
llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:25: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range<llvm::mapped_iterator<std::__1::__wrap_iter<llvm::Record **>, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis]
    for (const TypeDef &typeDef : defs)
                        ^
llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:10: note: use non-reference type 'mlir::tblgen::TypeDef'
    for (const TypeDef &typeDef : defs)
         ^~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:23: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range<llvm::mapped_iterator<std::__1::__wrap_iter<llvm::Record **>, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis]
  for (const TypeDef &typeDef : defs)
                      ^
llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:8: note: use non-reference type 'mlir::tblgen::TypeDef'
  for (const TypeDef &typeDef : defs)
       ^~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

[1934/2862] Building CXX object tools...Files/toyc-ch4.dir/mlir/MLIRGen.cpp.o
llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<unique_ptr<VariableExprAST, default_delete<VariableExprAST> > > &, MutableArrayRef<BlockArgument> >' does not return a reference [-Wrange-loop-analysis]
    for (const auto &name_value :
                     ^
llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple<const std::__1::unique_ptr<toy::VariableExprAST, std::__1::default_delete<toy::VariableExprAST> > &, mlir::BlockArgument &>'
    for (const auto &name_value :
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

[1940/2862] Building CXX object tools...Files/toyc-ch5.dir/mlir/MLIRGen.cpp.o
llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<unique_ptr<VariableExprAST, default_delete<VariableExprAST> > > &, MutableArrayRef<BlockArgument> >' does not return a reference [-Wrange-loop-analysis]
    for (const auto &name_value :
                     ^
llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple<const std::__1::unique_ptr<toy::VariableExprAST, std::__1::default_delete<toy::VariableExprAST> > &, mlir::BlockArgument &>'
    for (const auto &name_value :
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D94003
This commit is contained in:
Dan Zheng 2021-01-05 18:15:26 +00:00 committed by Mehdi Amini
parent 249d7de119
commit 7afd5cfbc7
8 changed files with 20 additions and 20 deletions

View File

@ -136,10 +136,10 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(std::get<0>(name_value)->getName(),
std::get<1>(name_value))))
if (failed(declare(std::get<0>(nameValue)->getName(),
std::get<1>(nameValue))))
return nullptr;
}

View File

@ -136,10 +136,10 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(std::get<0>(name_value)->getName(),
std::get<1>(name_value))))
if (failed(declare(std::get<0>(nameValue)->getName(),
std::get<1>(nameValue))))
return nullptr;
}

View File

@ -136,10 +136,10 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(std::get<0>(name_value)->getName(),
std::get<1>(name_value))))
if (failed(declare(std::get<0>(nameValue)->getName(),
std::get<1>(nameValue))))
return nullptr;
}

View File

@ -136,10 +136,10 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(std::get<0>(name_value)->getName(),
std::get<1>(name_value))))
if (failed(declare(std::get<0>(nameValue)->getName(),
std::get<1>(nameValue))))
return nullptr;
}

View File

@ -136,10 +136,10 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(std::get<0>(name_value)->getName(),
std::get<1>(name_value))))
if (failed(declare(std::get<0>(nameValue)->getName(),
std::get<1>(nameValue))))
return nullptr;
}

View File

@ -244,7 +244,7 @@ static mlir::LogicalResult verifyConstantForType(mlir::Type type,
// Check that each of the elements are valid.
llvm::ArrayRef<mlir::Attribute> attrElementValues = attrValue.getValue();
for (const auto &it : llvm::zip(resultElementTypes, attrElementValues))
for (const auto it : llvm::zip(resultElementTypes, attrElementValues))
if (failed(verifyConstantForType(std::get<0>(it), std::get<1>(it), op)))
return mlir::failure();
return mlir::success();

View File

@ -190,9 +190,9 @@ private:
auto protoArgs = funcAST.getProto()->getArgs();
// Declare all the function arguments in the symbol table.
for (const auto &name_value :
for (const auto nameValue :
llvm::zip(protoArgs, entryBlock.getArguments())) {
if (failed(declare(*std::get<0>(name_value), std::get<1>(name_value))))
if (failed(declare(*std::get<0>(nameValue), std::get<1>(nameValue))))
return nullptr;
}

View File

@ -47,7 +47,7 @@ static void findAllTypeDefs(const llvm::RecordKeeper &recordKeeper,
return;
llvm::SmallSet<Dialect, 4> dialects;
for (const TypeDef &typeDef : defs)
for (const TypeDef typeDef : defs)
dialects.insert(typeDef.getDialect());
if (dialects.size() != 1)
llvm::PrintFatalError("TypeDefs belonging to more than one dialect. Must "
@ -61,7 +61,7 @@ static void findAllTypeDefs(const llvm::RecordKeeper &recordKeeper,
"generate types via '--typedefs-dialect'.");
}
for (const TypeDef &typeDef : defs)
for (const TypeDef typeDef : defs)
if (typeDef.getDialect().getName().equals(dialectName))
typeDefs.push_back(typeDef);
}