Skip to content

Commit

Permalink
fixup! Fix somes issues spotted by SonarSource
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan0x committed Sep 28, 2023
1 parent dde4cc7 commit 9f3f3af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,6 @@ void CodegenCppVisitor::print_table_check_function(const Block& node) {
auto use_table_var = get_variable_name(naming::USE_TABLE_VARIABLE);
auto tmin_name = get_variable_name("tmin_" + name);
auto mfac_name = get_variable_name("mfac_" + name);
const auto& float_type = default_float_data_type();

printer->add_newline(2);
print_device_method_annotation();
Expand All @@ -1416,7 +1415,7 @@ void CodegenCppVisitor::print_table_check_function(const Block& node) {

printer->add_line("static bool make_table = true;");
for (const auto& variable: depend_variables) {
printer->fmt_line("static {} save_{};", float_type, variable->get_node_name());
printer->fmt_line("static {} save_{};", default_float_data_type(), variable->get_node_name());
}

for (const auto& variable: depend_variables) {
Expand Down
10 changes: 7 additions & 3 deletions src/language/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,17 @@ def get_typename(self):

return type_name

@classmethod
def add_const_rvalue_reference(cls, type):
return f"const {type}&"

def get_rvalue_typename(self):
"""returns rvalue reference type of the node"""
typename = self.get_typename()
if self.is_vector:
return "const " + typename + "&"
return self.add_const_rvalue_reference(typename)
if self.is_base_type_node and not self.is_integral_type_node or self.is_ptr_excluded_node:
return "const " + typename + "&"
return self.add_const_rvalue_reference(typename)
return typename

def get_shared_typename(self):
Expand Down Expand Up @@ -245,7 +249,7 @@ def member_rvalue_typename(self):
"""returns rvalue reference type when used as returned or parameter type"""
typename = self.member_typename
if not self.is_integral_type_node:
return "const " + typename + "&"
return self.add_const_rvalue_reference(typename)
return typename

def get_add_methods_declaration(self):
Expand Down
2 changes: 1 addition & 1 deletion src/visitors/loop_unroll_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static std::shared_ptr<ast::ExpressionStatement> unroll_for_loop(
}

/// create new statement representing unrolled loop
auto block = new ast::StatementBlock(statements);
auto block = std::make_shared<ast::StatementBlock>(statements);
return std::make_shared<ast::ExpressionStatement>(block);
}

Expand Down

0 comments on commit 9f3f3af

Please sign in to comment.