diff --git a/.clang-tidy b/.clang-tidy index 7d637c829..badab5d0e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,4 @@ -Checks: 'modernize-*' +Checks: 'modernize-use-override' AnalyzeTemporaryDtors: false HeaderFilterRegex: '.*' FormatStyle: file diff --git a/cmake/AkantuCleaning.cmake b/cmake/AkantuCleaning.cmake index 1b3d80aee..f41eb399e 100644 --- a/cmake/AkantuCleaning.cmake +++ b/cmake/AkantuCleaning.cmake @@ -1,66 +1,77 @@ #=============================================================================== # @file AkantuCleaning.cmake # # @author Nicolas Richart # # @date creation: Thu Jun 1, 2017 # # @brief set of tools to clean the code # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . #=============================================================================== # Adding clang-format target if executable is found find_program(CLANG_FORMAT "clang-format") mark_as_advanced(CLANG_FORMAT) macro(register_code_to_format) if(CLANG_FORMAT) add_custom_target( clang-format-all COMMAND ${CLANG_FORMAT} -i -style=file ${ARGN} ) endif() endmacro() # Adding clang-tidy target if executable is found find_program(CLANG_TIDY "clang-tidy") mark_as_advanced(CLANG_TIDY) macro(register_target_to_tidy target) if(CLANG_TIDY) get_target_property(_sources ${target} SOURCES) set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation" FORCE) - add_custom_target( - clang-tidy-${target} - COMMAND ${CLANG_TIDY} - -quiet - -p=${PROJECT_BINARY_DIR} - -export-fixes=${PROJECT_BINARY_DIR}/clang-tidy-${target}.yaml - ${_sources} - COMMENT "Tidying ${target}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/clang-tidy) + + set(_depends) + + foreach(_src ${_sources}) + get_filename_component(_src_dir ${_src} DIRECTORY) + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/clang-tidy/${_src_dir}) + + add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml + COMMAND ${CLANG_TIDY} + -p=${PROJECT_BINARY_DIR} + -export-fixes=${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml + ${_src} + COMMENT "Tidying ${_src}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + list(APPEND _depends ${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml) + endforeach() + add_custom_target(clang-tidy DEPENDS ${_depends}) endif() endmacro() diff --git a/src/common/aka_array_tmpl.hh b/src/common/aka_array_tmpl.hh index e20a4dcf0..174f8e1c0 100644 --- a/src/common/aka_array_tmpl.hh +++ b/src/common/aka_array_tmpl.hh @@ -1,1549 +1,1538 @@ /** * @file aka_array_tmpl.hh * * @author Nicolas Richart * * @date creation: Thu Jul 15 2010 * @date last modification: Fri Jan 22 2016 * * @brief Inline functions of the classes Array and ArrayBase * * @section LICENSE * * Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de * Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des * Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ /* Inline Functions Array */ /* -------------------------------------------------------------------------- */ #include "aka_array.hh" /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_AKA_ARRAY_TMPL_HH__ #define __AKANTU_AKA_ARRAY_TMPL_HH__ namespace akantu { /* -------------------------------------------------------------------------- */ template inline T & Array::operator()(UInt i, UInt j) { AKANTU_DEBUG_ASSERT(size > 0, "The array \"" << id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < size) && (j < nb_component), "The value at position [" << i << "," << j << "] is out of range in array \"" << id << "\""); return values[i * nb_component + j]; } /* -------------------------------------------------------------------------- */ template inline const T & Array::operator()(UInt i, UInt j) const { AKANTU_DEBUG_ASSERT(size > 0, "The array \"" << id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < size) && (j < nb_component), "The value at position [" << i << "," << j << "] is out of range in array \"" << id << "\""); return values[i * nb_component + j]; } template inline T & Array::operator[](UInt i) { AKANTU_DEBUG_ASSERT(size > 0, "The array \"" << id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < size * nb_component), "The value at position [" << i << "] is out of range in array \"" << id << "\""); return values[i]; } /* -------------------------------------------------------------------------- */ template inline const T & Array::operator[](UInt i) const { AKANTU_DEBUG_ASSERT(size > 0, "The array \"" << id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < size * nb_component), "The value at position [" << i << "] is out of range in array \"" << id << "\""); return values[i]; } /* -------------------------------------------------------------------------- */ /** * append a tuple to the array with the value value for all components * @param value the new last tuple or the array will contain nb_component copies * of value */ template inline void Array::push_back(const T & value) { resizeUnitialized(size + 1, true, value); } /* -------------------------------------------------------------------------- */ /** * append a tuple to the array * @param new_elem a C-array containing the values to be copied to the end of * the array */ // template // inline void Array::push_back(const T new_elem[]) { // UInt pos = size; // resizeUnitialized(size + 1, false); // T * tmp = values + nb_component * pos; // std::uninitialized_copy(new_elem, new_elem + nb_component, tmp); // } /* -------------------------------------------------------------------------- */ /** * append a matrix or a vector to the array * @param new_elem a reference to a Matrix or Vector */ template template