summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2020-05-03 08:58:12 +0200
committerGravatarGravatar couriersud <couriersud@gmx.org>2020-05-03 08:58:12 +0200
commit534b58eee6c6005bc0d1c43c6dff682d6c9482b7 (patch) (github)
tree589ae166730f2f9a43eb6e273f074be5110acf04
parent36622eca96573ab7ef6540f4904580f1fd759e38 (diff)
downloadmame-534b58eee6c6005bc0d1c43c6dff682d6c9482b7.tar.bz2
mame-534b58eee6c6005bc0d1c43c6dff682d6c9482b7.zip
netlist: Fix some tidy warnings. (nw)
moving over to clang-tidy-11 and enabling more warnings.
-rw-r--r--src/lib/netlist/build/makefile8
-rw-r--r--src/lib/netlist/devices/nld_4316.cpp37
-rw-r--r--src/lib/netlist/devices/nld_74393.cpp1
-rw-r--r--src/lib/netlist/nl_base.cpp6
-rwxr-xr-xsrc/lib/netlist/nl_setup.cpp16
-rw-r--r--src/lib/netlist/nltypes.h11
-rw-r--r--src/lib/netlist/plib/palloc.h3
-rw-r--r--src/lib/netlist/plib/pfmtlog.h2
-rw-r--r--src/lib/netlist/plib/pmath.h2
-rw-r--r--src/lib/netlist/plib/pmempool.h4
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp1
11 files changed, 56 insertions, 35 deletions
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile
index 37e4133ee27..fbc24d490ff 100644
--- a/src/lib/netlist/build/makefile
+++ b/src/lib/netlist/build/makefile
@@ -26,12 +26,13 @@ DOC = $(SRC)/documentation
TIDY_FLAGSX = -checks=*,-google*,-hicpp*,readability*,-fuchsia*,cert-*,-android-*,
TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast,
-TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory,
+TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,
+#TIDY_FLAGSX += -cppcoreguidelines-owning-memory,
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-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,
+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,
@@ -39,7 +40,8 @@ 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-named-parameter,-readability-function-size,
-TIDY_FLAGSX += -llvmlibc-restrict-system-libc-headers,-llvmlibc-implementation-in-namespace
+TIDY_FLAGSX += -llvmlibc-restrict-system-libc-headers,-llvmlibc-implementation-in-namespace,
+TIDY_FLAGSX += -cppcoreguidelines-avoid-non-const-global-variables
space :=
space +=
diff --git a/src/lib/netlist/devices/nld_4316.cpp b/src/lib/netlist/devices/nld_4316.cpp
index f8085092178..84668be5221 100644
--- a/src/lib/netlist/devices/nld_4316.cpp
+++ b/src/lib/netlist/devices/nld_4316.cpp
@@ -24,10 +24,24 @@ namespace netlist { namespace devices {
{
}
- NETLIB_RESETI();
- NETLIB_UPDATEI();
+ NETLIB_RESETI()
+ {
+ m_R.set_R(plib::reciprocal(exec().gmin()));
+ }
+
+ NETLIB_UPDATEI()
+ {
+ m_R.change_state([this]()
+ {
+ if (m_S() && !m_E())
+ m_R.set_R(m_base_r());
+ else
+ m_R.set_R(plib::reciprocal(exec().gmin()));
+ }
+ , NLTIME_FROM_NS(1));
+ }
- public:
+ private:
nld_power_pins m_supply;
analog::NETLIB_SUB(R_base) m_R;
@@ -36,23 +50,6 @@ namespace netlist { namespace devices {
param_fp_t m_base_r;
};
- NETLIB_RESET(CD4316_GATE)
- {
- m_R.set_R(plib::reciprocal(exec().gmin()));
- }
-
- NETLIB_UPDATE(CD4316_GATE)
- {
- m_R.change_state([this]()
- {
- if (m_S() && !m_E())
- m_R.set_R(m_base_r());
- else
- m_R.set_R(plib::reciprocal(exec().gmin()));
- }
- , NLTIME_FROM_NS(1));
- }
-
NETLIB_DEVICE_IMPL(CD4316_GATE, "CD4316_GATE", "")
} // namespace devices
diff --git a/src/lib/netlist/devices/nld_74393.cpp b/src/lib/netlist/devices/nld_74393.cpp
index 56c554055a8..2cd84c32380 100644
--- a/src/lib/netlist/devices/nld_74393.cpp
+++ b/src/lib/netlist/devices/nld_74393.cpp
@@ -55,7 +55,6 @@ namespace netlist
}
}
- protected:
logic_input_t m_CP;
logic_input_t m_MR;
object_array_t<logic_output_t, 4> m_Q;
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index 7db9354ba0e..25fbe484b3b 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -111,11 +111,11 @@ namespace netlist
// ----------------------------------------------------------------------------------------
detail::queue_t::queue_t(netlist_t &nl)
- : timed_queue<plib::pqentry_t<net_t *, netlist_time_ext>, false>(512)
+ : timed_queue<plib::pqentry_t<net_t *, netlist_time_ext>, false>(nlconst::max_queue_size())
, netlist_object_t(nl, nl.nlstate().name() + ".queue")
, m_qsize(0)
- , m_times(512)
- , m_net_ids(512)
+ , m_times(nlconst::max_queue_size())
+ , m_net_ids(nlconst::max_queue_size())
{
}
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index 1b1d3aeea6c..893f9df6a09 100755
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -577,6 +577,8 @@ param_t *setup_t::find_param(const pstring &param_in, bool required) const
return (ret == m_params.end() ? nullptr : ret->second.param());
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
devices::nld_base_proxy *setup_t::get_d_a_proxy(const detail::core_terminal_t &out)
{
nl_assert(out.is_logic());
@@ -618,6 +620,8 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(const detail::core_terminal_t &o
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
{
nl_assert(inp.is_logic());
@@ -676,6 +680,8 @@ detail::core_terminal_t &setup_t::resolve_proxy(detail::core_terminal_t &term)
return term;
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
{
log().debug("merging nets ...\n");
@@ -703,7 +709,7 @@ void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
}
-
+//NOLINTNEXTLINE(misc-no-recursion)
void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_terminal_t &out)
{
if (out.is_analog() && in.is_logic())
@@ -729,6 +735,7 @@ void setup_t::connect_input_output(detail::core_terminal_t &in, detail::core_ter
}
+//NOLINTNEXTLINE(misc-no-recursion)
void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &inp)
{
if (inp.is_analog())
@@ -752,6 +759,8 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
}
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
void setup_t::connect_terminal_output(terminal_t &in, detail::core_terminal_t &out)
{
if (out.is_analog())
@@ -807,6 +816,7 @@ void setup_t::connect_terminals(detail::core_terminal_t &t1,detail::core_termina
}
}
+//NOLINTNEXTLINE(misc-no-recursion)
bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_terminal_t &t2)
{
bool ret = false;
@@ -843,6 +853,8 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term
return ret;
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t2_in)
{
log().debug("Connecting {1} to {2}\n", t1_in.name(), t2_in.name());
@@ -1051,6 +1063,8 @@ void models_t::register_model(const pstring &model_in)
throw nl_exception(MF_MODEL_ALREADY_EXISTS_1(model_in));
}
+
+//NOLINTNEXTLINE(misc-no-recursion)
void models_t::model_parse(const pstring &model_in, model_map_t &map)
{
pstring model = model_in;
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h
index 915abcafb11..542a3d8c816 100644
--- a/src/lib/netlist/nltypes.h
+++ b/src/lib/netlist/nltypes.h
@@ -33,6 +33,13 @@ namespace netlist
{
using BC = plib::constants<T>;
+ static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept
+ { return n * temp * BC::k_b() / BC::Q_e(); }
+
+ static inline constexpr T np_Is() noexcept { return static_cast<T>(1e-15); } // NOLINT
+
+ static inline constexpr std::size_t max_queue_size() { return 512; } // NOLINT
+
/// \brief constant startup gmin
///
/// This should be used during object creation to initialize
@@ -53,10 +60,6 @@ namespace netlist
///
static inline constexpr T diode_start_voltage() noexcept { return BC::magic(0.7); } // NOLINT
- static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept
- { return n * temp * BC::k_b() / BC::Q_e(); }
-
- static inline constexpr T np_Is() noexcept { return static_cast<T>(1e-15); } // NOLINT
};
/// \brief nlconst_base struct specialized for nl_fptype.
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index 3c33795103f..9136a82a42a 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -323,6 +323,7 @@ namespace plib {
auto *mem = allocate(alignof(T), sizeof(T));
try
{
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto *mema = new (mem) T(std::forward<Args>(args)...);
return unique_pool_ptr<T>(mema, arena_deleter<aligned_arena, T>(*this));
}
@@ -339,6 +340,7 @@ namespace plib {
auto *mem = allocate(alignof(T), sizeof(T));
try
{
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto *mema = new (mem) T(std::forward<Args>(args)...);
return owned_pool_ptr<T>(mema, true, arena_deleter<aligned_arena, T>(*this));
}
@@ -353,6 +355,7 @@ namespace plib {
static T *alloc(Args&&... args)
{
auto *p = allocate(alignof(T), sizeof(T));
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
return new(p) T(std::forward<Args>(args)...);
}
diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h
index 27e6211d8f1..e35e7db70bb 100644
--- a/src/lib/netlist/plib/pfmtlog.h
+++ b/src/lib/netlist/plib/pfmtlog.h
@@ -21,7 +21,7 @@
{ \
template<typename... Args> explicit name(Args&&... args) \
: plib::perrmsg(str, std::forward<Args>(args)...) \
- { static_assert(narg == sizeof...(args), "Argument count mismatch"); } \
+ { static_assert((narg) == sizeof...(args), "Argument count mismatch"); } \
};
namespace plib {
diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h
index 4b3f7d41431..cb6ae6fc8cd 100644
--- a/src/lib/netlist/plib/pmath.h
+++ b/src/lib/netlist/plib/pmath.h
@@ -405,7 +405,7 @@ namespace plib
///
template<typename M, typename N>
constexpr typename std::common_type<M, N>::type
- gcd(M m, N n) noexcept
+ gcd(M m, N n) noexcept //NOLINT(misc-no-recursion)
{
static_assert(plib::is_integral<M>::value, "gcd: M must be an integer");
static_assert(plib::is_integral<N>::value, "gcd: N must be an integer");
diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h
index 60eba09ccce..72a07613315 100644
--- a/src/lib/netlist/plib/pmempool.h
+++ b/src/lib/netlist/plib/pmempool.h
@@ -138,6 +138,7 @@ namespace plib {
auto *mem = this->allocate(alignof(T), sizeof(T));
try
{
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto *mema = new (mem) T(std::forward<Args>(args)...);
return owned_pool_ptr<T>(mema, true, arena_deleter<mempool, T>(this));
}
@@ -154,6 +155,7 @@ namespace plib {
auto *mem = this->allocate(alignof(T), sizeof(T));
try
{
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto *mema = new (mem) T(std::forward<Args>(args)...);
return unique_pool_ptr<T>(mema, arena_deleter<mempool, T>(this));
}
@@ -181,7 +183,7 @@ namespace plib {
min_bytes = std::max(mp.m_min_alloc, min_bytes);
m_free = min_bytes;
size_type alloc_bytes = (min_bytes + mp.m_min_align); // - 1); // & ~(mp.m_min_align - 1);
- //m_data_allocated = ::operator new(alloc_bytes);
+ // NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
m_data_allocated = new char[alloc_bytes];
void *r = m_data_allocated;
std::align(mp.m_min_align, min_bytes, r, alloc_bytes);
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index 10c2909145f..2cd092cdbdd 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -279,6 +279,7 @@ namespace devices
return false;
}
+ // NOLINTNEXTLINE(misc-no-recursion)
void process_net(netlist_state_t &netlist, analog_net_t &n)
{
// ignore empty nets. FIXME: print a warning message