netlist: more lint corrections. (nw)

- fixed lint corrections
- added NOLINT where needed
This commit is contained in:
couriersud 2019-09-28 21:45:59 +02:00
parent 8e31f22bcd
commit 545ebe832d
17 changed files with 86 additions and 47 deletions

View File

@ -134,7 +134,7 @@ namespace analog
BJT_PNP
};
NETLIB_CONSTRUCTOR_EX(QBJT, pstring model = "NPN")
NETLIB_CONSTRUCTOR_EX(QBJT, const pstring &model = "NPN")
, m_model(*this, "MODEL", model)
, m_qtype(BJT_NPN)
{

View File

@ -360,7 +360,7 @@ namespace analog
NETLIB_OBJECT_DERIVED(D, twoterm)
{
public:
NETLIB_CONSTRUCTOR_DERIVED_EX(D, twoterm, pstring model = "D")
NETLIB_CONSTRUCTOR_DERIVED_EX(D, twoterm, const pstring &model = "D")
, m_model(*this, "MODEL", model)
, m_D(*this, "m_D")
{

View File

@ -28,6 +28,9 @@ TIDY_FLAGSX += -modernize-use-trailing-return-type
space :=
space +=
TIDY_FLAGS = $(subst $(space),,$(TIDY_FLAGSX))
TIDY_SOURCES = $(SOURCES)
#TIDY_SOURCES = $(SRC)/plib/pparser.cpp
#TIDY_FLAGS = -checks=llvm-include-order,llvm-namespace-comment,modernize-use-override,modernize-use-using -fix
#TIDY_FLAGS = -checks=llvm-include-order -fix
@ -45,8 +48,8 @@ endif
# LTO = -flto=4 -fuse-linker-plugin -flto-partition=balanced -Wodr
CFLAGS = $(LTO) -g -O3 -std=c++11 -I$(CURDIR)/.. -I$(CURDIR)/../.. $(CEXTRAFLAGS)
LDFLAGS = $(LTO) -g -O3 -std=c++11 $(LDEXTRAFLAGS)
CFLAGS = $(LTO) -g -O3 -std=c++14 -I$(CURDIR)/.. -I$(CURDIR)/../.. $(CEXTRAFLAGS)
LDFLAGS = $(LTO) -g -O3 -std=c++14 $(LDEXTRAFLAGS)
LIBS = -lpthread -ldl
CC = g++
@ -54,7 +57,7 @@ LD = @g++
MD = @mkdir
RM = @rm
DOXYGEN = @doxygen
CLANG_TIDY = clang-tidy-9
CLANG_TIDY = clang-tidy-10
TARGETS = nltool nlwav
@ -295,7 +298,7 @@ endif
#-------------------------------------------------
tidy: tidy_db
@echo running tidy
@for i in $(SOURCES); do \
@for i in $(TIDY_SOURCES); do \
$(CLANG_TIDY) $$i $(TIDY_FLAGS) -header-filter=.*; \
done

View File

@ -167,13 +167,11 @@ detail::terminal_type detail::core_terminal_t::type() const
{
if (dynamic_cast<const terminal_t *>(this) != nullptr)
return terminal_type::TERMINAL;
else if (dynamic_cast<const logic_input_t *>(this) != nullptr)
else if (dynamic_cast<const logic_input_t *>(this) != nullptr
|| dynamic_cast<const analog_input_t *>(this) != nullptr)
return terminal_type::INPUT;
else if (dynamic_cast<const logic_output_t *>(this) != nullptr)
return terminal_type::OUTPUT;
else if (dynamic_cast<const analog_input_t *>(this) != nullptr)
return terminal_type::INPUT;
else if (dynamic_cast<const analog_output_t *>(this) != nullptr)
else if (dynamic_cast<const logic_output_t *>(this) != nullptr
|| dynamic_cast<const analog_output_t *>(this) != nullptr)
return terminal_type::OUTPUT;
else
{
@ -472,7 +470,7 @@ void netlist_t::print_stats() const
}
log().verbose("Total calls : {1:12} {2:12} {3:12}", total_count,
total_time, total_time / static_cast<decltype(total_time)>(total_count));
total_time, total_time / static_cast<decltype(total_time)>(total_count ? total_count : 1));
log().verbose("Total loop {1:15}", m_stat_mainloop());
log().verbose("Total time {1:15}", total_time);

View File

@ -1474,7 +1474,7 @@ namespace netlist
// netlist_t
// -----------------------------------------------------------------------------
class netlist_t
class netlist_t // NOLINT(clang-analyzer-optin.performance.Padding)
{
public:
@ -1496,9 +1496,9 @@ namespace netlist
void qpush(detail::queue_t::entry_t && e) noexcept
{
if (!USE_QUEUE_STATS || !m_stats)
m_queue.push_nostats(std::move(e));
m_queue.push_nostats(std::move(e)); // NOLINT(performance-move-const-arg)
else
m_queue.push(std::move(e));
m_queue.push(std::move(e)); // NOLINT(performance-move-const-arg)
}
template <class R>

View File

@ -144,6 +144,8 @@ void parser_t::parse_netlist(const pstring &nlname)
void parser_t::net_truthtable_start(const pstring &nlname)
{
pstring name = get_identifier();
bool head_found(false);
require_token(m_tok_comma);
long ni = get_number_long();
require_token(m_tok_comma);
@ -169,9 +171,12 @@ void parser_t::net_truthtable_start(const pstring &nlname)
require_token(m_tok_param_left);
desc.desc.push_back(get_string());
require_token(m_tok_param_right);
head_found = true;
}
else if (token.is(m_tok_TT_LINE))
{
if (!head_found)
m_setup.log().error("TT_LINE found without TT_HEAD");
require_token(m_tok_param_left);
desc.desc.push_back(get_string());
require_token(m_tok_param_right);

View File

@ -943,7 +943,7 @@ nl_double models_t::value(const pstring &model, const pstring &entity)
switch (*p)
{
case 'M': factor = 1e6; break;
case 'k': factor = 1e3; break;
case 'k':
case 'K': factor = 1e3; break;
case 'm': factor = 1e-3; break;
case 'u': factor = 1e-6; break;

View File

@ -191,7 +191,7 @@ namespace plib
const std::size_t piie = row_idx[i+1];
const auto &nz = nzbd[i];
while (auto j = nz[nzbdp++])
while (auto j = nz[nzbdp++]) // NOLINT(bugprone-infinite-loop)
{
// proceed to column i

View File

@ -159,10 +159,12 @@ ptokenizer::token_t ptokenizer::get_token()
{
skipeol();
}
#if 0
else if (ret.str() == "#")
{
skipeol();
}
#endif
else
{
return ret;
@ -293,6 +295,8 @@ void ppreprocessor::error(const pstring &err)
#define CHECKTOK2(p_op, p_prio) \
else if (tok == # p_op) \
{ \
if (!has_val) \
{ error("parsing error!"); return 1;} \
if (prio < (p_prio)) \
return val; \
start++; \
@ -304,7 +308,9 @@ void ppreprocessor::error(const pstring &err)
int ppreprocessor::expr(const std::vector<pstring> &sexpr, std::size_t &start, int prio)
{
int val = 0;
int val(0);
bool has_val(false);
pstring tok=sexpr[start];
if (tok == "(")
{
@ -312,6 +318,7 @@ int ppreprocessor::expr(const std::vector<pstring> &sexpr, std::size_t &start, i
val = expr(sexpr, start, /*prio*/ 255);
if (sexpr[start] != ")")
error("parsing error!");
has_val = true;
start++;
}
while (start < sexpr.size())
@ -319,18 +326,32 @@ int ppreprocessor::expr(const std::vector<pstring> &sexpr, std::size_t &start, i
tok=sexpr[start];
if (tok == ")")
{
// FIXME: catch error
return val;
if (!has_val)
{
error("parsing error!");
return 1; // tease compiler
}
else
return val;
}
else if (tok == "!")
{
if (prio < 3)
return val;
{
if (!has_val)
{
error("parsing error!");
return 1; // tease compiler
}
else
return val;
}
start++;
val = !expr(sexpr, start, 3);
has_val = true;
}
CHECKTOK2(*, 5)
CHECKTOK2(/, 5)
CHECKTOK2(/, 5) // NOLINT(clang-analyzer-core.DivideZero)
CHECKTOK2(+, 6)
CHECKTOK2(-, 6)
CHECKTOK2(==, 10)
@ -338,12 +359,18 @@ int ppreprocessor::expr(const std::vector<pstring> &sexpr, std::size_t &start, i
CHECKTOK2(||, 15)
else
{
// FIXME: error handling
val = plib::pstonum<decltype(val)>(tok);
has_val = true;
start++;
}
}
return val;
if (!has_val)
{
error("parsing error!");
return 1; // tease compiler
}
else
return val;
}
ppreprocessor::define_t *ppreprocessor::get_define(const pstring &name)

View File

@ -220,6 +220,7 @@ protected:
readbuffer(readbuffer &&rhs) noexcept : m_strm(rhs.m_strm), m_buf() {}
COPYASSIGN(readbuffer, delete)
readbuffer &operator=(readbuffer &&src) = delete;
~readbuffer() override = default;
int_type underflow() override
{

View File

@ -69,10 +69,11 @@ namespace plib {
using generic_function = void (*)();
template<typename MemberFunctionType>
mfp(MemberFunctionType mftp) // XXNOLINT(cppcoreguidelines-pro-type-member-init)
mfp(MemberFunctionType mftp)
: m_function(0), m_this_delta(0), m_dummy1(0), m_dummy2(0), m_size(sizeof(mfp))
{
*reinterpret_cast<MemberFunctionType *>(this) = mftp;
*reinterpret_cast<MemberFunctionType *>(this) = mftp; // NOLINT
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.UninitializedObject)
}
template<typename MemberFunctionType, typename FunctionType, typename ObjectType>

View File

@ -256,7 +256,7 @@ struct perrlogger
template <typename ... Args>
explicit perrlogger(Args&& ... args)
{
h()(std::forward<Args>(args)...);
h()(std::forward<Args>(args)...); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
}
private:
static putf8_fmt_writer &h()

View File

@ -107,7 +107,7 @@ public:
template<typename C, std::size_t N,
class = typename std::enable_if<std::is_same<C, const mem_t>::value>::type>
pstring_t(C (&string)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
pstring_t(C (*string)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
{
static_assert(N > 0,"pstring from array of length 0");
if (string[N-1] != 0)
@ -248,9 +248,7 @@ struct putf8_traits
static std::size_t codelen(const mem_t *p)
{
const auto p1 = reinterpret_cast<const unsigned char *>(p);
if ((*p1 & 0x80) == 0x00)
return 1;
else if ((*p1 & 0xE0) == 0xC0)
if ((*p1 & 0xE0) == 0xC0)
return 2;
else if ((*p1 & 0xF0) == 0xE0)
return 3;
@ -258,7 +256,9 @@ struct putf8_traits
return 4;
else
{
return 1; // not correct
// valid utf8: ((*p1 & 0x80) == 0x00)
// However, we return 1 here.
return 1;
}
}
static std::size_t codelen(const code_t c)
@ -284,7 +284,7 @@ struct putf8_traits
else if ((*p1 & 0xF8) == 0xF0)
return static_cast<code_t>(((p1[0] & 0x0f) << 18) | ((p1[1] & 0x3f) << 12) | ((p1[2] & 0x3f) << 6) | ((p1[3] & 0x3f) << 0));
else
return *p1; // not correct
return 0xFFFD; // unicode-replacement character
}
static void encode(const code_t c, string_type &s)
{

View File

@ -188,7 +188,7 @@ namespace plib
};
template<typename T, typename S>
T pstonum(const S &arg, std::locale loc = std::locale::classic())
T pstonum(const S &arg, const std::locale &loc = std::locale::classic())
{
decltype(arg.c_str()) cstr = arg.c_str();
std::size_t idx(0);

View File

@ -147,7 +147,7 @@ namespace devices
pstring ml = "";
for (std::size_t j = 0; j < iN; j++)
{
ml += fill[k][j] == 0 ? "X" : fill[k][j] < decltype(mat)::FILL_INFINITY ? "+" : ".";
ml += fill[k][j] == 0 ? 'X' : fill[k][j] < decltype(mat)::FILL_INFINITY ? '+' : '.';
if (fill[k][j] < decltype(mat)::FILL_INFINITY)
if (fill[k][j] > fm)
fm = fill[k][j];

View File

@ -90,14 +90,16 @@ namespace devices
float_ext_type &lAinv(const T1 &r, const T2 &c) { return m_lAinv[r][c]; }
private:
template <typename T, std::size_t N, std::size_t M>
using array2D = std::array<std::array<T, M>, N>;
static constexpr std::size_t m_pitch = ((( storage_N) + 7) / 8) * 8;
float_ext_type m_A[storage_N][m_pitch];
float_ext_type m_Ainv[storage_N][m_pitch];
float_ext_type m_W[storage_N][m_pitch];
array2D<float_ext_type, storage_N, m_pitch> m_A;
array2D<float_ext_type, storage_N, m_pitch> m_Ainv;
array2D<float_ext_type, storage_N, m_pitch> m_W;
std::array<float_ext_type, storage_N> m_RHS; // right hand side - contains currents
float_ext_type m_lA[storage_N][m_pitch];
float_ext_type m_lAinv[storage_N][m_pitch];
array2D<float_ext_type, storage_N, m_pitch> m_lA;
array2D<float_ext_type, storage_N, m_pitch> m_lAinv;
//float_ext_type m_RHSx[storage_N];

View File

@ -97,18 +97,20 @@ protected:
private:
template <typename T, std::size_t N, std::size_t M>
using array2D = std::array<std::array<T, M>, N>;
static constexpr std::size_t m_pitch = ((( storage_N) + 7) / 8) * 8;
float_ext_type m_A[storage_N][m_pitch];
float_ext_type m_Ainv[storage_N][m_pitch];
float_ext_type m_W[storage_N][m_pitch];
array2D<float_ext_type, storage_N, m_pitch> m_A;
array2D<float_ext_type, storage_N, m_pitch> m_Ainv;
array2D<float_ext_type, storage_N, m_pitch> m_W;
std::array<float_ext_type, storage_N> m_RHS; // right hand side - contains currents
float_ext_type m_lA[storage_N][m_pitch];
array2D<float_ext_type, storage_N, m_pitch> m_lA;
/* temporary */
float_type H[storage_N][m_pitch] ;
array2D<float_ext_type, storage_N, m_pitch> H;
std::array<unsigned, storage_N> rows;
unsigned cols[storage_N][m_pitch];
array2D<unsigned, storage_N, m_pitch> cols;
std::array<unsigned, storage_N> colcount;
unsigned m_cnt;