Skip to content

Commit e8d0739

Browse files
committed
Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC)
1 parent 8e5f112 commit e8d0739

File tree

20 files changed

+195
-142
lines changed

20 files changed

+195
-142
lines changed

mlir/examples/toy/Ch1/include/toy/AST.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/ArrayRef.h"
2121
#include "llvm/ADT/StringRef.h"
2222
#include "llvm/Support/Casting.h"
23+
#include <utility>
2324
#include <vector>
2425

2526
namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
4445
};
4546

4647
ExprAST(ExprASTKind kind, Location location)
47-
: kind(kind), location(location) {}
48+
: kind(kind), location(std::move(location)) {}
4849
virtual ~ExprAST() = default;
4950

5051
ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
6465
double Val;
6566

6667
public:
67-
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
68+
NumberExprAST(Location loc, double val)
69+
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
6870

6971
double getValue() { return Val; }
7072

@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
8082
public:
8183
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
8284
std::vector<int64_t> dims)
83-
: ExprAST(Expr_Literal, loc), values(std::move(values)),
85+
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
8486
dims(std::move(dims)) {}
8587

8688
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
9698

9799
public:
98100
VariableExprAST(Location loc, llvm::StringRef name)
99-
: ExprAST(Expr_Var, loc), name(name) {}
101+
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
100102

101103
llvm::StringRef getName() { return name; }
102104

@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
113115
public:
114116
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
115117
std::unique_ptr<ExprAST> initVal)
116-
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
117-
initVal(std::move(initVal)) {}
118+
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
119+
type(std::move(type)), initVal(std::move(initVal)) {}
118120

119121
llvm::StringRef getName() { return name; }
120122
ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
130132

131133
public:
132134
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
133-
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
135+
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
134136

135137
llvm::Optional<ExprAST *> getExpr() {
136138
if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
154156

155157
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
156158
std::unique_ptr<ExprAST> rhs)
157-
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
159+
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
158160
rhs(std::move(rhs)) {}
159161

160162
/// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
169171
public:
170172
CallExprAST(Location loc, const std::string &callee,
171173
std::vector<std::unique_ptr<ExprAST>> args)
172-
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
174+
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
175+
args(std::move(args)) {}
173176

174177
llvm::StringRef getCallee() { return callee; }
175178
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
184187

185188
public:
186189
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
187-
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
190+
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
188191

189192
ExprAST *getArg() { return arg.get(); }
190193

@@ -203,7 +206,7 @@ class PrototypeAST {
203206
public:
204207
PrototypeAST(Location location, const std::string &name,
205208
std::vector<std::unique_ptr<VariableExprAST>> args)
206-
: location(location), name(name), args(std::move(args)) {}
209+
: location(std::move(location)), name(name), args(std::move(args)) {}
207210

208211
const Location &loc() { return location; }
209212
llvm::StringRef getName() const { return name; }

mlir/examples/toy/Ch2/include/toy/AST.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/ArrayRef.h"
2121
#include "llvm/ADT/StringRef.h"
2222
#include "llvm/Support/Casting.h"
23+
#include <utility>
2324
#include <vector>
2425

2526
namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
4445
};
4546

4647
ExprAST(ExprASTKind kind, Location location)
47-
: kind(kind), location(location) {}
48+
: kind(kind), location(std::move(location)) {}
4849
virtual ~ExprAST() = default;
4950

5051
ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
6465
double Val;
6566

6667
public:
67-
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
68+
NumberExprAST(Location loc, double val)
69+
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
6870

6971
double getValue() { return Val; }
7072

@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
8082
public:
8183
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
8284
std::vector<int64_t> dims)
83-
: ExprAST(Expr_Literal, loc), values(std::move(values)),
85+
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
8486
dims(std::move(dims)) {}
8587

8688
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
9698

9799
public:
98100
VariableExprAST(Location loc, llvm::StringRef name)
99-
: ExprAST(Expr_Var, loc), name(name) {}
101+
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
100102

101103
llvm::StringRef getName() { return name; }
102104

@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
113115
public:
114116
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
115117
std::unique_ptr<ExprAST> initVal)
116-
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
117-
initVal(std::move(initVal)) {}
118+
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
119+
type(std::move(type)), initVal(std::move(initVal)) {}
118120

119121
llvm::StringRef getName() { return name; }
120122
ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
130132

131133
public:
132134
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
133-
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
135+
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
134136

135137
llvm::Optional<ExprAST *> getExpr() {
136138
if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
154156

155157
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
156158
std::unique_ptr<ExprAST> rhs)
157-
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
159+
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
158160
rhs(std::move(rhs)) {}
159161

160162
/// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
169171
public:
170172
CallExprAST(Location loc, const std::string &callee,
171173
std::vector<std::unique_ptr<ExprAST>> args)
172-
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
174+
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
175+
args(std::move(args)) {}
173176

174177
llvm::StringRef getCallee() { return callee; }
175178
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
184187

185188
public:
186189
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
187-
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
190+
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
188191

189192
ExprAST *getArg() { return arg.get(); }
190193

@@ -203,7 +206,7 @@ class PrototypeAST {
203206
public:
204207
PrototypeAST(Location location, const std::string &name,
205208
std::vector<std::unique_ptr<VariableExprAST>> args)
206-
: location(location), name(name), args(std::move(args)) {}
209+
: location(std::move(location)), name(name), args(std::move(args)) {}
207210

208211
const Location &loc() { return location; }
209212
llvm::StringRef getName() const { return name; }

mlir/examples/toy/Ch3/include/toy/AST.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/ArrayRef.h"
2121
#include "llvm/ADT/StringRef.h"
2222
#include "llvm/Support/Casting.h"
23+
#include <utility>
2324
#include <vector>
2425

2526
namespace toy {
@@ -44,7 +45,7 @@ class ExprAST {
4445
};
4546

4647
ExprAST(ExprASTKind kind, Location location)
47-
: kind(kind), location(location) {}
48+
: kind(kind), location(std::move(location)) {}
4849
virtual ~ExprAST() = default;
4950

5051
ExprASTKind getKind() const { return kind; }
@@ -64,7 +65,8 @@ class NumberExprAST : public ExprAST {
6465
double Val;
6566

6667
public:
67-
NumberExprAST(Location loc, double val) : ExprAST(Expr_Num, loc), Val(val) {}
68+
NumberExprAST(Location loc, double val)
69+
: ExprAST(Expr_Num, std::move(loc)), Val(val) {}
6870

6971
double getValue() { return Val; }
7072

@@ -80,7 +82,7 @@ class LiteralExprAST : public ExprAST {
8082
public:
8183
LiteralExprAST(Location loc, std::vector<std::unique_ptr<ExprAST>> values,
8284
std::vector<int64_t> dims)
83-
: ExprAST(Expr_Literal, loc), values(std::move(values)),
85+
: ExprAST(Expr_Literal, std::move(loc)), values(std::move(values)),
8486
dims(std::move(dims)) {}
8587

8688
llvm::ArrayRef<std::unique_ptr<ExprAST>> getValues() { return values; }
@@ -96,7 +98,7 @@ class VariableExprAST : public ExprAST {
9698

9799
public:
98100
VariableExprAST(Location loc, llvm::StringRef name)
99-
: ExprAST(Expr_Var, loc), name(name) {}
101+
: ExprAST(Expr_Var, std::move(loc)), name(name) {}
100102

101103
llvm::StringRef getName() { return name; }
102104

@@ -113,8 +115,8 @@ class VarDeclExprAST : public ExprAST {
113115
public:
114116
VarDeclExprAST(Location loc, llvm::StringRef name, VarType type,
115117
std::unique_ptr<ExprAST> initVal)
116-
: ExprAST(Expr_VarDecl, loc), name(name), type(std::move(type)),
117-
initVal(std::move(initVal)) {}
118+
: ExprAST(Expr_VarDecl, std::move(loc)), name(name),
119+
type(std::move(type)), initVal(std::move(initVal)) {}
118120

119121
llvm::StringRef getName() { return name; }
120122
ExprAST *getInitVal() { return initVal.get(); }
@@ -130,7 +132,7 @@ class ReturnExprAST : public ExprAST {
130132

131133
public:
132134
ReturnExprAST(Location loc, llvm::Optional<std::unique_ptr<ExprAST>> expr)
133-
: ExprAST(Expr_Return, loc), expr(std::move(expr)) {}
135+
: ExprAST(Expr_Return, std::move(loc)), expr(std::move(expr)) {}
134136

135137
llvm::Optional<ExprAST *> getExpr() {
136138
if (expr.hasValue())
@@ -154,7 +156,7 @@ class BinaryExprAST : public ExprAST {
154156

155157
BinaryExprAST(Location loc, char Op, std::unique_ptr<ExprAST> lhs,
156158
std::unique_ptr<ExprAST> rhs)
157-
: ExprAST(Expr_BinOp, loc), op(Op), lhs(std::move(lhs)),
159+
: ExprAST(Expr_BinOp, std::move(loc)), op(Op), lhs(std::move(lhs)),
158160
rhs(std::move(rhs)) {}
159161

160162
/// LLVM style RTTI
@@ -169,7 +171,8 @@ class CallExprAST : public ExprAST {
169171
public:
170172
CallExprAST(Location loc, const std::string &callee,
171173
std::vector<std::unique_ptr<ExprAST>> args)
172-
: ExprAST(Expr_Call, loc), callee(callee), args(std::move(args)) {}
174+
: ExprAST(Expr_Call, std::move(loc)), callee(callee),
175+
args(std::move(args)) {}
173176

174177
llvm::StringRef getCallee() { return callee; }
175178
llvm::ArrayRef<std::unique_ptr<ExprAST>> getArgs() { return args; }
@@ -184,7 +187,7 @@ class PrintExprAST : public ExprAST {
184187

185188
public:
186189
PrintExprAST(Location loc, std::unique_ptr<ExprAST> arg)
187-
: ExprAST(Expr_Print, loc), arg(std::move(arg)) {}
190+
: ExprAST(Expr_Print, std::move(loc)), arg(std::move(arg)) {}
188191

189192
ExprAST *getArg() { return arg.get(); }
190193

@@ -203,7 +206,7 @@ class PrototypeAST {
203206
public:
204207
PrototypeAST(Location location, const std::string &name,
205208
std::vector<std::unique_ptr<VariableExprAST>> args)
206-
: location(location), name(name), args(std::move(args)) {}
209+
: location(std::move(location)), name(name), args(std::move(args)) {}
207210

208211
const Location &loc() { return location; }
209212
llvm::StringRef getName() const { return name; }

0 commit comments

Comments
 (0)