Skip to content

Commit 90af423

Browse files
Fix clang-tidy-19 errors (#8509)
1 parent 5264706 commit 90af423

14 files changed

+33
-33
lines changed

src/Buffer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class Buffer {
222222

223223
template<typename... Args,
224224
typename = typename std::enable_if<Internal::all_ints_and_optional_name<Args...>::value>::type>
225-
explicit Buffer(int first, Args... rest)
225+
explicit Buffer(int first, const Args &...rest)
226226
: Buffer(Runtime::Buffer<T, Dims>(Internal::get_shape_from_start_of_parameter_pack(first, rest...)),
227227
Internal::get_name_from_end_of_parameter_pack(rest...)) {
228228
}

src/CodeGen_Vulkan_Dev.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class CodeGen_Vulkan_Dev : public CodeGen_GPU_Dev {
153153

154154
// Returns Phi node inputs.
155155
template<typename StmtOrExpr>
156-
SpvFactory::BlockVariables emit_if_then_else(const Expr &condition, StmtOrExpr then_case, StmtOrExpr else_case);
156+
SpvFactory::BlockVariables emit_if_then_else(const Expr &condition, const StmtOrExpr &then_case, const StmtOrExpr &else_case);
157157

158158
template<typename T>
159159
SpvId declare_constant_int(Type value_type, int64_t value);
@@ -1936,7 +1936,7 @@ void CodeGen_Vulkan_Dev::SPIRV_Emitter::visit(const Realize *) {
19361936
template<typename StmtOrExpr>
19371937
SpvFactory::BlockVariables
19381938
CodeGen_Vulkan_Dev::SPIRV_Emitter::emit_if_then_else(const Expr &condition,
1939-
StmtOrExpr then_case, StmtOrExpr else_case) {
1939+
const StmtOrExpr &then_case, const StmtOrExpr &else_case) {
19401940

19411941
SpvId merge_block_id = builder.reserve_id(SpvBlockId);
19421942
SpvId if_block_id = builder.reserve_id(SpvBlockId);

src/Deserialization.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Deserializer {
5151
// does not apply to union types like Stmt and Expr or enum types like MemoryType
5252
template<typename src, typename dst>
5353
std::vector<dst> deserialize_vector(const flatbuffers::Vector<::flatbuffers::Offset<src>> *flatbuffer_vec,
54-
std::function<dst(Deserializer &, const src *)> deserialize_func) {
54+
const std::function<dst(Deserializer &, const src *)> &deserialize_func) {
5555
user_assert(flatbuffer_vec != nullptr) << "deserializing a null vector\n";
5656
std::vector<dst> result;
5757
result.reserve(flatbuffer_vec->size());

src/ExternFuncArgument.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct ExternFuncArgument {
3131
}
3232

3333
template<typename T, int Dims>
34-
ExternFuncArgument(Buffer<T, Dims> b)
34+
ExternFuncArgument(const Buffer<T, Dims> &b)
3535
: arg_type(BufferArg), buffer(b) {
3636
}
3737
ExternFuncArgument(Expr e)

src/Func.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -3313,7 +3313,7 @@ Stage FuncRef::func_ref_update(const Tuple &e, int init_val) {
33133313
}
33143314

33153315
template<typename BinaryOp>
3316-
Stage FuncRef::func_ref_update(Expr e, int init_val) {
3316+
Stage FuncRef::func_ref_update(const Expr &e, int init_val) {
33173317
// Don't do this: we want to allow the RHS to be implicitly cast to the type of LHS.
33183318
// func.check_types(e);
33193319

@@ -3323,8 +3323,8 @@ Stage FuncRef::func_ref_update(Expr e, int init_val) {
33233323
return self_ref = BinaryOp()(Expr(self_ref), e);
33243324
}
33253325

3326-
Stage FuncRef::operator+=(Expr e) {
3327-
return func_ref_update<std::plus<Expr>>(std::move(e), 0);
3326+
Stage FuncRef::operator+=(const Expr &e) {
3327+
return func_ref_update<std::plus<Expr>>(e, 0);
33283328
}
33293329

33303330
Stage FuncRef::operator+=(const Tuple &e) {
@@ -3343,8 +3343,8 @@ Stage FuncRef::operator+=(const FuncRef &e) {
33433343
}
33443344
}
33453345

3346-
Stage FuncRef::operator*=(Expr e) {
3347-
return func_ref_update<std::multiplies<Expr>>(std::move(e), 1);
3346+
Stage FuncRef::operator*=(const Expr &e) {
3347+
return func_ref_update<std::multiplies<Expr>>(e, 1);
33483348
}
33493349

33503350
Stage FuncRef::operator*=(const Tuple &e) {
@@ -3363,8 +3363,8 @@ Stage FuncRef::operator*=(const FuncRef &e) {
33633363
}
33643364
}
33653365

3366-
Stage FuncRef::operator-=(Expr e) {
3367-
return func_ref_update<std::minus<Expr>>(std::move(e), 0);
3366+
Stage FuncRef::operator-=(const Expr &e) {
3367+
return func_ref_update<std::minus<Expr>>(e, 0);
33683368
}
33693369

33703370
Stage FuncRef::operator-=(const Tuple &e) {
@@ -3383,8 +3383,8 @@ Stage FuncRef::operator-=(const FuncRef &e) {
33833383
}
33843384
}
33853385

3386-
Stage FuncRef::operator/=(Expr e) {
3387-
return func_ref_update<std::divides<Expr>>(std::move(e), 1);
3386+
Stage FuncRef::operator/=(const Expr &e) {
3387+
return func_ref_update<std::divides<Expr>>(e, 1);
33883388
}
33893389

33903390
Stage FuncRef::operator/=(const Tuple &e) {

src/Func.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class FuncRef {
505505
* already have a pure definition, init_val will be used as RHS in
506506
* the initial function definition. */
507507
template<typename BinaryOp>
508-
Stage func_ref_update(Expr e, int init_val);
508+
Stage func_ref_update(const Expr &e, int init_val);
509509

510510
public:
511511
FuncRef(const Internal::Function &, const std::vector<Expr> &,
@@ -528,7 +528,7 @@ class FuncRef {
528528
* pure definition, this sets it to zero.
529529
*/
530530
// @{
531-
Stage operator+=(Expr);
531+
Stage operator+=(const Expr &);
532532
Stage operator+=(const Tuple &);
533533
Stage operator+=(const FuncRef &);
534534
// @}
@@ -539,7 +539,7 @@ class FuncRef {
539539
* not already have a pure definition, this sets it to zero.
540540
*/
541541
// @{
542-
Stage operator-=(Expr);
542+
Stage operator-=(const Expr &);
543543
Stage operator-=(const Tuple &);
544544
Stage operator-=(const FuncRef &);
545545
// @}
@@ -550,7 +550,7 @@ class FuncRef {
550550
* definition, this sets it to 1.
551551
*/
552552
// @{
553-
Stage operator*=(Expr);
553+
Stage operator*=(const Expr &);
554554
Stage operator*=(const Tuple &);
555555
Stage operator*=(const FuncRef &);
556556
// @}
@@ -561,7 +561,7 @@ class FuncRef {
561561
* function does not already have a pure definition, this sets it to 1.
562562
*/
563563
// @{
564-
Stage operator/=(Expr);
564+
Stage operator/=(const Expr &);
565565
Stage operator/=(const Tuple &);
566566
Stage operator/=(const FuncRef &);
567567
// @}

src/LLVM_Output.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace {
4242
// If data too large, assert.
4343
// Return the offset at which 'data' was written.
4444
template<typename T>
45-
size_t emit_padded(std::ostream &out, T data, size_t size) {
45+
size_t emit_padded(std::ostream &out, const T &data, size_t size) {
4646
size_t pos = out.tellp();
4747
out << data;
4848
size_t written = (size_t)out.tellp() - pos;

src/RDom.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class RDom {
217217
}
218218

219219
template<typename... Args>
220-
HALIDE_NO_USER_CODE_INLINE RDom(Expr min, Expr extent, Args &&...args) {
220+
HALIDE_NO_USER_CODE_INLINE RDom(const Expr &min, const Expr &extent, Args &&...args) {
221221
// This should really just be a delegating constructor, but I couldn't make
222222
// that work with variadic template unpacking in visual studio 2013
223223
Region region;

src/Simplify_Let.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FindVarUses : public IRVisitor {
5353
};
5454

5555
template<typename StmtOrExpr>
56-
void find_var_uses(StmtOrExpr x, std::unordered_set<std::string> &unused_vars) {
56+
void find_var_uses(const StmtOrExpr &x, std::unordered_set<std::string> &unused_vars) {
5757
FindVarUses counter(unused_vars);
5858
x.accept(&counter);
5959
}

src/StmtToHTML.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ class HTMLCodePrinter : public IRVisitor {
11971197
}
11981198

11991199
/* Helper functions for printing IR nodes */
1200-
void print_constant(std::string cls, Expr c) {
1200+
void print_constant(const std::string &cls, const Expr &c) {
12011201
print_opening_tag("span", cls, type_to_string(c.type()));
12021202
stream << c;
12031203
print_closing_tag("span");
@@ -1209,7 +1209,7 @@ class HTMLCodePrinter : public IRVisitor {
12091209
print_closing_tag("span");
12101210
}
12111211

1212-
void print_binary_op(const Expr &a, const Expr &b, std::string op, Type result_type) {
1212+
void print_binary_op(const Expr &a, const Expr &b, const std::string &op, Type result_type) {
12131213
std::string result_type_str = type_to_string(result_type);
12141214
print_opening_tag("span", "BinaryOp");
12151215
print_html_element("span", "matched", "(", result_type_str);
@@ -1222,7 +1222,7 @@ class HTMLCodePrinter : public IRVisitor {
12221222
print_closing_tag("span");
12231223
}
12241224

1225-
void print_function_call(std::string fn_name, const std::vector<Expr> &args, const std::string &tooltip) {
1225+
void print_function_call(const std::string &fn_name, const std::vector<Expr> &args, const std::string &tooltip) {
12261226
print_opening_tag("span", "matched");
12271227
print_html_element("span", "Symbol matched", fn_name, tooltip);
12281228
print_text("(");
@@ -1329,7 +1329,7 @@ class HTMLCodePrinter : public IRVisitor {
13291329
}
13301330

13311331
// Prints a cost button/indicator
1332-
void print_cost_btn(int line_cost, int block_cost, int max_line_cost, int max_block_cost, std::string id, std::string prefix) {
1332+
void print_cost_btn(int line_cost, int block_cost, int max_line_cost, int max_block_cost, const std::string &id, const std::string &prefix) {
13331333
const int num_cost_buckets = 20;
13341334
const auto compand = [](int v) -> int { return (int)std::sqrt(v * 10); };
13351335

src/Util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ struct ScopedValue {
388388
: var(var), old_value(var) {
389389
}
390390
/** Preserve the old value, then set the var to a new value. */
391-
ScopedValue(T &var, T new_value)
391+
ScopedValue(T &var, const T &new_value)
392392
: var(var), old_value(var) {
393393
var = new_value;
394394
}

src/autoschedulers/common/cmdline.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ std::string readable_typename() {
161161
}
162162

163163
template<class T>
164-
std::string default_value(T def) {
164+
std::string default_value(const T &def) {
165165
return detail::lexical_cast<std::string>(def);
166166
}
167167

@@ -397,7 +397,7 @@ class parser {
397397
char short_name = 0,
398398
const std::string &desc = "",
399399
bool need = true,
400-
const T def = T()) {
400+
const T &def = T()) {
401401
add(name, short_name, desc, need, def, default_reader<T>());
402402
}
403403

@@ -406,7 +406,7 @@ class parser {
406406
char short_name = 0,
407407
const std::string &desc = "",
408408
bool need = true,
409-
const T def = T(),
409+
const T &def = T(),
410410
F reader = F()) {
411411
if (options.count(name)) {
412412
throw_cmdline_error("multiple definition: " + name);
@@ -879,7 +879,7 @@ class parser {
879879
option_with_value_with_reader(const std::string &name,
880880
char short_name,
881881
bool need,
882-
const T def,
882+
const T &def,
883883
const std::string &desc,
884884
F reader)
885885
: option_with_value<T>(name, short_name, need, def, desc), reader(reader) {

src/autoschedulers/li2018/GradientAutoscheduler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ void parallelize_vars_and_rvars_cpu(
535535
template<typename FuncOrStage>
536536
void parallelize_vars_and_rvars(
537537
const GradientAutoschedulerParams &params,
538-
FuncOrStage func_or_stage,
538+
const FuncOrStage &func_or_stage,
539539
int natural_vector_size,
540540
bool is_pure_def,
541541
const std::vector<Var> &vars,

src/runtime/HalideBuffer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ class Buffer {
19911991
/** Make a buffer with the same shape and memory nesting order as
19921992
* another buffer. It may have a different type. */
19931993
template<typename T2, int D2, int S2>
1994-
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(Buffer<T2, D2, S2> src,
1994+
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(const Buffer<T2, D2, S2> &src,
19951995
void *(*allocate_fn)(size_t) = nullptr,
19961996
void (*deallocate_fn)(void *) = nullptr) {
19971997
static_assert(Dims == D2 || Dims == AnyDims);

0 commit comments

Comments
 (0)