Skip to content

Commit

Permalink
Fix clang-tidy-19 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson committed Dec 16, 2024
1 parent 8646bc8 commit 097196c
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class Buffer {

template<typename... Args,
typename = typename std::enable_if<Internal::all_ints_and_optional_name<Args...>::value>::type>
explicit Buffer(int first, Args... rest)
explicit Buffer(int first, const Args &...rest)
: Buffer(Runtime::Buffer<T, Dims>(Internal::get_shape_from_start_of_parameter_pack(first, rest...)),
Internal::get_name_from_end_of_parameter_pack(rest...)) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGen_Vulkan_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class CodeGen_Vulkan_Dev : public CodeGen_GPU_Dev {

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

template<typename T>
SpvId declare_constant_int(Type value_type, int64_t value);
Expand Down Expand Up @@ -1913,7 +1913,7 @@ void CodeGen_Vulkan_Dev::SPIRV_Emitter::visit(const Realize *) {
template<typename StmtOrExpr>
SpvFactory::BlockVariables
CodeGen_Vulkan_Dev::SPIRV_Emitter::emit_if_then_else(const Expr &condition,
StmtOrExpr then_case, StmtOrExpr else_case) {
const StmtOrExpr &then_case, const StmtOrExpr &else_case) {

SpvId merge_block_id = builder.reserve_id(SpvBlockId);
SpvId if_block_id = builder.reserve_id(SpvBlockId);
Expand Down
2 changes: 1 addition & 1 deletion src/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Deserializer {
// does not apply to union types like Stmt and Expr or enum types like MemoryType
template<typename src, typename dst>
std::vector<dst> deserialize_vector(const flatbuffers::Vector<::flatbuffers::Offset<src>> *flatbuffer_vec,
std::function<dst(Deserializer &, const src *)> deserialize_func) {
const std::function<dst(Deserializer &, const src *)> &deserialize_func) {
user_assert(flatbuffer_vec != nullptr) << "deserializing a null vector\n";
std::vector<dst> result;
result.reserve(flatbuffer_vec->size());
Expand Down
2 changes: 1 addition & 1 deletion src/ExternFuncArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct ExternFuncArgument {
}

template<typename T, int Dims>
ExternFuncArgument(Buffer<T, Dims> b)
ExternFuncArgument(const Buffer<T, Dims> &b)
: arg_type(BufferArg), buffer(b) {
}
ExternFuncArgument(Expr e)
Expand Down
18 changes: 9 additions & 9 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,7 @@ Stage FuncRef::func_ref_update(const Tuple &e, int init_val) {
}

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

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

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

Stage FuncRef::operator+=(const Tuple &e) {
Expand All @@ -3343,8 +3343,8 @@ Stage FuncRef::operator+=(const FuncRef &e) {
}
}

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

Stage FuncRef::operator*=(const Tuple &e) {
Expand All @@ -3363,8 +3363,8 @@ Stage FuncRef::operator*=(const FuncRef &e) {
}
}

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

Stage FuncRef::operator-=(const Tuple &e) {
Expand All @@ -3383,8 +3383,8 @@ Stage FuncRef::operator-=(const FuncRef &e) {
}
}

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

Stage FuncRef::operator/=(const Tuple &e) {
Expand Down
10 changes: 5 additions & 5 deletions src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class FuncRef {
* already have a pure definition, init_val will be used as RHS in
* the initial function definition. */
template<typename BinaryOp>
Stage func_ref_update(Expr e, int init_val);
Stage func_ref_update(const Expr &e, int init_val);

public:
FuncRef(const Internal::Function &, const std::vector<Expr> &,
Expand All @@ -528,7 +528,7 @@ class FuncRef {
* pure definition, this sets it to zero.
*/
// @{
Stage operator+=(Expr);
Stage operator+=(const Expr &);
Stage operator+=(const Tuple &);
Stage operator+=(const FuncRef &);
// @}
Expand All @@ -539,7 +539,7 @@ class FuncRef {
* not already have a pure definition, this sets it to zero.
*/
// @{
Stage operator-=(Expr);
Stage operator-=(const Expr &);
Stage operator-=(const Tuple &);
Stage operator-=(const FuncRef &);
// @}
Expand All @@ -550,7 +550,7 @@ class FuncRef {
* definition, this sets it to 1.
*/
// @{
Stage operator*=(Expr);
Stage operator*=(const Expr &);
Stage operator*=(const Tuple &);
Stage operator*=(const FuncRef &);
// @}
Expand All @@ -561,7 +561,7 @@ class FuncRef {
* function does not already have a pure definition, this sets it to 1.
*/
// @{
Stage operator/=(Expr);
Stage operator/=(const Expr &);
Stage operator/=(const Tuple &);
Stage operator/=(const FuncRef &);
// @}
Expand Down
2 changes: 1 addition & 1 deletion src/LLVM_Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace {
// If data too large, assert.
// Return the offset at which 'data' was written.
template<typename T>
size_t emit_padded(std::ostream &out, T data, size_t size) {
size_t emit_padded(std::ostream &out, const T &data, size_t size) {
size_t pos = out.tellp();
out << data;
size_t written = (size_t)out.tellp() - pos;
Expand Down
2 changes: 1 addition & 1 deletion src/RDom.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class RDom {
}

template<typename... Args>
HALIDE_NO_USER_CODE_INLINE RDom(Expr min, Expr extent, Args &&...args) {
HALIDE_NO_USER_CODE_INLINE RDom(const Expr &min, const Expr &extent, Args &&...args) {
// This should really just be a delegating constructor, but I couldn't make
// that work with variadic template unpacking in visual studio 2013
Region region;
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify_Let.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FindVarUses : public IRVisitor {
};

template<typename StmtOrExpr>
void find_var_uses(StmtOrExpr x, std::unordered_set<std::string> &unused_vars) {
void find_var_uses(const StmtOrExpr &x, std::unordered_set<std::string> &unused_vars) {
FindVarUses counter(unused_vars);
x.accept(&counter);
}
Expand Down
8 changes: 4 additions & 4 deletions src/StmtToHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ class HTMLCodePrinter : public IRVisitor {
}

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

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

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

// Prints a cost button/indicator
void print_cost_btn(int line_cost, int block_cost, int max_line_cost, int max_block_cost, std::string id, std::string prefix) {
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) {
const int num_cost_buckets = 20;
const auto compand = [](int v) -> int { return (int)std::sqrt(v * 10); };

Expand Down
2 changes: 1 addition & 1 deletion src/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ struct ScopedValue {
: var(var), old_value(var) {
}
/** Preserve the old value, then set the var to a new value. */
ScopedValue(T &var, T new_value)
ScopedValue(T &var, const T &new_value)
: var(var), old_value(var) {
var = new_value;
}
Expand Down
8 changes: 4 additions & 4 deletions src/autoschedulers/common/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ std::string readable_typename() {
}

template<class T>
std::string default_value(T def) {
std::string default_value(const T &def) {
return detail::lexical_cast<std::string>(def);
}

Expand Down Expand Up @@ -397,7 +397,7 @@ class parser {
char short_name = 0,
const std::string &desc = "",
bool need = true,
const T def = T()) {
const T &def = T()) {
add(name, short_name, desc, need, def, default_reader<T>());
}

Expand All @@ -406,7 +406,7 @@ class parser {
char short_name = 0,
const std::string &desc = "",
bool need = true,
const T def = T(),
const T &def = T(),
F reader = F()) {
if (options.count(name)) {
throw_cmdline_error("multiple definition: " + name);
Expand Down Expand Up @@ -879,7 +879,7 @@ class parser {
option_with_value_with_reader(const std::string &name,
char short_name,
bool need,
const T def,
const T &def,
const std::string &desc,
F reader)
: option_with_value<T>(name, short_name, need, def, desc), reader(reader) {
Expand Down
2 changes: 1 addition & 1 deletion src/autoschedulers/li2018/GradientAutoscheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void parallelize_vars_and_rvars_cpu(
template<typename FuncOrStage>
void parallelize_vars_and_rvars(
const GradientAutoschedulerParams &params,
FuncOrStage func_or_stage,
const FuncOrStage &func_or_stage,
int natural_vector_size,
bool is_pure_def,
const std::vector<Var> &vars,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/HalideBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ class Buffer {
/** Make a buffer with the same shape and memory nesting order as
* another buffer. It may have a different type. */
template<typename T2, int D2, int S2>
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(Buffer<T2, D2, S2> src,
static Buffer<T, Dims, InClassDimStorage> make_with_shape_of(const Buffer<T2, D2, S2> &src,
void *(*allocate_fn)(size_t) = nullptr,
void (*deallocate_fn)(void *) = nullptr) {
static_assert(Dims == D2 || Dims == AnyDims);
Expand Down

0 comments on commit 097196c

Please sign in to comment.