netlist: Pedantic and clang tidy updates

* also fix an issue with netlist vs build
This commit is contained in:
couriersud 2020-09-06 17:47:12 +02:00
parent d314df16be
commit d16baea163
28 changed files with 57 additions and 52 deletions

View File

@ -34,11 +34,11 @@
///
//
#include "nl_base.h"
#include "../nl_setup.h"
#include "nl_base.h"
#include "nld_generic_models.h"
#include "plib/pfunction.h"
#include "solver/nld_solver.h"
#include "nld_generic_models.h"
// -----------------------------------------------------------------------------
// Implementation

View File

@ -58,7 +58,7 @@ TIDY_SOURCES = $(ALLSOURCES)
#TIDY_SOURCES = $(SRC)/devices/nld_7442.cpp $(SRC)/devices/nld_7492.cpp
TIDY_FLAGS = -p $(OBJ) -checks=llvm-include-order,llvm-namespace-comment,modernize-use-override,modernize-use-using -fix
#TIDY_FLAGS = -p $(OBJ) -checks=llvm-include-order,llvm-namespace-comment,modernize-use-override,modernize-use-using -fix
#TIDY_FLAGS = -checks=llvm-include-order -fix
#TIDY_FLAGS = -checks=llvm-namespace-comment -fix
#TIDY_FLAGS = -checks=modernize-use-override -fix

View File

@ -101,7 +101,7 @@
</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\;$(SolutionDir)..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -84,8 +84,8 @@ NETLIST_EXTERNAL(base_lib)
#include "nld_9322.h"
#include "nld_tms4800.h"
#include "nld_am2847.h"
#include "nld_8277.h"
#include "nld_am2847.h"
#include "nld_dm9314.h"
#include "nld_dm9334.h"

View File

@ -46,7 +46,7 @@ namespace netlist
namespace devices
{
template <std::size_t _MaxCount>
template <std::size_t MaxCount>
NETLIB_OBJECT(CD4017_base)
{
NETLIB_CONSTRUCTOR_MODEL(CD4017_base, "CD4XXX")
@ -93,15 +93,15 @@ namespace netlist
void update_outputs(const unsigned cnt) noexcept
{
for (std::size_t i = 0; i < _MaxCount; i++)
for (std::size_t i = 0; i < MaxCount; i++)
m_Q[i].push(i == cnt, NLTIME_FROM_NS(200));
m_CO.push(cnt < _MaxCount / 2, NLTIME_FROM_NS(160));
m_CO.push(cnt < MaxCount / 2, NLTIME_FROM_NS(160));
}
logic_input_t m_CLK;
logic_input_t m_CLKEN;
logic_input_t m_RESET;
logic_output_t m_CO;
object_array_t<logic_output_t, _MaxCount> m_Q;
object_array_t<logic_output_t, MaxCount> m_Q;
state_var<unsigned> m_cnt;
nld_power_pins m_supply;

View File

@ -46,10 +46,10 @@ namespace netlist
namespace devices
{
template <unsigned _TotalBits, unsigned _LiveBitmask>
template <unsigned TotalBits, unsigned LiveBitmask>
NETLIB_OBJECT(CD4020_sub)
{
static_assert((_LiveBitmask >> _TotalBits) == 0, "Live bitmask too large");
static_assert((LiveBitmask >> TotalBits) == 0, "Live bitmask too large");
NETLIB_CONSTRUCTOR_MODEL(CD4020_sub, "CD4XXX")
, m_IP(*this, "IP", NETLIB_DELEGATE(ip))
@ -79,8 +79,8 @@ namespace netlist
m_cnt = 0;
m_IP.inactivate();
/* static */ const netlist_time reset_time = netlist_time::from_nsec(140);
for (unsigned i = 0; i < _TotalBits; i++)
if (((_LiveBitmask >> i) & 1) != 0)
for (unsigned i = 0; i < TotalBits; i++)
if (((LiveBitmask >> i) & 1) != 0)
m_Q[i].push(0, reset_time);
}
else
@ -100,13 +100,13 @@ namespace netlist
NLTIME_FROM_NS(1380), NLTIME_FROM_NS(1480),
};
for (unsigned i = 0; i < _TotalBits; i++)
if (((_LiveBitmask >> i) & 1) != 0)
for (unsigned i = 0; i < TotalBits; i++)
if (((LiveBitmask >> i) & 1) != 0)
m_Q[i].push((cnt >> i) & 1, out_delayQn[i]);
}
logic_input_t m_IP;
logic_input_t m_RESET;
object_array_t<logic_output_t, _TotalBits> m_Q;
object_array_t<logic_output_t, TotalBits> m_Q;
state_var<unsigned> m_cnt;
nld_power_pins m_supply;

View File

@ -61,7 +61,8 @@ namespace netlist
private:
NETLIB_HANDLERI(controls)
{
bool newx = false, newy = false;
bool newx = false;
bool newy = false;
if (!on(m_inhibit, m_inhibit_state))
{
if (!on(m_select, m_select_state))

View File

@ -41,7 +41,7 @@ namespace netlist
{
namespace devices
{
template<bool _HasQQ>
template<bool HasQQ>
NETLIB_OBJECT(7475_GATE_BASE)
{
NETLIB_CONSTRUCTOR(7475_GATE_BASE)
@ -87,7 +87,7 @@ namespace netlist
// 0: High-to-low 40 ns, 1: Low-to-high 25 ns
static constexpr const std::array<netlist_time, 2> delay = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) };
m_Q.push(stateQ, delay[stateQ]);
if (_HasQQ)
if (HasQQ)
m_QQ.push(stateQQ, delay[stateQQ]);
}
};

View File

@ -43,7 +43,7 @@ namespace netlist
private:
NETLIB_HANDLERI(in)
{
m_enable = m_E() ? 0 : 1;
m_enable = m_E() ? false : true;
m_o = (m_A[1]() << 1) | m_A[0]();
for (std::size_t i=0; i<4; i++)
m_D[i].push((i == m_o && m_enable) ? 0 : 1, NLTIME_FROM_NS(21));

View File

@ -6,8 +6,8 @@
*/
#include "solver/nld_solver.h"
#include "solver/nld_matrix_solver.h"
#include "nlid_system.h"
#include "solver/nld_matrix_solver.h"
#include "plib/pstrutil.h"

View File

@ -74,7 +74,7 @@ namespace devices
if (!m_func().empty())
{
std::vector<pstring> inps;
inps.push_back(pstring("T"));
inps.emplace_back("T");
m_vals.push_back(nlconst::zero());
for (int i=0; i < m_N(); i++)
{

View File

@ -112,8 +112,6 @@ namespace devices
m_ign = (1<<m_NI)-1;
}
private:
template<bool doOUT>
void process() noexcept
{

View File

@ -8,8 +8,8 @@
#ifndef NLID_TRUTHTABLE_H_
#define NLID_TRUTHTABLE_H_
#include "nl_factory.h"
#include "../nl_setup.h"
#include "nl_factory.h"
#define USE_TT_ALTERNATIVE (0)

View File

@ -158,7 +158,7 @@ namespace netlist
void netlist_state_t::set_static_solver_lib(std::unique_ptr<plib::dynlib_base> &&lib)
{
m_lib = std::move(lib);
};
}
void netlist_t::stop()

View File

@ -45,7 +45,7 @@ namespace factory {
bool list_t::exists(const pstring &name) const noexcept
{
for (auto & e : *this)
for (const auto & e : *this)
if (e->name() == name)
return true;
return false;

View File

@ -11,8 +11,8 @@
#include "nltypes.h"
#include "plib/palloc.h"
#include "plib/pmempool.h"
#include "plib/ptypes.h"
#include "plib/psource.h"
#include "plib/ptypes.h"
#include <tuple>
#include <utility>

View File

@ -12,8 +12,8 @@
#include "nl_setup.h"
#include "plib/penum.h"
#include "plib/pstonum.h"
#include "plib/putil.h"
#include "plib/pstrutil.h"
#include "plib/putil.h"
#include "solver/nld_solver.h"
@ -379,12 +379,13 @@ namespace netlist
return parser.parse(st, name);
}
#else
const auto filename = istrm.filename();
auto preprocessed = std::make_unique<std::stringstream>(putf8string(
plib::ppreprocessor(m_includes, &m_defines).process(std::move(istrm), istrm.filename())));
plib::ppreprocessor(m_includes, &m_defines).process(std::move(istrm), filename)));
parser_t::token_store st;
parser_t parser(*this);
parser.parse_tokens(plib::istream_uptr(std::move(preprocessed), istrm.filename()), st);
parser.parse_tokens(plib::istream_uptr(std::move(preprocessed), filename), st);
return parser.parse(st, name);
#endif
}
@ -1725,8 +1726,8 @@ plib::istream_uptr source_file_t::stream(const pstring &name)
{
return plib::istream_uptr(std::move(f), m_filename);
}
else
return plib::istream_uptr();
return plib::istream_uptr();
}
plib::istream_uptr source_pattern_t::stream(const pstring &name)
@ -1737,8 +1738,8 @@ plib::istream_uptr source_pattern_t::stream(const pstring &name)
{
return plib::istream_uptr(std::move(f), filename);
}
else
return plib::istream_uptr();
return plib::istream_uptr();
}

View File

@ -11,9 +11,9 @@
#define NL_AUTO_DEVICES 0
#include "plib/ppreprocessor.h"
#include "plib/psource.h"
#include "plib/pstream.h"
#include "plib/pstring.h"
#include "plib/psource.h"
#include "nl_config.h"
#include "nl_parser.h"

View File

@ -14,10 +14,10 @@
#include <array>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include <string>
namespace plib {

View File

@ -9,9 +9,9 @@
#define PFMTLOG_H_
#include "penum.h"
#include "ppmf.h"
#include "pstring.h"
#include "ptypes.h"
#include "ppmf.h"
#include <limits>
#include <locale>

View File

@ -10,8 +10,8 @@
#include "palloc.h"
#include "pexception.h"
#include "pstring.h"
#include "pstream.h"
#include "pstring.h"
#include <algorithm>
#include <initializer_list>

View File

@ -367,12 +367,12 @@ public:
pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type;
template <typename T>
explicit ifstream(const pstring_t<T> name, ios_base::openmode mode = ios_base::in)
explicit ifstream(const pstring_t<T> &name, ios_base::openmode mode = ios_base::in)
: std::ifstream(filename_type(name).c_str(), mode)
{
}
explicit ifstream(const std::string name, ios_base::openmode mode = ios_base::in)
explicit ifstream(const std::string &name, ios_base::openmode mode = ios_base::in)
: std::ifstream(filename_type(putf8string(name)).c_str(), mode)
{
}
@ -388,12 +388,12 @@ public:
pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type;
template <typename T>
explicit ofstream(const pstring_t<T> name, ios_base::openmode mode = ios_base::out | ios_base::trunc)
explicit ofstream(const pstring_t<T> &name, ios_base::openmode mode = ios_base::out | ios_base::trunc)
: std::ofstream(filename_type(name).c_str(), mode)
{
}
explicit ofstream(const std::string name, ios_base::openmode mode = ios_base::out | ios_base::trunc)
explicit ofstream(const std::string &name, ios_base::openmode mode = ios_base::out | ios_base::trunc)
: std::ofstream(filename_type(putf8string(name)).c_str(), mode)
{
}

View File

@ -243,7 +243,7 @@ namespace plib
auto p = str.begin();
auto pn = std::search(p, str.end(), onstr.begin(), onstr.end());
auto ol = onstr.length();
const auto ol = static_cast<typename T::difference_type>(onstr.length());
while (pn != str.end())
{

View File

@ -124,7 +124,7 @@ namespace testing
{
using reg_entry_base::reg_entry_base;
Test *create() const override { return new T(); }
Test *create() const override { return new T(); } // NOLINT
};
template <typename C, typename T1, typename T2>

View File

@ -3,8 +3,8 @@
#include "palloc.h"
#include "pstonum.h"
#include "ptokenizer.h"
#include "pstrutil.h"
#include "ptokenizer.h"
namespace plib {

View File

@ -24,6 +24,7 @@ namespace plib {
public:
explicit ptokenizer() // NOLINT(misc-forwarding-reference-overload, bugprone-forwarding-reference-overload)
: m_strm(nullptr)
, m_unget(0)
, m_string('"')
, m_support_line_markers(true) // FIXME
, m_token_queue(nullptr)
@ -61,6 +62,8 @@ namespace plib {
PCOPYASSIGNMOVE(token_id_t, default)
~token_id_t() = default;
std::size_t id() const { return m_id; }
const pstring & name() const { return m_name; }
private:
@ -89,6 +92,8 @@ namespace plib {
PCOPYASSIGNMOVE(token_t, default)
~token_t() = default;
bool is(const token_id_t &tok_id) const noexcept { return m_id == tok_id.id(); }
bool is_not(const token_id_t &tok_id) const noexcept { return !is(tok_id); }

View File

@ -55,14 +55,14 @@ namespace devices
const netlist_time_ext now(exec().time());
const std::size_t nthreads = m_params.m_parallel() < 2 ? 1 : std::min(static_cast<std::size_t>(m_params.m_parallel()), plib::omp::get_max_threads());
const netlist_time_ext sched(now + (nthreads <= 1 ? netlist_time_ext::zero() : netlist_time_ext::from_nsec(100)));
plib::uninitialised_array<solver::matrix_solver_t *, config::MAX_SOLVER_QUEUE_SIZE::value> tmp;
plib::uninitialised_array<netlist_time, config::MAX_SOLVER_QUEUE_SIZE::value> nt;
plib::uninitialised_array<solver::matrix_solver_t *, config::MAX_SOLVER_QUEUE_SIZE::value> tmp; //NOLINT
plib::uninitialised_array<netlist_time, config::MAX_SOLVER_QUEUE_SIZE::value> nt; //NOLINT
std::size_t p=0;
while (!m_queue.empty())
{
auto t = m_queue.top().exec_time();
auto o = m_queue.top().object();
const auto t = m_queue.top().exec_time();
auto *o = m_queue.top().object();
if (t != now)
if (t > sched)
break;
@ -72,7 +72,7 @@ namespace devices
// FIXME: Disabled for now since parallel processing will decrease performance
// for tested applications. More testing required here
if (1 || nthreads < 2)
if (true || nthreads < 2)
{
if (!KEEP_STATS)
{

View File

@ -8,8 +8,8 @@
/// \file nld_solver.h
///
#include "../plib/pstream.h"
#include "../nl_base.h"
#include "../plib/pstream.h"
#include "nld_matrix_solver.h"
#include <map>