Fix/disable some core guidelines warnings

This commit is contained in:
Matthias Hochsteger 2019-04-24 22:21:05 +02:00
parent 81a06181b4
commit 0525b8b61f
6 changed files with 27 additions and 20 deletions

View File

@ -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: '*'

View File

@ -1,6 +1,7 @@
#ifndef NETGEN_CORE_ARCHIVE_HPP
#define NETGEN_CORE_ARCHIVE_HPP
#include <array> // for array
#include <complex> // for complex
#include <cstring> // for size_t, strlen
#include <fstream> // 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<char,BUFFERSIZE> buffer{};
size_t ptr = 0;
protected:
std::shared_ptr<std::ostream> stream;
@ -701,7 +702,7 @@ namespace ngcore
}
Archive & operator & (char *& str) override
{
long len = str ? strlen (str) : -1;
long len = str ? static_cast<long>(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<long>(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 {} = {}",

View File

@ -98,7 +98,7 @@ namespace ngcore
// return time in milliseconds as double
// return std::chrono::duration<double>(t-start_time).count()*1000.0;
// return std::chrono::duration<double>(t-start_time).count() / 2.7e3;
return 1000.0*(t-start_time) / ticks_per_second;
return 1000.0*static_cast<double>(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<int, TreeNode> 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<double>(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<double>(event.time-current->start_time)/ticks_per_second;
current->time += time;
current = node_stack.back();
current->time -= time;

View File

@ -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<size_t,NgProfiler::SIZE> NgProfiler::dummy_thread_times;
size_t * NgProfiler::thread_times = NgProfiler::dummy_thread_times.data(); // NOLINT
std::array<size_t,NgProfiler::SIZE> NgProfiler::dummy_thread_flops;
size_t * NgProfiler::thread_flops = NgProfiler::dummy_thread_flops.data(); // NOLINT
std::shared_ptr<Logger> NgProfiler::logger = GetLogger("Profiler"); // NOLINT

View File

@ -1,6 +1,7 @@
#ifndef NETGEN_CORE_PROFILER_HPP
#define NETGEN_CORE_PROFILER_HPP
#include <array>
#include <chrono>
#include <string>
@ -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> 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<size_t, NgProfiler::SIZE> dummy_thread_times;
NGCORE_API static std::array<size_t, NgProfiler::SIZE> dummy_thread_flops;
private:
NGCORE_API static std::string filename;

View File

@ -33,7 +33,7 @@ namespace ngcore
auto tick_end = GetTimeCounter();
tend = WallTime();
return (tick_end-tick_start)/(tend-tstart);
return static_cast<double>(tick_end-tick_start)/(tend-tstart);
}();
const std::chrono::time_point<TClock> wall_time_start = TClock::now();