netlist: various clang-tidy-11 fixes. (nw)

This commit is contained in:
couriersud 2020-05-22 10:45:20 +02:00
parent a976bddc0c
commit f88a576c54
12 changed files with 46 additions and 38 deletions

View File

@ -309,8 +309,8 @@ namespace analog
NETLIB_UPDATE(QBJT_switch)
{
auto solv(m_RB.solver());
if (solv)
auto *solv(m_RB.solver());
if (solv != nullptr)
solv->solve_now();
else
m_RC.solver()->solve_now();
@ -373,8 +373,8 @@ namespace analog
NETLIB_UPDATE(QBJT_EB)
{
auto solv(m_D_EB.solver());
if (solv)
auto *solv(m_D_EB.solver());
if (solv != nullptr)
solv->solve_now();
else
m_D_CB.solver()->solve_now();

View File

@ -18,7 +18,7 @@ namespace analog
solver::matrix_solver_t * NETLIB_NAME(twoterm)::solver() const noexcept
{
auto *solv(m_P.solver());
if (solv)
if (solv != nullptr)
return solv;
return m_N.solver();
}
@ -27,7 +27,7 @@ namespace analog
void NETLIB_NAME(twoterm)::solve_now() const
{
auto *solv(solver());
if (solv)
if (solv != nullptr)
solv->solve_now();
}

View File

@ -31,14 +31,15 @@ TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast,
TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index,
TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast-downcast,
TIDY_FLAGSX += -cppcoreguidelines-avoid-magic-numbers,
#TIDY_FLAGSX += -cppcoreguidelines-macro-usage,
TIDY_FLAGSX += -cppcoreguidelines-macro-usage,
TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,
TIDY_FLAGSX += -bugprone-macro-parentheses,
#TIDY_FLAGSX += -misc-macro-parentheses,
TIDY_FLAGSX += -bugprone-too-small-loop-variable,
TIDY_FLAGSX += -modernize-use-trailing-return-type,
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
TIDY_FLAGSX += -readability-magic-numbers,-readability-implicit-bool-conversion,-readability-braces-around-statements,
TIDY_FLAGSX += -readability-magic-numbers,-readability-braces-around-statements,
#TIDY_FLAGSX += -readability-implicit-bool-conversion,
TIDY_FLAGSX += -readability-named-parameter,-readability-function-size,
TIDY_FLAGSX += -llvmlibc-restrict-system-libc-headers,-llvmlibc-implementation-in-namespace,-llvmlibc-callee-namespace,
#TIDY_FLAGSX += -cppcoreguidelines-avoid-non-const-global-variables
@ -290,7 +291,12 @@ gcc9:
clang:
#$(MAKE) CC=clang++-11 LD=clang++-11 OBJ=obj/clang CEXTRAFLAGS="-march=native -msse4.2 -Weverything -Wall -pedantic -Wpedantic -Wunused-private-field -Wno-padded -Wno-unused-template -Wno-missing-variable-declarations -Wno-float-equal -Wconversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-exit-time-destructors"
$(MAKE) CC=clang++-11 LD=clang++-11 OBJ=obj/clang CEXTRAFLAGS="-march=native -msse4.2 -Weverything -Wall -pedantic -Wpedantic -Wunused-private-field -Werror -Wno-padded -Wno-weak-vtables -Wno-unused-template -Wno-missing-variable-declarations -Wno-float-equal -Wconversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-exit-time-destructors"
$(MAKE) CC=clang++-11 LD=clang++-11 OBJ=obj/clang CEXTRAFLAGS="-march=native \
-msse4.2 -Weverything -Wall -pedantic -Wpedantic -Wunused-private-field \
-Werror -Wno-padded -Wno-weak-vtables -Wno-unused-template \
-Wno-missing-variable-declarations -Wno-float-equal -Wconversion \
-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral \
-Wno-exit-time-destructors -Winconsistent-missing-destructor-override"
clang-5:
$(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors"
@ -304,9 +310,8 @@ nvcc:
tidy_db: compile_commands_prefix $(ALL_TIDY_FILES) compile_commands_postfix
#
# -Wno-c++11-narrowing : seems a bit broken
# Mostly done: -Wno-weak-vtables -Wno-cast-align
# FIXME: -Wno-weak-vtables -Wno-missing-variable-declarations -Wno-conversion -Wno-exit-time-destructors
# FIXME: -Wno-weak-vtables -Wno-exit-time-destructors
# FIXME: -Winconsistent-missing-destructor-override : c++ community has diverging opinions on this https://github.com/isocpp/CppCoreGuidelines/issues/721
# FIXME: -Wunreachable-code : False warnings, this a documented clang bug: https://llvm.org/bugs/show_bug.cgi?id=28994
# -Wweak-template-vtables

View File

@ -56,7 +56,7 @@ namespace netlist
NETLIB_HANDLERI(clk_strb);
friend class NETLIB_NAME(7497_dip);
private:
object_array_t<logic_input_t, 6> m_B;
logic_input_t m_CLK;
logic_input_t m_STRBQ;

View File

@ -40,11 +40,11 @@ namespace netlist
/*detail::terminal_type::INPUT,*/ false));
auto *tp_cn(anetlist.setup().find_terminal(devname + "." + pwr_sym.second,
/*detail::terminal_type::INPUT,*/ false));
if (tp_ct && tp_cn)
if ((tp_ct != nullptr) && (tp_cn != nullptr))
{
if (tp_ct && !tp_ct->is_analog())
if (!tp_ct->is_analog())
throw nl_exception(plib::pfmt("Not an analog terminal: {1}")(tp_ct->name()));
if (tp_cn && !tp_cn->is_analog())
if (!tp_cn->is_analog())
throw nl_exception(plib::pfmt("Not an analog terminal: {1}")(tp_cn->name()));
auto *tp_t = static_cast<analog_t* >(tp_ct);
@ -52,8 +52,8 @@ namespace netlist
if (f && (tp_t != nullptr && tn_t != nullptr))
log().warning(MI_MULTIPLE_POWER_TERMINALS_ON_DEVICE(inout_proxied->device().name(),
m_tp->name(), m_tn->name(),
tp_t ? tp_t->name() : "",
tn_t ? tn_t->name() : ""));
tp_t != nullptr ? tp_t->name() : "",
tn_t != nullptr ? tn_t->name() : ""));
else if (tp_t != nullptr && tn_t != nullptr)
{
m_tp = tp_t;
@ -64,8 +64,8 @@ namespace netlist
}
if (!f)
throw nl_exception(MF_NO_POWER_TERMINALS_ON_DEVICE_2(name, anetlist.setup().de_alias(inout_proxied->device().name())));
else
log().verbose("D/A Proxy: Found power terminals on device {1}", inout_proxied->device().name());
log().verbose("D/A Proxy: Found power terminals on device {1}", inout_proxied->device().name());
}
// ----------------------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ namespace devices
NETLIB_UPDATEI()
{
m_Q.push(!m_feedback(), m_inc);
m_Q.push(m_feedback() ^ 1, m_inc);
}
private:
@ -104,7 +104,7 @@ namespace devices
{
m_funcparam[0] = exec().time().as_fp<nl_fptype>();
const netlist_time m_inc = netlist_time::from_fp(m_compiled->evaluate(m_funcparam));
m_Q.push(!m_feedback(), m_inc);
m_Q.push(m_feedback() ^ 1, m_inc);
}
private:

View File

@ -401,13 +401,13 @@ namespace netlist
}
log().verbose("Total calls : {1:12} {2:12} {3:12}", total_count,
total_time, total_time / static_cast<decltype(total_time)>(total_count ? total_count : 1));
total_time, total_time / static_cast<decltype(total_time)>((total_count > 0) ? total_count : 1));
log().verbose("Total loop {1:15}", si.m_stat_mainloop());
log().verbose("Total time {1:15}", total_time);
// FIXME: clang complains about unreachable code without
const auto clang_workaround_unreachable_code = NL_USE_QUEUE_STATS;
const bool clang_workaround_unreachable_code(NL_USE_QUEUE_STATS>0);
if (clang_workaround_unreachable_code)
{
// Only one serialization should be counted in total time
@ -714,7 +714,7 @@ namespace netlist
{
const auto *solv(solver());
// Nets may belong to railnets which do not have a solver attached
if (solv)
if (solv != nullptr)
solver()->solve_now();
}

View File

@ -1059,8 +1059,8 @@ namespace netlist
///
/// This function throws an exception if actually called.
///
[[noreturn]] void set_tristate(bool v,
netlist_time ts_off_on, netlist_time ts_on_off) const
[[noreturn]] static void set_tristate(netlist_sig_t v,
netlist_time ts_off_on, netlist_time ts_on_off)
{
plib::unused_var(v, ts_off_on, ts_on_off);
throw nl_exception("set_tristate on logic_output should never be called!");
@ -1104,7 +1104,7 @@ namespace netlist
m_last_logic = newQ;
}
void set_tristate(bool v,
void set_tristate(netlist_sig_t v,
netlist_time ts_off_on, netlist_time ts_on_off) noexcept
{
if (!m_force_logic)
@ -1980,10 +1980,10 @@ namespace netlist
}
template<class D>
object_array_base_t(D &dev, std::size_t offset, const pstring &fmt, nldelegate &&delegate)
object_array_base_t(D &dev, std::size_t offset, const pstring &fmt, nldelegate delegate)
{
for (std::size_t i = 0; i<N; i++)
this->emplace(i, dev, formatted(fmt, i+offset), std::move(delegate));
this->emplace(i, dev, formatted(fmt, i+offset), delegate);
}
template<class D>
@ -2000,13 +2000,11 @@ namespace netlist
protected:
object_array_base_t() = default;
protected:
static pstring formatted(const pstring &fmt, std::size_t n)
{
if (N != 1)
return plib::pfmt(fmt)(n);
else
return plib::pfmt(fmt)("");
return plib::pfmt(fmt)("");
}
};
@ -2111,7 +2109,7 @@ namespace netlist
(*this)[i].push((v >> i) & 1, t[i]);
}
void set_tristate(bool v,
void set_tristate(netlist_sig_t v,
netlist_time ts_off_on, netlist_time ts_on_off) noexcept
{
for (std::size_t i = 0; i < N; i++)
@ -2141,7 +2139,7 @@ namespace netlist
(*this)[i].push((v >> i) & 1, t);
}
void set_tristate(bool v,
void set_tristate(netlist_sig_t v,
netlist_time ts_off_on, netlist_time ts_on_off) noexcept
{
for (std::size_t i = 0; i < N; i++)
@ -2387,6 +2385,7 @@ namespace netlist
inline void terminal_t::set_ptrs(nl_fptype *gt, nl_fptype *go, nl_fptype *Idr) noexcept(false)
{
// NOLINTNEXTLINE(readability-implicit-bool-conversion)
if (!(gt && go && Idr) && (gt || go || Idr))
{
throw nl_exception("Inconsistent nullptrs for terminal {}", name());

View File

@ -33,6 +33,7 @@
return devtype::create(p_name, std::move(sl)); \
} \
\
extern factory::constructor_ptr_t decl_ ## p_alias; \
factory::constructor_ptr_t decl_ ## p_alias = NETLIB_NAME(p_alias ## _c);
namespace netlist {
@ -50,6 +51,7 @@ namespace factory {
, m_sourceloc(std::move(sourceloc))
{ }
~properties() = default;
PCOPYASSIGNMOVE(properties, default)
const pstring &defparam() const noexcept
@ -153,7 +155,7 @@ namespace factory {
// factory_creator_ptr_t
// -----------------------------------------------------------------------------
using constructor_ptr_t = plib::unique_ptr<element_t> (*)();
using constructor_ptr_t = plib::unique_ptr<element_t> (*const)();
template <typename T>
plib::unique_ptr<element_t> constructor_t(const pstring &name, properties &&props)

View File

@ -53,7 +53,7 @@ namespace netlist
std::initializer_list<const char *> more_parameters)
{
std::vector<pstring> params;
const auto *i(more_parameters.begin());
auto i(more_parameters.begin());
pstring name(*i);
++i;
for (; i != more_parameters.end(); ++i)
@ -1527,7 +1527,7 @@ void setup_t::prepare_to_run()
d.second->set_hint_deactivate(false);
}
if (errcnt)
if (errcnt > 0)
{
log().fatal(MF_ERRORS_FOUND(errcnt));
throw nl_exception(MF_ERRORS_FOUND(errcnt));

View File

@ -177,6 +177,8 @@ namespace netlist
: m_device(&device)
, m_param(&param)
{ }
~param_ref_t() = default;
PCOPYASSIGNMOVE(param_ref_t, default)
const core_device_t &device() const noexcept { return *m_device; }

View File

@ -191,7 +191,7 @@ namespace netlist
}
};
/// \brief: used to hold two static netlist_time values
/// \brief: used to hold three static netlist_time values
///
template<netlist_time::internal_type value0,
netlist_time::internal_type value1,