diff options
author | 2020-01-31 20:20:53 +0100 | |
---|---|---|
committer | 2020-01-31 20:20:53 +0100 | |
commit | 72f86082aaef3166335dad915fa4656073a51a76 (patch) | |
tree | e95111d3ffdc0dc259ef54d19ecf0c924b9e2b30 | |
parent | 146739fb884397840555dbd0dceb01aeb9f191c8 (diff) |
netlist: clang lint fixes. (nw)
-rw-r--r-- | src/lib/netlist/devices/nlid_truthtable.cpp | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/pmempool.h | 4 | ||||
-rw-r--r-- | src/lib/netlist/plib/ppreprocessor.cpp | 20 | ||||
-rw-r--r-- | src/lib/netlist/plib/ppreprocessor.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/pstring.h | 56 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptokenizer.cpp | 20 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptypes.h | 2 |
7 files changed, 53 insertions, 53 deletions
diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index b213faea082..d674513e62a 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -321,7 +321,7 @@ namespace devices { tt_bitset bj(j); size_t nb(bj.count()); - if ((t[j] == false) && (nb>jb)) + if (!t[j] && (nb > jb)) { jb = nb; jm = bj; diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index a06c67acd8e..aab6448258b 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -149,7 +149,7 @@ namespace plib { } catch (...) { - this->deallocate(mem, sizeof(T)); + deallocate(mem, sizeof(T)); throw; } } @@ -165,7 +165,7 @@ namespace plib { } catch (...) { - this->deallocate(mem, sizeof(T)); + deallocate(mem, sizeof(T)); throw; } } diff --git a/src/lib/netlist/plib/ppreprocessor.cpp b/src/lib/netlist/plib/ppreprocessor.cpp index 74d32fcd477..3ed1885f007 100644 --- a/src/lib/netlist/plib/ppreprocessor.cpp +++ b/src/lib/netlist/plib/ppreprocessor.cpp @@ -447,8 +447,8 @@ namespace plib { m_state = LINE_CONTINUATION; return {"", false}; } - else - m_state = PROCESS; + + m_state = PROCESS; line = process_comments(m_line); @@ -582,13 +582,11 @@ namespace plib { } return { "", false }; } - else - { - if (m_if_flag == 0) - return { replace_macros(lt), true }; - else - return { "", false }; - } + + if (m_if_flag == 0) + return { replace_macros(lt), true }; + + return { "", false }; } void ppreprocessor::push_out(const pstring &s) @@ -600,7 +598,7 @@ namespace plib { void ppreprocessor::process_stack() { - while (m_stack.size() > 0) + while (!m_stack.empty()) { pstring line; pstring linemarker = pfmt("# {1} \"{2}\"\n")(m_stack.back().m_lineno, m_stack.back().m_name); @@ -621,7 +619,7 @@ namespace plib { last_skipped = true; } m_stack.pop_back(); - if (m_stack.size() > 0) + if (!m_stack.empty()) { linemarker = pfmt("# {1} \"{2}\" 2\n")(m_stack.back().m_lineno, m_stack.back().m_name); push_out(linemarker); diff --git a/src/lib/netlist/plib/ppreprocessor.h b/src/lib/netlist/plib/ppreprocessor.h index fe498fc1148..30af8d936f2 100644 --- a/src/lib/netlist/plib/ppreprocessor.h +++ b/src/lib/netlist/plib/ppreprocessor.h @@ -132,7 +132,7 @@ namespace plib { void process_stack(); string_list tokenize(const pstring &str, const string_list &sep, bool remove_ws, bool concat); - bool is_valid_token(const pstring &str); + static bool is_valid_token(const pstring &str); std::pair<pstring,bool> process_line(pstring line); pstring process_comments(pstring line); diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 86b041cadaf..11397c54c51 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -251,42 +251,43 @@ struct putf8_traits const auto p1 = reinterpret_cast<const unsigned char *>(p); if ((*p1 & 0xE0) == 0xC0) return 2; - else if ((*p1 & 0xF0) == 0xE0) + if ((*p1 & 0xF0) == 0xE0) return 3; - else if ((*p1 & 0xF8) == 0xF0) + if ((*p1 & 0xF8) == 0xF0) return 4; - else - { - // valid utf8: ((*p1 & 0x80) == 0x00) - // However, we return 1 here. - return 1; - } + + // valid utf8: ((*p1 & 0x80) == 0x00) + // However, we return 1 here. + return 1; } + static std::size_t codelen(const code_t c) noexcept { if (c < 0x0080) return 1; - else if (c < 0x800) + if (c < 0x800) return 2; - else if (c < 0x10000) + if (c < 0x10000) return 3; - else // U+10000 U+1FFFFF - return 4; // no checks + // U+10000 U+1FFFFF + return 4; // no checks } + static code_t code(const mem_t *p) noexcept { const auto p1 = reinterpret_cast<const unsigned char *>(p); if ((*p1 & 0x80) == 0x00) return *p1; - else if ((*p1 & 0xE0) == 0xC0) + if ((*p1 & 0xE0) == 0xC0) return static_cast<code_t>(((p1[0] & 0x3f) << 6) | (p1[1] & 0x3f)); - else if ((*p1 & 0xF0) == 0xE0) + if ((*p1 & 0xF0) == 0xE0) return static_cast<code_t>(((p1[0] & 0x1f) << 12) | ((p1[1] & 0x3f) << 6) | ((p1[2] & 0x3f) << 0)); - else if ((*p1 & 0xF8) == 0xF0) + 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 0xFFFD; // unicode-replacement character + + return 0xFFFD; // unicode-replacement character } + static void encode(const code_t c, string_type &s) { if (c < 0x0080) @@ -312,6 +313,7 @@ struct putf8_traits s += static_cast<mem_t>(0x80 | (c & 0x3f)); } } + static const mem_t *nthcode(const mem_t *p, const std::size_t n) noexcept { const mem_t *p1 = p; @@ -409,8 +411,8 @@ struct pwchar_traits } return ret; } - else - return p.size(); + + return p.size(); } static std::size_t codelen(const mem_t *p) noexcept @@ -420,16 +422,16 @@ struct pwchar_traits auto c = static_cast<uint16_t>(*p); return ((c & 0xd800) == 0xd800) ? 2 : 1; } - else - return 1; + + return 1; } static std::size_t codelen(const code_t c) noexcept { if (sizeof(wchar_t) == 2) return ((c & 0xd800) == 0xd800) ? 2 : 1; - else - return 1; + + return 1; } static code_t code(const mem_t *p) @@ -444,8 +446,8 @@ struct pwchar_traits } return static_cast<code_t>(c); } - else - return static_cast<code_t>(*p); + + return static_cast<code_t>(*p); } static void encode(code_t c, string_type &s) @@ -475,8 +477,8 @@ struct pwchar_traits p += codelen(p); return p; } - else - return p + n; + + return p + n; } }; diff --git a/src/lib/netlist/plib/ptokenizer.cpp b/src/lib/netlist/plib/ptokenizer.cpp index 7ccb0ff8ca2..46af36d2bf9 100644 --- a/src/lib/netlist/plib/ptokenizer.cpp +++ b/src/lib/netlist/plib/ptokenizer.cpp @@ -151,7 +151,8 @@ namespace plib { { if (ret.is_type(token_type::token_type::ENDOFFILE)) return ret; - else if (m_support_line_markers && ret.is_type(token_type::LINEMARKER)) + + if (m_support_line_markers && ret.is_type(token_type::LINEMARKER)) { bool benter(false); bool bexit(false); @@ -215,7 +216,8 @@ namespace plib { } if (m_support_line_markers && c == '#') return token_t(token_type::LINEMARKER, "#"); - else if (m_number_chars_start.find(c) != pstring::npos) + + if (m_number_chars_start.find(c) != pstring::npos) { // read number while we receive number or identifier chars // treat it as an identifier when there are identifier chars in it @@ -243,10 +245,9 @@ namespace plib { } ungetc(c); auto id = m_tokens.find(tokstr); - if (id != m_tokens.end()) - return token_t(id->second, tokstr); - else - return token_t(token_type::IDENTIFIER, tokstr); + return (id != m_tokens.end()) ? + token_t(id->second, tokstr) + : token_t(token_type::IDENTIFIER, tokstr); } else if (c == m_string) { @@ -277,10 +278,9 @@ namespace plib { } ungetc(c); auto id = m_tokens.find(tokstr); - if (id != m_tokens.end()) - return token_t(id->second, tokstr); - else - return token_t(token_type::UNKNOWN, tokstr); + return (id != m_tokens.end()) ? + token_t(id->second, tokstr) + : token_t(token_type::UNKNOWN, tokstr); } } diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index 32ec6e7f9bf..d011d228154 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -80,7 +80,7 @@ namespace plib // Avoid unused variable warnings //============================================================ template<typename... Ts> - inline void unused_var(Ts&&...) noexcept {} + inline void unused_var(Ts&&...) noexcept {} // NOLINT(readability-named-parameter) } // namespace plib |