diff --git a/libsrc/core/.clang-tidy b/libsrc/core/.clang-tidy index 5742a3d8..9ceddce8 100644 --- a/libsrc/core/.clang-tidy +++ b/libsrc/core/.clang-tidy @@ -1,5 +1,8 @@ -Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion,-google-explicit-constructor,-hicpp-explicit-conversions,-google-runtime-int,-llvm-header-guard,-modernize-pass-by-value' +Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion,-google-explicit-constructor,-hicpp-explicit-conversions,-google-runtime-int,-llvm-header-guard,-modernize-pass-by-value,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers' CheckOptions: - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor value: 1 + - key: cppcoreguidelines-macro-usage.AllowedRegexp + value: NGCORE_*|NETGEN_*|NG_EXCEPTION* + WarningsAsErrors: '*' diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index 4dfa6628..c708c596 100644 --- a/libsrc/core/archive.hpp +++ b/libsrc/core/archive.hpp @@ -1,6 +1,7 @@ #ifndef NETGEN_CORE_ARCHIVE_HPP #define NETGEN_CORE_ARCHIVE_HPP +#include // for array #include // for complex #include // for size_t, strlen #include // for ifstream, ofstream @@ -657,7 +658,7 @@ namespace ngcore class NGCORE_API BinaryOutArchive : public Archive { static constexpr size_t BUFFERSIZE = 1024; - char buffer[BUFFERSIZE] = {}; + std::array buffer{}; size_t ptr = 0; protected: std::shared_ptr stream; @@ -701,7 +702,7 @@ namespace ngcore } Archive & operator & (char *& str) override { - long len = str ? strlen (str) : -1; + long len = str ? static_cast(strlen (str)) : -1; (*this) & len; FlushBuffer(); if(len > 0) @@ -838,7 +839,7 @@ namespace ngcore } Archive & operator & (char *& str) override { - long len = str ? strlen (str) : -1; + long len = str ? static_cast(strlen (str)) : -1; *this & len; if(len > 0) { @@ -994,7 +995,7 @@ namespace ngcore std::string(pybind11::str(output))); return output; }, - [](pybind11::tuple state) + [](const pybind11::tuple & state) { T* val = nullptr; GetLogger("Archive")->trace("State for unpickling of object of type {} = {}", diff --git a/libsrc/core/paje_trace.cpp b/libsrc/core/paje_trace.cpp index 66a3b8a1..f9c5ba89 100644 --- a/libsrc/core/paje_trace.cpp +++ b/libsrc/core/paje_trace.cpp @@ -98,7 +98,7 @@ namespace ngcore // return time in milliseconds as double // return std::chrono::duration(t-start_time).count()*1000.0; // return std::chrono::duration(t-start_time).count() / 2.7e3; - return 1000.0*(t-start_time) / ticks_per_second; + return 1000.0*static_cast(t-start_time) / ticks_per_second; } enum PType @@ -241,7 +241,9 @@ namespace ngcore } int alias = ++alias_counter; - double r,g,b; + double r; + double g; + double b; Hue2RGB( hue, r, g, b ); fprintf( ctrace_stream, "%d\ta%d\ta%d\t\"%s\"\t\"%.15g %.15g %.15g\"\n", PajeDefineEntityValue, alias, type, name.c_str(), r,g,b ); // NOLINT return alias; @@ -346,7 +348,7 @@ namespace ngcore void PajeTrace::Write( const std::string & filename ) { - int n_events = jobs.size() + timer_events.size(); + auto n_events = jobs.size() + timer_events.size(); for(auto & vtasks : tasks) n_events += vtasks.size(); @@ -558,11 +560,11 @@ namespace ngcore // Write HTML file drawing a sunburst chart with cumulated timings struct TreeNode { - int id; + int id = 0; std::map children; - double time; + double time = 0.0; std::string name; - TTimePoint start_time; + TTimePoint start_time = 0; }; void PrintNode (const TreeNode &n, int &level, std::ofstream & f); @@ -627,7 +629,7 @@ namespace ngcore std::sort (events.begin(), events.end()); - root.time = 1000.0*(stop_time-start_time)/ticks_per_second; + root.time = 1000.0*static_cast(stop_time-start_time)/ticks_per_second; for(auto & event : events) { @@ -652,7 +654,7 @@ namespace ngcore } else { - double time = 1000.0*(event.time-current->start_time)/ticks_per_second; + double time = 1000.0*static_cast(event.time-current->start_time)/ticks_per_second; current->time += time; current = node_stack.back(); current->time -= time; diff --git a/libsrc/core/profiler.cpp b/libsrc/core/profiler.cpp index 3302342d..1190e6fe 100644 --- a/libsrc/core/profiler.cpp +++ b/libsrc/core/profiler.cpp @@ -8,10 +8,10 @@ namespace ngcore std::string NgProfiler::filename; - size_t NgProfiler::dummy_thread_times[NgProfiler::SIZE]; - size_t * NgProfiler::thread_times = NgProfiler::dummy_thread_times; // NOLINT - size_t NgProfiler::dummy_thread_flops[NgProfiler::SIZE]; - size_t * NgProfiler::thread_flops = NgProfiler::dummy_thread_flops; // NOLINT + std::array NgProfiler::dummy_thread_times; + size_t * NgProfiler::thread_times = NgProfiler::dummy_thread_times.data(); // NOLINT + std::array NgProfiler::dummy_thread_flops; + size_t * NgProfiler::thread_flops = NgProfiler::dummy_thread_flops.data(); // NOLINT std::shared_ptr NgProfiler::logger = GetLogger("Profiler"); // NOLINT diff --git a/libsrc/core/profiler.hpp b/libsrc/core/profiler.hpp index 5a9b16e1..4e4b565c 100644 --- a/libsrc/core/profiler.hpp +++ b/libsrc/core/profiler.hpp @@ -1,6 +1,7 @@ #ifndef NETGEN_CORE_PROFILER_HPP #define NETGEN_CORE_PROFILER_HPP +#include #include #include @@ -35,8 +36,8 @@ namespace ngcore NGCORE_API static TTimePoint * thread_times; NGCORE_API static TTimePoint * thread_flops; NGCORE_API static std::shared_ptr logger; - NGCORE_API static size_t dummy_thread_times[NgProfiler::SIZE]; - NGCORE_API static size_t dummy_thread_flops[NgProfiler::SIZE]; + NGCORE_API static std::array dummy_thread_times; + NGCORE_API static std::array dummy_thread_flops; private: NGCORE_API static std::string filename; diff --git a/libsrc/core/utils.cpp b/libsrc/core/utils.cpp index 0347d244..5f5376bd 100644 --- a/libsrc/core/utils.cpp +++ b/libsrc/core/utils.cpp @@ -33,7 +33,7 @@ namespace ngcore auto tick_end = GetTimeCounter(); tend = WallTime(); - return (tick_end-tick_start)/(tend-tstart); + return static_cast(tick_end-tick_start)/(tend-tstart); }(); const std::chrono::time_point wall_time_start = TClock::now();