Skip to content

Commit

Permalink
Tackle some issues reported by SonarSource
Browse files Browse the repository at this point in the history
* Prefer C++ nested namespaces
* Fix misc issues in CodegenCppVisitor
* SonarSource: exclude external projects from analysis
  • Loading branch information
tristan0x committed Sep 29, 2023
1 parent 2355a6e commit 7814018
Show file tree
Hide file tree
Showing 115 changed files with 547 additions and 577 deletions.
7 changes: 2 additions & 5 deletions src/ast/ast_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include "symtab/symbol_table.hpp"
#include "visitors/visitor.hpp"

namespace nmodl {

/// Abstract Syntax Tree (AST) related implementations
namespace ast {
namespace nmodl::ast {

/**
* @defgroup ast AST Implementation
Expand Down Expand Up @@ -96,5 +94,4 @@ static const std::string ReactionOpNames[] = {"<->", "<<", "->"};

/** @} */ // end of ast_prop

} // namespace ast
} // namespace nmodl
} // namespace nmodl::ast
6 changes: 2 additions & 4 deletions src/codegen/codegen_acc_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "ast/protect_statement.hpp"


namespace nmodl {
namespace codegen {
namespace nmodl::codegen {

/****************************************************************************************/
/* Routines must be overloaded in backend */
Expand Down Expand Up @@ -376,5 +375,4 @@ void CodegenAccVisitor::print_dt_update_to_device() const {
get_variable_name(naming::NTHREAD_DT_VARIABLE));
}

} // namespace codegen
} // namespace nmodl
} // namespace nmodl::codegen
12 changes: 5 additions & 7 deletions src/codegen/codegen_acc_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include "codegen/codegen_cpp_visitor.hpp"


namespace nmodl {
namespace codegen {
namespace nmodl::codegen {

/**
* \addtogroup codegen_backends
Expand Down Expand Up @@ -116,13 +115,13 @@ class CodegenAccVisitor: public CodegenCppVisitor {
void print_net_send_buf_update_to_host() const override;

/// update NetSendBuffer_t count from host to device
virtual void print_net_send_buf_count_update_to_device() const override;
void print_net_send_buf_count_update_to_device() const override;

/// update dt from host to device
virtual void print_dt_update_to_device() const override;
void print_dt_update_to_device() const override;

// synchronise/wait on stream specific to NrnThread
virtual void print_device_stream_wait() const override;
void print_device_stream_wait() const override;

/// print atomic capture pragma
void print_device_atomic_capture_annotation() const override;
Expand Down Expand Up @@ -151,5 +150,4 @@ class CodegenAccVisitor: public CodegenCppVisitor {

/** \} */ // end of codegen_backends

} // namespace codegen
} // namespace nmodl
} // namespace nmodl::codegen
11 changes: 4 additions & 7 deletions src/codegen/codegen_compatibility_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
#include "utils/logger.hpp"
#include "visitors/visitor_utils.hpp"


namespace nmodl {
namespace codegen {
namespace nmodl::codegen {

const std::map<ast::AstNodeType, CodegenCompatibilityVisitor::FunctionPointer>
CodegenCompatibilityVisitor::unhandled_ast_types_func(
Expand Down Expand Up @@ -101,7 +99,7 @@ std::string CodegenCompatibilityVisitor::return_error_if_no_bbcore_read_write(
parser::CDriver driver;

driver.scan_string(verbatim_statement_string);
auto tokens = driver.all_tokens();
const auto& tokens = driver.all_tokens();

for (const auto& token: tokens) {
if (token == "bbcore_read") {
Expand Down Expand Up @@ -132,7 +130,7 @@ std::string CodegenCompatibilityVisitor::return_error_if_no_bbcore_read_write(
bool CodegenCompatibilityVisitor::find_unhandled_ast_nodes(Ast& node) const {
std::vector<ast::AstNodeType> unhandled_ast_types;
unhandled_ast_types.reserve(unhandled_ast_types_func.size());
for (auto [node_type, _]: unhandled_ast_types_func) {
for (const auto& [node_type, _]: unhandled_ast_types_func) {
unhandled_ast_types.push_back(node_type);
}
const auto& unhandled_ast_nodes = collect_nodes(node, unhandled_ast_types);
Expand All @@ -158,5 +156,4 @@ bool CodegenCompatibilityVisitor::find_unhandled_ast_nodes(Ast& node) const {
return false;
}

} // namespace codegen
} // namespace nmodl
} // namespace nmodl::codegen
6 changes: 2 additions & 4 deletions src/codegen/codegen_compatibility_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include "utils/logger.hpp"
#include "visitors/ast_visitor.hpp"

namespace nmodl {
namespace codegen {
namespace nmodl::codegen {

using namespace ast;

Expand Down Expand Up @@ -157,5 +156,4 @@ class CodegenCompatibilityVisitor: public visitor::AstVisitor {

/** \} */ // end of codegen_backends

} // namespace codegen
} // namespace nmodl
} // namespace nmodl::codegen
Loading

0 comments on commit 7814018

Please sign in to comment.