[Mlir-commits] [mlir] e8d0739 - Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)

Mehdi Amini llvmlistbot at llvm.org
Thu Jan 13 18:28:07 PST 2022


Author: Mehdi Amini
Date: 2022-01-14T02:26:27Z
New Revision: e8d073951b4c732b48a87ca4f3a87e5f35a0ffa4

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

LOG: Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)

Added: 
    

Modified: 
    mlir/examples/toy/Ch1/include/toy/AST.h
    mlir/examples/toy/Ch2/include/toy/AST.h
    mlir/examples/toy/Ch3/include/toy/AST.h
    mlir/examples/toy/Ch4/include/toy/AST.h
    mlir/examples/toy/Ch5/include/toy/AST.h
    mlir/examples/toy/Ch6/include/toy/AST.h
    mlir/examples/toy/Ch7/include/toy/AST.h
    mlir/include/mlir/Bindings/Python/PybindAdaptors.h
    mlir/include/mlir/CAPI/Utils.h
    mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
    mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
    mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
    mlir/include/mlir/Dialect/Quant/UniformSupport.h
    mlir/include/mlir/Dialect/Vector/VectorRewritePatterns.h
    mlir/include/mlir/Pass/PassRegistry.h
    mlir/include/mlir/TableGen/GenInfo.h
    mlir/include/mlir/Transforms/DialectConversion.h
    mlir/lib/Bindings/Python/IRModule.h
    mlir/lib/Bindings/Python/PybindUtils.h
    mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h

Removed: 
    


################################################################################
diff  --git a/mlir/examples/toy/Ch1/include/toy/AST.h b/mlir/examples/toy/Ch1/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch1/include/toy/AST.h
+++ b/mlir/examples/toy/Ch1/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch2/include/toy/AST.h b/mlir/examples/toy/Ch2/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch2/include/toy/AST.h
+++ b/mlir/examples/toy/Ch2/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch3/include/toy/AST.h b/mlir/examples/toy/Ch3/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch3/include/toy/AST.h
+++ b/mlir/examples/toy/Ch3/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch4/include/toy/AST.h b/mlir/examples/toy/Ch4/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch4/include/toy/AST.h
+++ b/mlir/examples/toy/Ch4/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch5/include/toy/AST.h b/mlir/examples/toy/Ch5/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch5/include/toy/AST.h
+++ b/mlir/examples/toy/Ch5/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch6/include/toy/AST.h b/mlir/examples/toy/Ch6/include/toy/AST.h
index 79c9e191ce7d6..962a1624be88e 100644
--- a/mlir/examples/toy/Ch6/include/toy/AST.h
+++ b/mlir/examples/toy/Ch6/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -203,7 +206,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VariableExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }

diff  --git a/mlir/examples/toy/Ch7/include/toy/AST.h b/mlir/examples/toy/Ch7/include/toy/AST.h
index c59c54d342d7b..ca4c0df358032 100644
--- a/mlir/examples/toy/Ch7/include/toy/AST.h
+++ b/mlir/examples/toy/Ch7/include/toy/AST.h
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include <utility>
 #include <vector>
 
 namespace toy {
@@ -46,7 +47,7 @@ class ExprAST {
   };
 
   ExprAST(ExprASTKind kind, Location location)
-      : kind(kind), location(location) {}
+      : kind(kind), location(std::move(location)) {}
   virtual ~ExprAST() = default;
 
   ExprASTKind getKind() const { return kind; }
@@ -66,7 +67,8 @@ class NumberExprAST : public ExprAST {
   double Val;
 
 public:
-  NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
+  NumberExprAST(Location loc, double val)
+      : ExprAST(Expr_Num, std::move(loc)), Val(val) {}
 
   double getValue() { return Val; }
 
@@ -82,7 +84,7 @@ class LiteralExprAST : public ExprAST {
 public:
   LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
                  std::vector<int64_t> dims)
-      : ExprAST(Expr_Literal, loc), values(std::move(values)),
+      : ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
         dims(std::move(dims)) {}
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -99,7 +101,8 @@ class StructLiteralExprAST : public ExprAST {
 public:
   StructLiteralExprAST(Location loc,
                        std::vector<std::unique_ptr<ExprAST>> values)
-      : ExprAST(Expr_StructLiteral, loc), values(std::move(values)) {}
+      : ExprAST(Expr_StructLiteral, std::move(loc)), values(std::move(values)) {
+  }
 
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
 
@@ -115,7 +118,7 @@ class VariableExprAST : public ExprAST {
 
 public:
   VariableExprAST(Location loc, llvm::StringRef name)
-      : ExprAST(Expr_Var, loc), name(name) {}
+      : ExprAST(Expr_Var, std::move(loc)), name(name) {}
 
   llvm::StringRef getName() { return name; }
 
@@ -132,8 +135,8 @@ class VarDeclExprAST : public ExprAST {
 public:
   VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
                  std::unique_ptr<ExprAST> initVal = nullptr)
-      : ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
-        initVal(std::move(initVal)) {}
+      : ExprAST(Expr_VarDecl, std::move(loc)), name(name),
+        type(std::move(type)), initVal(std::move(initVal)) {}
 
   llvm::StringRef getName() { return name; }
   ExprAST *getInitVal() { return initVal.get(); }
@@ -149,7 +152,7 @@ class ReturnExprAST : public ExprAST {
 
 public:
   ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
-      : ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
+      : ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
 
   llvm::Optional<ExprAST *> getExpr() {
     if (expr.hasValue())
@@ -173,7 +176,7 @@ class BinaryExprAST : public ExprAST {
 
   BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
                 std::unique_ptr<ExprAST> rhs)
-      : ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
+      : ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
         rhs(std::move(rhs)) {}
 
   /// LLVM style RTTI
@@ -188,7 +191,8 @@ class CallExprAST : public ExprAST {
 public:
   CallExprAST(Location loc, const std::string &callee,
               std::vector<std::unique_ptr<ExprAST>> args)
-      : ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
+      : ExprAST(Expr_Call, std::move(loc)), callee(callee),
+        args(std::move(args)) {}
 
   llvm::StringRef getCallee() { return callee; }
   llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -203,7 +207,7 @@ class PrintExprAST : public ExprAST {
 
 public:
   PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
-      : ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
+      : ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
 
   ExprAST *getArg() { return arg.get(); }
 
@@ -222,7 +226,7 @@ class PrototypeAST {
 public:
   PrototypeAST(Location location, const std::string &name,
                std::vector<std::unique_ptr<VarDeclExprAST>> args)
-      : location(location), name(name), args(std::move(args)) {}
+      : location(std::move(location)), name(name), args(std::move(args)) {}
 
   const Location &loc() { return location; }
   llvm::StringRef getName() const { return name; }
@@ -274,7 +278,7 @@ class StructAST : public RecordAST {
 public:
   StructAST(Location location, const std::string &name,
             std::vector<std::unique_ptr<VarDeclExprAST>> variables)
-      : RecordAST(Record_Struct), location(location), name(name),
+      : RecordAST(Record_Struct), location(std::move(location)), name(name),
         variables(std::move(variables)) {}
 
   const Location &loc() { return location; }

diff  --git a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
index f2ccbfed147ac..05fb0844ac620 100644
--- a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
+++ b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
@@ -250,7 +250,7 @@ namespace adaptors {
 class pure_subclass {
 public:
   pure_subclass(py::handle scope, const char *derivedClassName,
-                py::object superClass) {
+                const py::object &superClass) {
     py::object pyType =
         py::reinterpret_borrow<py::object>((PyObject *)&PyType_Type);
     py::object metaclass = pyType(superClass);
@@ -335,7 +335,8 @@ class mlir_attribute_subclass : public pure_subclass {
   /// as the mlir.ir class (otherwise, it will trigger a recursive
   /// initialization).
   mlir_attribute_subclass(py::handle scope, const char *typeClassName,
-                          IsAFunctionTy isaFunction, py::object superClass)
+                          IsAFunctionTy isaFunction,
+                          const py::object &superClass)
       : pure_subclass(scope, typeClassName, superClass) {
     // Casting constructor. Note that defining an __init__ method is special
     // and not yet generalized on pure_subclass (it requires a somewhat
@@ -386,7 +387,7 @@ class mlir_type_subclass : public pure_subclass {
   /// as the mlir.ir class (otherwise, it will trigger a recursive
   /// initialization).
   mlir_type_subclass(py::handle scope, const char *typeClassName,
-                     IsAFunctionTy isaFunction, py::object superClass)
+                     IsAFunctionTy isaFunction, const py::object &superClass)
       : pure_subclass(scope, typeClassName, superClass) {
     // Casting constructor. Note that defining an __init__ method is special
     // and not yet generalized on pure_subclass (it requires a somewhat

diff  --git a/mlir/include/mlir/CAPI/Utils.h b/mlir/include/mlir/CAPI/Utils.h
index 000516e7a85f7..d78cdbf31dbda 100644
--- a/mlir/include/mlir/CAPI/Utils.h
+++ b/mlir/include/mlir/CAPI/Utils.h
@@ -14,6 +14,8 @@
 #ifndef MLIR_CAPI_UTILS_H
 #define MLIR_CAPI_UTILS_H
 
+#include <utility>
+
 #include "mlir-c/Support.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -29,7 +31,7 @@ class CallbackOstream : public llvm::raw_ostream {
 public:
   CallbackOstream(std::function<void(MlirStringRef, void *)> callback,
                   void *opaqueData)
-      : raw_ostream(/*unbuffered=*/true), callback(callback),
+      : raw_ostream(/*unbuffered=*/true), callback(std::move(callback)),
         opaqueData(opaqueData), pos(0u) {}
 
   void write_impl(const char *ptr, size_t size) override {

diff  --git a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
index 3c84ef8cbae46..9d865350f2313 100644
--- a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
+++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
@@ -9,6 +9,8 @@
 #ifndef MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_
 #define MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_
 
+#include <utility>
+
 #include "mlir/IR/BlockAndValueMapping.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
@@ -48,7 +50,8 @@ struct AllocationCallbacks {
 
   AllocationCallbacks(AllocationFn allocFn, DeallocationFn deallocFn,
                       MemCpyFn copyFn)
-      : allocationFn(allocFn), deallocationFn(deallocFn), memCpyFn(copyFn) {}
+      : allocationFn(std::move(allocFn)), deallocationFn(std::move(deallocFn)),
+        memCpyFn(std::move(copyFn)) {}
 
   /// A function that allocates memory.
   AllocationFn allocationFn;

diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
index a532478d72afd..50fb04898886b 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
@@ -9,6 +9,8 @@
 #ifndef MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
 #define MLIR_DIALECT_LINALG_TRANSFORMS_CODEGENSTRATEGY_H_
 
+#include <utility>
+
 #include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
 #include "mlir/Dialect/Linalg/Passes.h"
 #include "mlir/Pass/PassManager.h"
@@ -23,7 +25,7 @@ namespace linalg {
 /// through markers.
 struct Transformation {
   explicit Transformation(LinalgTransformationFilter::FilterFunction f)
-      : filter(f) {}
+      : filter(std::move(f)) {}
   virtual ~Transformation() = default;
   virtual void addToPassPipeline(OpPassManager &pm,
                                  LinalgTransformationFilter m) const = 0;
@@ -34,7 +36,8 @@ struct Transformation {
 struct TileAndFuse : public Transformation {
   TileAndFuse(StringRef name, linalg::LinalgTilingAndFusionOptions options,
               LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), opName(name), options(options) {}
+      : Transformation(std::move(f)), opName(name),
+        options(std::move(options)) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -50,7 +53,8 @@ struct TileAndFuse : public Transformation {
 struct Tile : public Transformation {
   Tile(StringRef name, linalg::LinalgTilingOptions options,
        LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), opName(name), options(options) {}
+      : Transformation(std::move(f)), opName(name),
+        options(std::move(options)) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -66,7 +70,8 @@ struct Tile : public Transformation {
 struct Pad : public Transformation {
   Pad(StringRef name, linalg::LinalgPaddingOptions options,
       LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), opName(name), options(options) {}
+      : Transformation(std::move(f)), opName(name),
+        options(std::move(options)) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -82,7 +87,8 @@ struct Pad : public Transformation {
 struct Promote : public Transformation {
   Promote(StringRef name, linalg::LinalgPromotionOptions options,
           LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), opName(name), options(options) {}
+      : Transformation(std::move(f)), opName(name),
+        options(std::move(options)) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -98,7 +104,7 @@ struct Promote : public Transformation {
 struct Generalize : public Transformation {
   explicit Generalize(StringRef name,
                       LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), opName(name) {}
+      : Transformation(std::move(f)), opName(name) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -113,8 +119,9 @@ struct Generalize : public Transformation {
 struct Interchange : public Transformation {
   explicit Interchange(ArrayRef<int64_t> iteratorInterchange,
                        LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), iteratorInterchange(iteratorInterchange.begin(),
-                                               iteratorInterchange.end()) {}
+      : Transformation(std::move(f)),
+        iteratorInterchange(iteratorInterchange.begin(),
+                            iteratorInterchange.end()) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -128,7 +135,7 @@ struct Interchange : public Transformation {
 /// Represent one application of createLinalgStrategyDecomposePass.
 struct Decompose : public Transformation {
   explicit Decompose(LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f) {}
+      : Transformation(std::move(f)) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -141,13 +148,13 @@ struct Vectorize : public Transformation {
   explicit Vectorize(linalg::LinalgVectorizationOptions options,
                      LinalgTransformationFilter::FilterFunction f = nullptr,
                      bool padVectorize = false)
-      : Transformation(f), opName(), options(options),
+      : Transformation(std::move(f)), opName(), options(options),
         vectorizePadding(padVectorize) {}
 
   Vectorize(StringRef name, linalg::LinalgVectorizationOptions options,
             LinalgTransformationFilter::FilterFunction f = nullptr,
             bool padVectorize = false)
-      : Transformation(f), opName(name), options(options),
+      : Transformation(std::move(f)), opName(name), options(options),
         vectorizePadding(padVectorize) {}
 
   void addToPassPipeline(OpPassManager &pm,
@@ -167,7 +174,7 @@ struct VectorLowering : public Transformation {
   explicit VectorLowering(
       linalg::LinalgVectorLoweringOptions options,
       LinalgTransformationFilter::FilterFunction f = nullptr)
-      : Transformation(f), options(options) {}
+      : Transformation(std::move(f)), options(options) {}
 
   void addToPassPipeline(OpPassManager &pm,
                          LinalgTransformationFilter m) const override {
@@ -183,8 +190,8 @@ struct CodegenStrategy {
   /// Append a pattern to tile the Op `opName` and fuse its producers with
   /// tiling and fusion `options`.
   CodegenStrategy &
-  tileAndFuse(StringRef opName, LinalgTilingAndFusionOptions options,
-              LinalgTransformationFilter::FilterFunction f = nullptr) {
+  tileAndFuse(StringRef opName, const LinalgTilingAndFusionOptions &options,
+              const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<TileAndFuse>(opName, options, f));
     return *this;
@@ -194,13 +201,13 @@ struct CodegenStrategy {
   CodegenStrategy &
   tileAndFuseIf(bool b, StringRef opName, LinalgTilingAndFusionOptions options,
                 LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? tileAndFuse(opName, options, f) : *this;
+    return b ? tileAndFuse(opName, std::move(options), std::move(f)) : *this;
   }
   /// Append a pattern to add a level of tiling for Op `opName` with tiling
   /// `options`.
   CodegenStrategy &
-  tile(StringRef opName, linalg::LinalgTilingOptions options,
-       LinalgTransformationFilter::FilterFunction f = nullptr) {
+  tile(StringRef opName, const linalg::LinalgTilingOptions &options,
+       const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<Tile>(opName, options, f));
     return *this;
@@ -210,12 +217,13 @@ struct CodegenStrategy {
   CodegenStrategy &
   tileIf(bool b, StringRef opName, linalg::LinalgTilingOptions options,
          LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? tile(opName, options, f) : *this;
+    return b ? tile(opName, std::move(options), std::move(f)) : *this;
   }
   /// Append a pattern to pad and hoist the operands of Op `opName` with padding
   /// `options`.
-  CodegenStrategy &pad(StringRef opName, linalg::LinalgPaddingOptions options,
-                       LinalgTransformationFilter::FilterFunction f = nullptr) {
+  CodegenStrategy &
+  pad(StringRef opName, const linalg::LinalgPaddingOptions &options,
+      const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<Pad>(opName, options, f));
     return *this;
@@ -225,13 +233,13 @@ struct CodegenStrategy {
   CodegenStrategy &
   padIf(bool b, StringRef opName, linalg::LinalgPaddingOptions options,
         LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? pad(opName, options, f) : *this;
+    return b ? pad(opName, std::move(options), std::move(f)) : *this;
   }
   /// Append a pattern to add a level of promotion for `LinalgOpType` with
   /// promotion `options`.
   CodegenStrategy &
-  promote(StringRef opName, linalg::LinalgPromotionOptions options,
-          LinalgTransformationFilter::FilterFunction f = nullptr) {
+  promote(StringRef opName, const linalg::LinalgPromotionOptions &options,
+          const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<Promote>(opName, options, f));
     return *this;
@@ -241,12 +249,12 @@ struct CodegenStrategy {
   CodegenStrategy &
   promoteIf(bool b, StringRef opName, linalg::LinalgPromotionOptions options,
             LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? promote(opName, options, f) : *this;
+    return b ? promote(opName, std::move(options), std::move(f)) : *this;
   }
   /// Append a pattern to generalize named operations.
   CodegenStrategy &
   generalize(StringRef opName,
-             LinalgTransformationFilter::FilterFunction f = nullptr) {
+             const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<Generalize>(opName, f));
     return *this;
@@ -255,12 +263,12 @@ struct CodegenStrategy {
   CodegenStrategy &
   generalizeIf(bool b, StringRef opName,
                LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? generalize(opName, f) : *this;
+    return b ? generalize(opName, std::move(f)) : *this;
   }
   /// Append a pattern to interchange iterators.
   CodegenStrategy &
   interchange(ArrayRef<int64_t> iteratorInterchange,
-              LinalgTransformationFilter::FilterFunction f = nullptr) {
+              const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(
         std::make_unique<Interchange>(iteratorInterchange, f));
     return *this;
@@ -269,23 +277,23 @@ struct CodegenStrategy {
   CodegenStrategy &
   interchangeIf(bool b, ArrayRef<int64_t> iteratorInterchange,
                 LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? interchange(iteratorInterchange, f) : *this;
+    return b ? interchange(iteratorInterchange, std::move(f)) : *this;
   }
   /// Append patterns to decompose convolutions.
   CodegenStrategy &
-  decompose(LinalgTransformationFilter::FilterFunction f = nullptr) {
+  decompose(const LinalgTransformationFilter::FilterFunction &f = nullptr) {
     transformationSequence.emplace_back(std::make_unique<Decompose>(f));
     return *this;
   }
   /// Conditionally append patterns to decompose convolutions.
   CodegenStrategy &
   decomposeIf(bool b, LinalgTransformationFilter::FilterFunction f = nullptr) {
-    return b ? decompose(f) : *this;
+    return b ? decompose(std::move(f)) : *this;
   }
   /// Append a pattern to rewrite `LinalgOpType` as a vector operation.
   CodegenStrategy &
   vectorize(StringRef opName,
-            LinalgTransformationFilter::FilterFunction f = nullptr,
+            const LinalgTransformationFilter::FilterFunction &f = nullptr,
             bool vectorizePadding = false) {
     transformationSequence.emplace_back(std::make_unique<Vectorize>(
         opName, linalg::LinalgVectorizationOptions(), f, vectorizePadding));
@@ -297,7 +305,7 @@ struct CodegenStrategy {
   vectorizeIf(bool b, StringRef opName,
               LinalgTransformationFilter::FilterFunction f = nullptr,
               bool vectorizePadding = false) {
-    return b ? vectorize(opName, f, vectorizePadding) : *this;
+    return b ? vectorize(opName, std::move(f), vectorizePadding) : *this;
   }
   /// Append a pattern to lower all vector operations.
   CodegenStrategy &vectorLowering(LinalgVectorLoweringOptions options) {

diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 38ea017bb2a6e..739d1b6d69a98 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -9,6 +9,8 @@
 #ifndef MLIR_DIALECT_LINALG_TRANSFORMS_TRANSFORMS_H
 #define MLIR_DIALECT_LINALG_TRANSFORMS_TRANSFORMS_H
 
+#include <utility>
+
 #include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
 #include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/MemRef/IR/MemRef.h"
@@ -443,7 +445,7 @@ struct LinalgTransformationFilter {
                                          Operation *op) const;
   bool hasReplacementFilter(Operation *op) const;
 
-  LinalgTransformationFilter &addFilter(FilterFunction f) {
+  LinalgTransformationFilter &addFilter(const FilterFunction &f) {
     if (f)
       filters.push_back(f);
     return *this;
@@ -550,7 +552,7 @@ struct LinalgTilingOptions {
   /// Set the `tileSizeComputationFunction` to return the values `ts`. The
   /// values must not fold away when tiling. Otherwise, use a more robust
   /// `tileSizeComputationFunction`.
-  LinalgTilingOptions &setTileSizes(SmallVector<Value, 4> ts) {
+  LinalgTilingOptions &setTileSizes(const SmallVector<Value, 4> &ts) {
     tileSizeComputationFunction = [=](OpBuilder &, Operation *) { return ts; };
     return *this;
   }
@@ -1160,7 +1162,7 @@ struct GeneralizePadTensorOpPattern : public OpRewritePattern<PadTensorOp> {
                                OptimizeCopyFn optimizeCopyFn = nullptr,
                                PatternBenefit benefit = 1)
       : OpRewritePattern<PadTensorOp>(context, benefit),
-        optimizeCopyFn(optimizeCopyFn) {}
+        optimizeCopyFn(std::move(optimizeCopyFn)) {}
   LogicalResult matchAndRewrite(PadTensorOp padOp,
                                 PatternRewriter &rewriter) const override;
 
@@ -1276,7 +1278,7 @@ class ConvOpVectorization : public OpRewritePattern<ConvOp> {
   SmallVector<bool, 4> mask;
 
 public:
-  ConvOpVectorization(MLIRContext *context, SmallVector<bool, 4> msk)
+  ConvOpVectorization(MLIRContext *context, const SmallVector<bool, 4> &msk)
       : OpRewritePattern<ConvOp>(context) {
     assert(msk.size() == N && "Mask size does not match rank");
     this->mask = msk;

diff  --git a/mlir/include/mlir/Dialect/Quant/UniformSupport.h b/mlir/include/mlir/Dialect/Quant/UniformSupport.h
index 202dcce2c792c..2a26aa8e557f1 100644
--- a/mlir/include/mlir/Dialect/Quant/UniformSupport.h
+++ b/mlir/include/mlir/Dialect/Quant/UniformSupport.h
@@ -9,6 +9,8 @@
 #ifndef MLIR_DIALECT_QUANT_UNIFORMSUPPORT_H_
 #define MLIR_DIALECT_QUANT_UNIFORMSUPPORT_H_
 
+#include <utility>
+
 #include "mlir/Dialect/Quant/QuantTypes.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Types.h"
@@ -79,7 +81,8 @@ class UniformQuantizedValueConverter {
         roundMode(APFloat::rmNearestTiesToAway) {}
 
   UniformQuantizedValueConverter(double scale, double zeroPoint,
-                                 APFloat clampMin, APFloat clampMax,
+                                 const APFloat &clampMin,
+                                 const APFloat &clampMax,
                                  uint32_t storageBitWidth, bool isSigned)
       : scale(scale), zeroPoint(zeroPoint), clampMin(clampMin),
         clampMax(clampMax), scaleDouble(scale), zeroPointDouble(zeroPoint),
@@ -116,7 +119,7 @@ class UniformQuantizedValueConverter {
   }
 
   int64_t quantizeFloatToInt64(APFloat expressedValue) const {
-    APInt qValue = quantizeFloatToInt(expressedValue);
+    APInt qValue = quantizeFloatToInt(std::move(expressedValue));
     return isSigned ? qValue.getSExtValue() : qValue.getZExtValue();
   }
 

diff  --git a/mlir/include/mlir/Dialect/Vector/VectorRewritePatterns.h b/mlir/include/mlir/Dialect/Vector/VectorRewritePatterns.h
index 966dcc1d3a449..563f67d817804 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorRewritePatterns.h
+++ b/mlir/include/mlir/Dialect/Vector/VectorRewritePatterns.h
@@ -9,6 +9,8 @@
 #ifndef MLIR_DIALECT_VECTOR_VECTORREWRITEPATTERNS_H
 #define MLIR_DIALECT_VECTOR_VECTORREWRITEPATTERNS_H
 
+#include <utility>
+
 #include "mlir/Dialect/Vector/VectorOps.h"
 #include "mlir/Dialect/Vector/VectorUtils.h"
 #include "mlir/IR/BuiltinOps.h"
@@ -101,7 +103,7 @@ struct UnrollVectorOptions {
   /// attempted on the operation.
   FilterConstraintFnType filterConstraint = nullptr;
   UnrollVectorOptions &setFilterConstraint(FilterConstraintFnType constraint) {
-    filterConstraint = constraint;
+    filterConstraint = std::move(constraint);
     return *this;
   }
 
@@ -111,7 +113,7 @@ struct UnrollVectorOptions {
   /// operation. The unrolling is aborted if the function returns `llvm::None`.
   NativeShapeFnType nativeShape = nullptr;
   UnrollVectorOptions &setNativeShapeFn(NativeShapeFnType fn) {
-    nativeShape = fn;
+    nativeShape = std::move(fn);
     return *this;
   }
 
@@ -321,7 +323,7 @@ struct VectorTransferFullPartialRewriter : public RewritePattern {
           [](VectorTransferOpInterface op) { return success(); },
       PatternBenefit benefit = 1)
       : RewritePattern(MatchAnyOpTypeTag(), benefit, context), options(options),
-        filter(filter) {}
+        filter(std::move(filter)) {}
 
   /// Performs the rewrite.
   LogicalResult matchAndRewrite(Operation *op,
@@ -360,7 +362,8 @@ class ContractionOpToMatmulOpLowering
       vector::VectorTransformsOptions vectorTransformOptions,
       MLIRContext *context, FilterConstraintType constraint = defaultFilter)
       : OpRewritePattern<vector::ContractionOp>(context),
-        vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
+        vectorTransformOptions(vectorTransformOptions),
+        filter(std::move(constraint)) {}
 
   LogicalResult matchAndRewrite(vector::ContractionOp op,
                                 PatternRewriter &rewriter) const override;
@@ -401,7 +404,8 @@ class ContractionOpToOuterProductOpLowering
       vector::VectorTransformsOptions vectorTransformOptions,
       MLIRContext *context, FilterConstraintType constraint = defaultFilter)
       : OpRewritePattern<vector::ContractionOp>(context),
-        vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
+        vectorTransformOptions(vectorTransformOptions),
+        filter(std::move(constraint)) {}
 
   LogicalResult matchAndRewrite(vector::ContractionOp op,
                                 PatternRewriter &rewriter) const override;
@@ -443,7 +447,8 @@ class ContractionOpToDotLowering
 
   ContractionOpToDotLowering(
       vector::VectorTransformsOptions vectorTransformOptions,
-      MLIRContext *context, FilterConstraintType constraint = defaultFilter)
+      MLIRContext *context,
+      const FilterConstraintType &constraint = defaultFilter)
       : OpRewritePattern<vector::ContractionOp>(context),
         vectorTransformOptions(vectorTransformOptions), filter(defaultFilter) {}
 
@@ -484,7 +489,8 @@ class ContractionOpLowering : public OpRewritePattern<vector::ContractionOp> {
                         MLIRContext *context,
                         FilterConstraintType constraint = defaultFilter)
       : OpRewritePattern<vector::ContractionOp>(context),
-        vectorTransformOptions(vectorTransformOptions), filter(constraint) {}
+        vectorTransformOptions(vectorTransformOptions),
+        filter(std::move(constraint)) {}
 
   LogicalResult matchAndRewrite(vector::ContractionOp op,
                                 PatternRewriter &rewriter) const override;

diff  --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h
index 63b474f86765a..9167751ebbcee 100644
--- a/mlir/include/mlir/Pass/PassRegistry.h
+++ b/mlir/include/mlir/Pass/PassRegistry.h
@@ -17,6 +17,7 @@
 #include "mlir/Pass/PassOptions.h"
 #include "mlir/Support/TypeID.h"
 #include <functional>
+#include <utility>
 
 namespace mlir {
 class OpPassManager;
@@ -76,7 +77,7 @@ class PassRegistryEntry {
       std::function<void(function_ref<void(const detail::PassOptions &)>)>
           optHandler)
       : arg(arg), description(description), builder(builder),
-        optHandler(optHandler) {}
+        optHandler(std::move(optHandler)) {}
 
 private:
   /// The argument with which to invoke the pass via mlir-opt.
@@ -100,7 +101,7 @@ class PassPipelineInfo : public PassRegistryEntry {
       StringRef arg, StringRef description, const PassRegistryFunction &builder,
       std::function<void(function_ref<void(const detail::PassOptions &)>)>
           optHandler)
-      : PassRegistryEntry(arg, description, builder, optHandler) {}
+      : PassRegistryEntry(arg, description, builder, std::move(optHandler)) {}
 };
 
 /// A structure to represent the information for a derived pass class.
@@ -182,8 +183,9 @@ struct PassPipelineRegistration {
 /// Convenience specialization of PassPipelineRegistration for EmptyPassOptions
 /// that does not pass an empty options struct to the pass builder function.
 template <> struct PassPipelineRegistration<EmptyPipelineOptions> {
-  PassPipelineRegistration(StringRef arg, StringRef description,
-                           std::function<void(OpPassManager &)> builder) {
+  PassPipelineRegistration(
+      StringRef arg, StringRef description,
+      const std::function<void(OpPassManager &)> &builder) {
     registerPassPipeline(
         arg, description,
         [builder](OpPassManager &pm, StringRef optionsStr,

diff  --git a/mlir/include/mlir/TableGen/GenInfo.h b/mlir/include/mlir/TableGen/GenInfo.h
index bbba88f1c065d..ef2e12f07df16 100644
--- a/mlir/include/mlir/TableGen/GenInfo.h
+++ b/mlir/include/mlir/TableGen/GenInfo.h
@@ -12,6 +12,7 @@
 #include "mlir/Support/LLVM.h"
 #include "llvm/ADT/StringRef.h"
 #include <functional>
+#include <utility>
 
 namespace llvm {
 class RecordKeeper;
@@ -30,7 +31,7 @@ class GenInfo {
   /// GenInfo constructor should not be invoked directly, instead use
   /// GenRegistration or registerGen.
   GenInfo(StringRef arg, StringRef description, GenFunction generator)
-      : arg(arg), description(description), generator(generator) {}
+      : arg(arg), description(description), generator(std::move(generator)) {}
 
   /// Invokes the generator and returns whether the generator failed.
   bool invoke(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) const {

diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index e73b3f95b116a..87a640342d00b 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -774,7 +774,7 @@ class ConversionTarget {
   /// Register the operations of the given dialects as dynamically legal, i.e.
   /// requiring custom handling by the callback.
   template <typename... Names>
-  void addDynamicallyLegalDialect(DynamicLegalityCallbackFn callback,
+  void addDynamicallyLegalDialect(const DynamicLegalityCallbackFn &callback,
                                   StringRef name, Names... names) {
     SmallVector<StringRef, 2> dialectNames({name, names...});
     setDialectAction(dialectNames, LegalizationAction::Dynamic);

diff  --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h
index 4f1b65610786f..b1424a994d857 100644
--- a/mlir/lib/Bindings/Python/IRModule.h
+++ b/mlir/lib/Bindings/Python/IRModule.h
@@ -9,6 +9,7 @@
 #ifndef MLIR_BINDINGS_PYTHON_IRMODULES_H
 #define MLIR_BINDINGS_PYTHON_IRMODULES_H
 
+#include <utility>
 #include <vector>
 
 #include "PybindUtils.h"
@@ -330,8 +331,9 @@ class PyDiagnosticHandler {
   void detach();
 
   pybind11::object contextEnter() { return pybind11::cast(this); }
-  void contextExit(pybind11::object excType, pybind11::object excVal,
-                   pybind11::object excTb) {
+  void contextExit(const pybind11::object &excType,
+                   const pybind11::object &excVal,
+                   const pybind11::object &excTb) {
     detach();
   }
 
@@ -532,7 +534,7 @@ class PyOperation : public PyOperationBase, public BaseContextObject {
   }
 
   bool isAttached() { return attached; }
-  void setAttached(pybind11::object parent = pybind11::object()) {
+  void setAttached(const pybind11::object &parent = pybind11::object()) {
     assert(!attached && "operation already attached");
     attached = true;
   }
@@ -876,7 +878,7 @@ class PyConcreteAttribute : public BaseTy {
 class PyValue {
 public:
   PyValue(PyOperationRef parentOperation, MlirValue value)
-      : parentOperation(parentOperation), value(value) {}
+      : parentOperation(std::move(parentOperation)), value(value) {}
   operator MlirValue() const { return value; }
 
   MlirValue get() { return value; }

diff  --git a/mlir/lib/Bindings/Python/PybindUtils.h b/mlir/lib/Bindings/Python/PybindUtils.h
index 457d8090c087c..75a72371e9ae1 100644
--- a/mlir/lib/Bindings/Python/PybindUtils.h
+++ b/mlir/lib/Bindings/Python/PybindUtils.h
@@ -133,7 +133,7 @@ struct PyPrintAccumulator {
 /// or binary.
 class PyFileAccumulator {
 public:
-  PyFileAccumulator(pybind11::object fileObject, bool binary)
+  PyFileAccumulator(const pybind11::object &fileObject, bool binary)
       : pyWriteFunction(fileObject.attr("write")), binary(binary) {}
 
   void *getUserData() { return this; }

diff  --git a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
index 8a3f47ed59891..e5c85199e2679 100644
--- a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
+++ b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
@@ -30,6 +30,7 @@
 #include <bitset>
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
 namespace mlir {
@@ -566,7 +567,7 @@ bool fromJSON(const llvm::json::Value &value, DocumentSymbolParams &result,
 /// diagnostics, e.g. when duplicating a symbol in a scope.
 struct DiagnosticRelatedInformation {
   DiagnosticRelatedInformation(Location location, std::string message)
-      : location(location), message(std::move(message)) {}
+      : location(std::move(location)), message(std::move(message)) {}
 
   /// The location of this related diagnostic information.
   Location location;
@@ -626,7 +627,7 @@ llvm::json::Value toJSON(const Diagnostic &diag);
 
 struct PublishDiagnosticsParams {
   PublishDiagnosticsParams(URIForFile uri, int64_t version)
-      : uri(uri), version(version) {}
+      : uri(std::move(uri)), version(version) {}
 
   /// The URI for which diagnostic information is reported.
   URIForFile uri;


        


More information about the Mlir-commits mailing list