diff --git a/keyvi/include/keyvi/compression/predictive_compression.h b/keyvi/include/keyvi/compression/predictive_compression.h index d02cd8c9c..39acee8ee 100644 --- a/keyvi/include/keyvi/compression/predictive_compression.h +++ b/keyvi/include/keyvi/compression/predictive_compression.h @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -58,7 +60,7 @@ class PredictiveCompression final { if (bigram[0] == 0 || bigram[1] == 0) { return ""; } else { - return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]]; + return predictor_table_[(static_cast(bigram[0]) << 8U) + bigram[1]]; } } @@ -210,7 +212,7 @@ class PredictiveCompression final { char c; instream.get(c); if (instream.eof()) break; - uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get(); + const uint16_t index = ((static_cast(c) & 0xFFU) << 8U) + instream.get(); uint8_t length = instream.get(); if (length > 8) { char error[100]; diff --git a/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector.h b/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector.h index 633f51e90..f7a874bf0 100644 --- a/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector.h +++ b/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector.h @@ -68,7 +68,7 @@ struct BitVector final { * Sets a bit in the bitvector. * @param bit the bit to set. */ - inline void Set(const size_t bit) { bits_[bit >> 5] |= (uint32_t)1 << (bit & 31); } + inline void Set(const size_t bit) { bits_[bit >> 5] |= static_cast(1) << (bit & 31); } /** * Sets all bits of the given bitvector @@ -86,7 +86,7 @@ struct BitVector final { bits_[byte_position + i] |= other.bits_[i]; } } else { - bits_[byte_position] |= ((uint32_t)other.bits_[0] << bit_position); + bits_[byte_position] |= (static_cast(other.bits_[0]) << bit_position); for (size_t i = 1; i < write_length; i++) { bits_[byte_position + i] |= ((other.bits_[i] << bit_position) | (other.bits_[i - 1] >> (32 - bit_position))); } @@ -117,7 +117,7 @@ struct BitVector final { * Erase a bit, set it to 0. * @param bit the bit to erase. */ - inline void Erase(const size_t bit) { bits_[bit >> 5] &= (uint32_t)(~(1 << (bit & 31))); } + inline void Erase(const size_t bit) { bits_[bit >> 5] &= static_cast(~(1 << (bit & 31))); } /** Gets the state of the given bit * diff --git a/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector_64.h b/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector_64.h index d76fb2771..1f39ed9af 100644 --- a/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector_64.h +++ b/keyvi/include/keyvi/dictionary/fsa/internal/bit_vector_64.h @@ -27,7 +27,10 @@ #include #include +#include +#include #include +#include namespace keyvi { namespace dictionary { @@ -63,7 +66,7 @@ struct BitVector final { * Sets a bit in the bitvector. * @param bit the bit to set. */ - inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); } + void Set(const size_t bit) { bits_[bit >> 6U] |= static_cast(1) << (bit & 63U); } /** * Sets all bits of the given bitvector @@ -81,7 +84,7 @@ struct BitVector final { bits_[byte_position + i] |= other.bits_[i]; } } else { - bits_[byte_position] |= ((uint64_t)other.bits_[0] << bit_position); + bits_[byte_position] |= (static_cast(other.bits_[0]) << bit_position); for (size_t i = 1; i < write_length; ++i) { bits_[byte_position + i] |= ((other.bits_[i] << bit_position) | (other.bits_[i - 1] >> (64 - bit_position))); } @@ -112,14 +115,16 @@ struct BitVector final { * Erase a bit, set it to 0. * @param bit the bit to erase. */ - inline void Erase(const size_t bit) { bits_[bit >> 6] &= (uint64_t)(~(1 << (bit & 63))); } + void Erase(const size_t bit) { bits_[bit >> 6U] &= static_cast(~(1ULL << (bit & 63U))); } /** Gets the state of the given bit * * @param bit the bit * @return True if set, false otherwise. */ - inline bool Get(const size_t bit) const { return (bits_[bit >> 6] & ((uint64_t)1 << (bit & 63))) != 0; } + [[nodiscard]] bool Get(const size_t bit) const { + return (bits_[bit >> 6U] & (static_cast(1) << (bit & 63U))) != 0; + } /** * Get the next non set bit in the bitvector starting from the given position. diff --git a/keyvi/include/keyvi/dictionary/fsa/internal/packed_state.h b/keyvi/include/keyvi/dictionary/fsa/internal/packed_state.h index f62154629..48b6928c5 100644 --- a/keyvi/include/keyvi/dictionary/fsa/internal/packed_state.h +++ b/keyvi/include/keyvi/dictionary/fsa/internal/packed_state.h @@ -26,6 +26,7 @@ #define KEYVI_DICTIONARY_FSA_INTERNAL_PACKED_STATE_H_ #include +#include #include namespace keyvi { @@ -51,16 +52,18 @@ struct PackedState final { public: PackedState() : PackedState(0, 0, 0) {} PackedState(OffsetTypeT offset, HashCodeTypeT hashcode, int num_outgoing) - : offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_((uint32_t)(num_outgoing & 0x1FF)) {} + : offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_(static_cast(num_outgoing) & 0x1FFU) {} HashCodeTypeT GetHashcode() const { return hashcode_; } - int GetNumberOfOutgoingTransitions() const { return static_cast(this->num_outgoing_and_cookie_ & 0x1FF); } + [[nodiscard]] int GetNumberOfOutgoingTransitions() const { + return static_cast(this->num_outgoing_and_cookie_ & 0x1FFU); + } - int GetCookie() const { return static_cast((this->num_outgoing_and_cookie_ & 0xFFFFFE00) >> 9); } + [[nodiscard]] int GetCookie() const { return static_cast((this->num_outgoing_and_cookie_ & 0xFFFFFE00U) >> 9U); } void SetCookie(int value) { - this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FF) | (uint32_t)(value << 9); + this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFU) | (static_cast(value) << 9U); } OffsetTypeT GetOffset() const { return offset_; } diff --git a/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_builder.h b/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_builder.h index e40790b0b..9a969a80d 100644 --- a/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_builder.h +++ b/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_builder.h @@ -25,6 +25,8 @@ #ifndef KEYVI_DICTIONARY_FSA_INTERNAL_SPARSE_ARRAY_BUILDER_H_ #define KEYVI_DICTIONARY_FSA_INTERNAL_SPARSE_ARRAY_BUILDER_H_ +#include // NOLINT(misc-include-cleaner) + #include "keyvi/dictionary/fsa/internal/constants.h" #include "keyvi/dictionary/fsa/internal/lru_generation_cache.h" #include "keyvi/dictionary/fsa/internal/minimization_hash.h" diff --git a/keyvi/tests/keyvi/dictionary/fsa/automata_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/automata_test.cpp index 81c947976..dfb147fb9 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/automata_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/automata_test.cpp @@ -23,6 +23,9 @@ * Author: hendrik */ +#include +#include + #include #include "keyvi/dictionary/fsa/automata.h" diff --git a/keyvi/tests/keyvi/dictionary/fsa/codepoint_state_traverser_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/codepoint_state_traverser_test.cpp index 0551b60b2..dc9ff4421 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/codepoint_state_traverser_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/codepoint_state_traverser_test.cpp @@ -23,6 +23,9 @@ * Author: hendrik */ +#include +#include + #include #include "keyvi/dictionary/fsa/codepoint_state_traverser.h" diff --git a/keyvi/tests/keyvi/dictionary/fsa/entry_iterator_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/entry_iterator_test.cpp index 39ed4444e..fc42485f9 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/entry_iterator_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/entry_iterator_test.cpp @@ -23,6 +23,9 @@ * Author: hendrik */ +#include +#include + #include #include "keyvi/dictionary/fsa/entry_iterator.h" diff --git a/keyvi/tests/keyvi/dictionary/fsa/generator_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/generator_test.cpp index 3d1a41922..18d81aee9 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/generator_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/generator_test.cpp @@ -23,6 +23,8 @@ * Author: hendrik */ +#include + #include #include diff --git a/keyvi/tests/keyvi/dictionary/fsa/internal/json_value_store_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/internal/json_value_store_test.cpp index ba4a0bd89..af7aa4b59 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/internal/json_value_store_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/internal/json_value_store_test.cpp @@ -24,6 +24,8 @@ #include "keyvi/dictionary/fsa/internal/json_value_store.h" +#include + #include #include #include diff --git a/keyvi/tests/keyvi/dictionary/fsa/internal/packed_state_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/internal/packed_state_test.cpp index e35ce5a13..20c6518b1 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/internal/packed_state_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/internal/packed_state_test.cpp @@ -23,6 +23,8 @@ * Author: hendrik */ +#include + #include #include "keyvi/dictionary/fsa/internal/packed_state.h" @@ -56,7 +58,7 @@ BOOST_AUTO_TEST_CASE(compare64) { BOOST_CHECK(p.GetHashcode() == 42); int64_t hashcode = std::numeric_limits::max(); - int32_t hashcode_32 = (int32_t)hashcode; + const auto hashcode_32 = static_cast(hashcode); PackedState<> p2(0, hashcode, 42); diff --git a/keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp index 83d3596a4..cfa516524 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/internal/sliding_window_bit_vector_position_tracker_test.cpp @@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(no_integer_overflow) { positions.Set(10); // trigger switch of the bit vectors - uint32_t t = uint32_t(INT_MAX) + 10; + const uint32_t t = static_cast(INT_MAX) + 10; positions.Set(t); BOOST_CHECK(positions.IsSet(t)); diff --git a/keyvi/tests/keyvi/dictionary/fsa/weighted_state_traverser_test.cpp b/keyvi/tests/keyvi/dictionary/fsa/weighted_state_traverser_test.cpp index 756506285..4c17a43d0 100644 --- a/keyvi/tests/keyvi/dictionary/fsa/weighted_state_traverser_test.cpp +++ b/keyvi/tests/keyvi/dictionary/fsa/weighted_state_traverser_test.cpp @@ -23,6 +23,9 @@ * Author: hendrik */ +#include +#include + #include #include "keyvi/dictionary/fsa/automata.h" diff --git a/keyvi/tests/keyvi/dictionary/matching/fuzzy_matching_test.cpp b/keyvi/tests/keyvi/dictionary/matching/fuzzy_matching_test.cpp index 0ba341842..561f5f6eb 100644 --- a/keyvi/tests/keyvi/dictionary/matching/fuzzy_matching_test.cpp +++ b/keyvi/tests/keyvi/dictionary/matching/fuzzy_matching_test.cpp @@ -23,6 +23,10 @@ */ #include +#include +#include +#include +#include #include diff --git a/keyvi/tests/keyvi/index/index_test.cpp b/keyvi/tests/keyvi/index/index_test.cpp index 2bac2635b..b05a0d3d7 100644 --- a/keyvi/tests/keyvi/index/index_test.cpp +++ b/keyvi/tests/keyvi/index/index_test.cpp @@ -25,7 +25,12 @@ #include //NOLINT #include +#include +#include +#include #include //NOLINT +#include +#include #include #include diff --git a/keyvi/tests/keyvi/index/internal/read_only_segment_test.cpp b/keyvi/tests/keyvi/index/internal/read_only_segment_test.cpp index a28746dc0..eb806e476 100644 --- a/keyvi/tests/keyvi/index/internal/read_only_segment_test.cpp +++ b/keyvi/tests/keyvi/index/internal/read_only_segment_test.cpp @@ -17,6 +17,8 @@ // #include +#include +#include #include diff --git a/keyvi/tests/keyvi/index/internal/segment_test.cpp b/keyvi/tests/keyvi/index/internal/segment_test.cpp index 7ad81ca22..a41682ae4 100644 --- a/keyvi/tests/keyvi/index/internal/segment_test.cpp +++ b/keyvi/tests/keyvi/index/internal/segment_test.cpp @@ -17,6 +17,8 @@ // #include +#include +#include #include #include diff --git a/keyvi/tests/keyvi/index/internal/tiered_merge_policy_test.cpp b/keyvi/tests/keyvi/index/internal/tiered_merge_policy_test.cpp index d21656ada..5c60e73e4 100644 --- a/keyvi/tests/keyvi/index/internal/tiered_merge_policy_test.cpp +++ b/keyvi/tests/keyvi/index/internal/tiered_merge_policy_test.cpp @@ -24,6 +24,9 @@ */ #include +#include +#include +#include #include diff --git a/keyvi/tests/keyvi/stringdistance/levenshtein_test.cpp b/keyvi/tests/keyvi/stringdistance/levenshtein_test.cpp index 265e93646..56974860a 100644 --- a/keyvi/tests/keyvi/stringdistance/levenshtein_test.cpp +++ b/keyvi/tests/keyvi/stringdistance/levenshtein_test.cpp @@ -23,6 +23,8 @@ * Author: hendrik */ #include +#include +#include #include diff --git a/keyvi/tests/keyvi/transform/fsa_transform_test.cpp b/keyvi/tests/keyvi/transform/fsa_transform_test.cpp index 8d1c16a15..cc0812ae9 100644 --- a/keyvi/tests/keyvi/transform/fsa_transform_test.cpp +++ b/keyvi/tests/keyvi/transform/fsa_transform_test.cpp @@ -24,6 +24,8 @@ */ #include +#include +#include #include