Skip to content

Commit 8516411

Browse files
committed
fix some warnings reported by the modernize family of clang-tidy's checks, particularly those related to mising [[nodiscard]] attributes
1 parent 1e98c94 commit 8516411

29 files changed

Lines changed: 137 additions & 125 deletions

CMakeLists.txt

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ install(FILES "${PROJECT_BINARY_DIR}/mgis-config-version.cmake"
2121
set(CMAKE_CXX_STANDARD 20)
2222
set(CXX_STANDARD_REQUIRED ON)
2323

24+
# enable tests
25+
option(enable-testing "" ON)
26+
2427
# portable-build
2528
option(enable-portable-build "produce binary that can be shared between various machine (same architecture, same gcc version, different processors" OFF)
2629

@@ -274,26 +277,30 @@ endif(enable-website)
274277

275278
add_subdirectory(docs)
276279

277-
# testing
278-
set(CTEST_CONFIGURATION_TYPE "${JOB_BUILD_CONFIGURATION}")
279-
# (must be placed *before* any add_subdirectory, cmake bug ?)
280-
enable_testing()
281-
282-
if(CMAKE_VERSION VERSION_GREATER 3.21.4)
283-
set(ctest_args )
284-
list(APPEND ctest_args --output-junit ctest-results.xml)
285-
endif(CMAKE_VERSION VERSION_GREATER 3.21.4)
286-
if(CMAKE_CONFIGURATION_TYPES)
287-
add_custom_target(check COMMAND
288-
${CMAKE_CTEST_COMMAND} ${ctest_args} -T test -C $<CONFIGURATION>)
289-
else(CMAKE_CONFIGURATION_TYPES)
290-
add_custom_target(check COMMAND
291-
${CMAKE_CTEST_COMMAND} ${ctest_args} -T test )
292-
endif(CMAKE_CONFIGURATION_TYPES)
280+
if(enable-testing)
281+
# testing
282+
set(CTEST_CONFIGURATION_TYPE "${JOB_BUILD_CONFIGURATION}")
283+
# (must be placed *before* any add_subdirectory, cmake bug ?)
284+
enable_testing()
285+
286+
if(CMAKE_VERSION VERSION_GREATER 3.21.4)
287+
set(ctest_args )
288+
list(APPEND ctest_args --output-junit ctest-results.xml)
289+
endif(CMAKE_VERSION VERSION_GREATER 3.21.4)
290+
if(CMAKE_CONFIGURATION_TYPES)
291+
add_custom_target(check COMMAND
292+
${CMAKE_CTEST_COMMAND} ${ctest_args} -T test -C $<CONFIGURATION>)
293+
else(CMAKE_CONFIGURATION_TYPES)
294+
add_custom_target(check COMMAND
295+
${CMAKE_CTEST_COMMAND} ${ctest_args} -T test )
296+
endif(CMAKE_CONFIGURATION_TYPES)
297+
endif(enable-testing)
293298

294299
add_subdirectory(include)
295300
add_subdirectory(src)
296-
add_subdirectory(tests)
301+
if(enable-testing)
302+
add_subdirectory(tests)
303+
endif(enable-testing)
297304
add_subdirectory(bindings)
298305
# shall be included after the other directories
299306
add_subdirectory(env)

INSTALL-cmake.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Options
5353
pandoc is found)
5454
- `enable-portable-build`: do not use processor specific flags.
5555
- `enable-static`: compiles static libraries
56+
- `enable-testing`: enable compilation of tests
5657
- `enable-doxygen-doc`: enable the generation of the API documentation
5758
using with `Doxygen`.
5859
- `disable-tfel`: by default, `MGIS` tries to add support for `TFEL`,

bindings/c/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_subdirectory(include)
22
add_subdirectory(src)
3-
if(MGIS_HAVE_MFRONT_SUPPORT)
3+
if(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)
44
add_subdirectory(tests)
5-
endif(MGIS_HAVE_MFRONT_SUPPORT)
5+
endif(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)

bindings/c/src/Status.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
extern "C" {
2121

2222
mgis_status mgis_report_success() {
23-
return {MGIS_SUCCESS, nullptr};
23+
return {.exit_status = MGIS_SUCCESS, .msg = nullptr};
2424
} // end of mgis_status mgis_report_success
2525

2626
mgis_status mgis_report_failure(const char* const e) {
2727
static thread_local char msg[512];
2828
::strncpy(msg, e, 511);
2929
msg[511] = '\0';
30-
return {MGIS_FAILURE, msg};
30+
return {.exit_status = MGIS_FAILURE, .msg = msg};
3131
} // end of mgis_status mgis_report_failure
3232

3333
mgis_status mgis_handle_cxx_exception() {

bindings/fenics/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_subdirectory(include)
22
add_subdirectory(src)
3-
if(MGIS_HAVE_TFEL)
3+
if(MGIS_HAVE_TFEL AND enable-testing)
44
add_subdirectory(tests)
5-
endif(MGIS_HAVE_TFEL)
5+
endif(MGIS_HAVE_TFEL AND enable-testing)

bindings/fortran/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_subdirectory(src)
22
add_subdirectory(modules)
3-
if(MGIS_HAVE_MFRONT_SUPPORT)
3+
if(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)
44
add_subdirectory(tests)
5-
endif(MGIS_HAVE_MFRONT_SUPPORT)
5+
endif(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)
66

bindings/python/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_subdirectory(src)
22
add_subdirectory(mgis)
3-
if(MGIS_HAVE_MFRONT_SUPPORT)
3+
if(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)
44
add_subdirectory(tests)
5-
endif(MGIS_HAVE_MFRONT_SUPPORT)
5+
endif(MGIS_HAVE_MFRONT_SUPPORT AND enable-testing)

bindings/python/src/Function.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#include "MGIS/Function/Function.hxx"
1212
#include "MGIS/Function/BasicLinearSpace.hxx"
1313

14-
mgis::function::FunctionView<mgis::function::BasicLinearSpace,
15-
mgis::function::FunctionDataLayoutDescription{},
16-
false>
14+
static mgis::function::FunctionView<
15+
mgis::function::BasicLinearSpace,
16+
mgis::function::FunctionDataLayoutDescription{},
17+
false>
1718
mgis_convert_to_span(const pybind11::array_t<double> &o) {
1819
using namespace mgis::function;
1920
const auto i = o.request();
@@ -26,6 +27,7 @@ mgis_convert_to_span(const pybind11::array_t<double> &o) {
2627
mgis::raise("convert_to_span: expected one dimensional array");
2728
} // end of mgis_convert_to_span
2829

30+
void declareFunction(pybind11::module_ &);
2931
void declareFunction(pybind11::module_ &m) {
3032
// FunctionView<BasicLinearSpace, FunctionDataLayoutDescription{}, false
3133
using mgis::real;

include/MGIS/Behaviour/BehaviourData.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace mgis::behaviour {
5858
*/
5959
char* error_message;
6060
//! \brief time increment
61-
mgis::real dt;
61+
real dt = real{};
6262
/*!
6363
* \brief the stiffness matrix.
6464
*

include/MGIS/Behaviour/BehaviourIntegrationFailureAnalyser.hxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ namespace mgis::behaviour::debug {
5959
* a significant overhead and is normally not required for correctly written
6060
* behaviours but data corruption may occur, so copying is safer.
6161
*/
62-
virtual bool shallCopyBehaviourDataBeforeIntegration() const noexcept = 0;
62+
[[nodiscard]] virtual bool shallCopyBehaviourDataBeforeIntegration()
63+
const noexcept = 0;
6364
//! \brief destructor
6465
virtual ~BehaviourIntegrationFailureAnalyser() noexcept;
6566
};

0 commit comments

Comments
 (0)