From bf59ba76f55526c14c8d1737e70ecb0de74c1d95 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Wed, 31 Jul 2019 14:43:45 -0700 Subject: [PATCH] Fix most warnings on VS2019 (#241) --- benchmark/parse.cpp | 2 +- benchmark/statisticalmodel.cpp | 2 +- include/simdjson/parsedjson.h | 7 +-- include/simdjson/simdutf8check_haswell.h | 50 +++++++++---------- include/simdjson/simdutf8check_westmere.h | 30 +++++------ include/simdjson/stage1_find_marks.h | 2 +- include/simdjson/stage1_find_marks_haswell.h | 10 ++-- include/simdjson/stage1_find_marks_westmere.h | 8 +-- src/parsedjsoniterator.cpp | 6 +-- tests/jsoncheck.cpp | 2 +- tools/json2json.cpp | 2 +- tools/jsonstats.cpp | 2 +- tools/minify.cpp | 2 +- 13 files changed, 63 insertions(+), 62 deletions(-) diff --git a/benchmark/parse.cpp b/benchmark/parse.cpp index bcce04c71..ab5c0d4f3 100644 --- a/benchmark/parse.cpp +++ b/benchmark/parse.cpp @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) { simdjson::padded_string p; try { simdjson::get_corpus(filename).swap(p); - } catch (const std::exception &e) { // caught by reference to base + } catch (const std::exception &) { // caught by reference to base std::cout << "Could not load the file " << filename << std::endl; return EXIT_FAILURE; } diff --git a/benchmark/statisticalmodel.cpp b/benchmark/statisticalmodel.cpp index a43dd9ae7..0cf236fac 100644 --- a/benchmark/statisticalmodel.cpp +++ b/benchmark/statisticalmodel.cpp @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) { simdjson::padded_string p; try { simdjson::get_corpus(filename).swap(p); - } catch (const std::exception &e) { // caught by reference to base + } catch (const std::exception &) { // caught by reference to base std::cerr << "Could not load the file " << filename << std::endl; return EXIT_FAILURE; } diff --git a/include/simdjson/parsedjson.h b/include/simdjson/parsedjson.h index a4b9427a6..81f06d50c 100644 --- a/include/simdjson/parsedjson.h +++ b/include/simdjson/parsedjson.h @@ -7,6 +7,7 @@ #include "simdjson/simdjson.h" #include #include +#include #include #include #include @@ -107,9 +108,9 @@ public: explicit Iterator(ParsedJson &pj_); ~Iterator(); - Iterator(const Iterator &o); + Iterator(const Iterator &o) noexcept; - Iterator(Iterator &&o); + Iterator(Iterator &&o) noexcept; inline bool is_ok() const; @@ -167,7 +168,7 @@ public: // we're at "d" inline double get_double() const { if (location + 1 >= tape_length) { - return NAN; // default value in case of error + return std::numeric_limits::quiet_NaN(); // default value in case of error } double answer; memcpy(&answer, &pj.tape[location + 1], sizeof(answer)); diff --git a/include/simdjson/simdutf8check_haswell.h b/include/simdjson/simdutf8check_haswell.h index 72dcf9388..920730993 100644 --- a/include/simdjson/simdutf8check_haswell.h +++ b/include/simdjson/simdutf8check_haswell.h @@ -41,7 +41,7 @@ static inline void avx_check_smaller_than_0xF4(__m256i current_bytes, __m256i *has_error) { // unsigned, saturates to 0 below max *has_error = _mm256_or_si256( - *has_error, _mm256_subs_epu8(current_bytes, _mm256_set1_epi8(0xF4))); + *has_error, _mm256_subs_epu8(current_bytes, _mm256_set1_epi8(0xF4u))); } static inline __m256i avx_continuation_lengths(__m256i high_nibbles) { @@ -94,14 +94,14 @@ static inline void avx_check_first_continuation_max(__m256i current_bytes, __m256i off1_current_bytes, __m256i *has_error) { __m256i maskED = - _mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xED)); + _mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xEDu)); __m256i maskF4 = - _mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xF4)); + _mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xF4u)); __m256i badfollowED = _mm256_and_si256( - _mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x9F)), maskED); + _mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x9Fu)), maskED); __m256i badfollowF4 = _mm256_and_si256( - _mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x8F)), maskF4); + _mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x8Fu)), maskF4); *has_error = _mm256_or_si256(*has_error, _mm256_or_si256(badfollowED, badfollowF4)); @@ -119,31 +119,31 @@ static inline void avx_check_overlong(__m256i current_bytes, __m256i *has_error) { __m256i off1_hibits = push_last_byte_of_a_to_b(previous_hibits, hibits); __m256i initial_mins = _mm256_shuffle_epi8( - _mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, -128, // 10xx => false - 0xC2, -128, // 110x - 0xE1, // 1110 - 0xF1, // 1111 - -128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, -128, // 10xx => false - 0xC2, -128, // 110x - 0xE1, // 1110 - 0xF1), // 1111 + _mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, // 10xx => false + 0xC2u, -128, // 110x + 0xE1u, // 1110 + 0xF1u, // 1111 + -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, // 10xx => false + 0xC2u, -128, // 110x + 0xE1u, // 1110 + 0xF1u), // 1111 off1_hibits); __m256i initial_under = _mm256_cmpgt_epi8(initial_mins, off1_current_bytes); __m256i second_mins = _mm256_shuffle_epi8( - _mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, -128, // 10xx => false - 127, 127, // 110x => true - 0xA0, // 1110 - 0x90, // 1111 - -128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, -128, // 10xx => false - 127, 127, // 110x => true - 0xA0, // 1110 - 0x90), // 1111 + _mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, // 10xx => false + 127, 127, // 110x => true + 0xA0u, // 1110 + 0x90u, // 1111 + -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, // 10xx => false + 127, 127, // 110x => true + 0xA0u, // 1110 + 0x90u), // 1111 off1_hibits); __m256i second_under = _mm256_cmpgt_epi8(second_mins, current_bytes); *has_error = _mm256_or_si256(*has_error, diff --git a/include/simdjson/simdutf8check_westmere.h b/include/simdjson/simdutf8check_westmere.h index 5cfdd59ba..20d5b8836 100644 --- a/include/simdjson/simdutf8check_westmere.h +++ b/include/simdjson/simdutf8check_westmere.h @@ -35,7 +35,7 @@ static inline void check_smaller_than_0xF4(__m128i current_bytes, __m128i *has_error) { // unsigned, saturates to 0 below max *has_error = _mm_or_si128(*has_error, - _mm_subs_epu8(current_bytes, _mm_set1_epi8(0xF4))); + _mm_subs_epu8(current_bytes, _mm_set1_epi8(0xF4u))); } static inline __m128i continuation_lengths(__m128i high_nibbles) { @@ -80,13 +80,13 @@ static inline void check_continuations(__m128i initial_lengths, __m128i carries, static inline void check_first_continuation_max(__m128i current_bytes, __m128i off1_current_bytes, __m128i *has_error) { - __m128i maskED = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xED)); - __m128i maskF4 = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xF4)); + __m128i maskED = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xEDu)); + __m128i maskF4 = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xF4u)); __m128i badfollowED = - _mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x9F)), maskED); + _mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x9Fu)), maskED); __m128i badfollowF4 = - _mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x8F)), maskF4); + _mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x8Fu)), maskF4); *has_error = _mm_or_si128(*has_error, _mm_or_si128(badfollowED, badfollowF4)); } @@ -102,21 +102,21 @@ static inline void check_overlong(__m128i current_bytes, __m128i previous_hibits, __m128i *has_error) { __m128i off1_hibits = _mm_alignr_epi8(hibits, previous_hibits, 16 - 1); __m128i initial_mins = _mm_shuffle_epi8( - _mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, // 10xx => false - 0xC2, -128, // 110x - 0xE1, // 1110 - 0xF1), + _mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, // 10xx => false + 0xC2u, -128, // 110x + 0xE1u, // 1110 + 0xF1u), off1_hibits); __m128i initial_under = _mm_cmpgt_epi8(initial_mins, off1_current_bytes); __m128i second_mins = _mm_shuffle_epi8( - _mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, - -128, -128, // 10xx => false - 127, 127, // 110x => true - 0xA0, // 1110 - 0x90), + _mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -128, -128, // 10xx => false + 127, 127, // 110x => true + 0xA0u, // 1110 + 0x90u), off1_hibits); __m128i second_under = _mm_cmpgt_epi8(second_mins, current_bytes); *has_error = diff --git a/include/simdjson/stage1_find_marks.h b/include/simdjson/stage1_find_marks.h index 0eefb8785..bcf8e8991 100644 --- a/include/simdjson/stage1_find_marks.h +++ b/include/simdjson/stage1_find_marks.h @@ -11,7 +11,7 @@ namespace simdjson { template struct simd_input; -template uint64_t compute_quote_mask(uint64_t quote_bits); +template uint64_t compute_quote_mask(uint64_t quote_bits); namespace { // for when clmul is unavailable diff --git a/include/simdjson/stage1_find_marks_haswell.h b/include/simdjson/stage1_find_marks_haswell.h index f8ed26e00..64eeecafc 100644 --- a/include/simdjson/stage1_find_marks_haswell.h +++ b/include/simdjson/stage1_find_marks_haswell.h @@ -30,7 +30,7 @@ compute_quote_mask(uint64_t quote_bits) { // There should be no such thing with a processing supporting avx2 // but not clmul. uint64_t quote_mask = _mm_cvtsi128_si64(_mm_clmulepi64_si128( - _mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFF), 0)); + _mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFFu), 0)); return quote_mask; } @@ -49,7 +49,7 @@ template <> really_inline void check_utf8( simd_input in, utf8_checking_state &state) { - __m256i high_bit = _mm256_set1_epi8(0x80); + __m256i high_bit = _mm256_set1_epi8(0x80u); if ((_mm256_testz_si256(_mm256_or_si256(in.lo, in.hi), high_bit)) == 1) { // it is ascii, we just check continuation state.has_error = _mm256_or_si256( @@ -170,12 +170,12 @@ really_inline void find_whitespace_and_structurals( #else // SIMDJSON_NAIVE_STRUCTURAL const __m256i structural_table = - _mm256_setr_epi8(44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123, - 44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123); + _mm256_setr_epi8(44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123, + 44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123); const __m256i white_table = _mm256_setr_epi8( 32, 100, 100, 100, 17, 100, 113, 2, 100, 9, 10, 112, 100, 13, 100, 100, 32, 100, 100, 100, 17, 100, 113, 2, 100, 9, 10, 112, 100, 13, 100, 100); - const __m256i struct_offset = _mm256_set1_epi8(0xd4); + const __m256i struct_offset = _mm256_set1_epi8(0xd4u); const __m256i struct_mask = _mm256_set1_epi8(32); __m256i lo_white = diff --git a/include/simdjson/stage1_find_marks_westmere.h b/include/simdjson/stage1_find_marks_westmere.h index cb85d69cd..dacd2923f 100644 --- a/include/simdjson/stage1_find_marks_westmere.h +++ b/include/simdjson/stage1_find_marks_westmere.h @@ -32,7 +32,7 @@ template <> really_inline uint64_t compute_quote_mask(uint64_t quote_bits) { return _mm_cvtsi128_si64(_mm_clmulepi64_si128( - _mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFF), 0)); + _mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFFu), 0)); } template <> struct utf8_checking_state { @@ -48,7 +48,7 @@ template <> really_inline void check_utf8( simd_input in, utf8_checking_state &state) { - __m128i high_bit = _mm_set1_epi8(0x80); + __m128i high_bit = _mm_set1_epi8(0x80u); if ((_mm_testz_si128(_mm_or_si128(in.v0, in.v1), high_bit)) == 1) { // it is ascii, we just check continuation state.has_error = @@ -140,10 +140,10 @@ really_inline void find_whitespace_and_structurals( simd_input in, uint64_t &whitespace, uint64_t &structurals) { const __m128i structural_table = - _mm_setr_epi8(44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123); + _mm_setr_epi8(44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123); const __m128i white_table = _mm_setr_epi8(32, 100, 100, 100, 17, 100, 113, 2, 100, 9, 10, 112, 100, 13, 100, 100); - const __m128i struct_offset = _mm_set1_epi8(0xd4); + const __m128i struct_offset = _mm_set1_epi8(0xd4u); const __m128i struct_mask = _mm_set1_epi8(32); __m128i white0 = _mm_cmpeq_epi8(in.v0, _mm_shuffle_epi8(white_table, in.v0)); diff --git a/src/parsedjsoniterator.cpp b/src/parsedjsoniterator.cpp index 96dc7a17b..c43c8ca97 100644 --- a/src/parsedjsoniterator.cpp +++ b/src/parsedjsoniterator.cpp @@ -34,7 +34,7 @@ ParsedJson::Iterator::Iterator(ParsedJson &pj_) ParsedJson::Iterator::~Iterator() { delete[] depth_index; } -ParsedJson::Iterator::Iterator(const Iterator &o) +ParsedJson::Iterator::Iterator(const Iterator &o) noexcept : pj(o.pj), depth(o.depth), location(o.location), tape_length(0), current_type(o.current_type), current_val(o.current_val), depth_index(nullptr) { @@ -45,7 +45,7 @@ ParsedJson::Iterator::Iterator(const Iterator &o) tape_length = o.tape_length; } -ParsedJson::Iterator::Iterator(Iterator &&o) +ParsedJson::Iterator::Iterator(Iterator &&o) noexcept : pj(o.pj), depth(o.depth), location(o.location), tape_length(o.tape_length), current_type(o.current_type), current_val(o.current_val), depth_index(o.depth_index) { @@ -114,7 +114,7 @@ bool ParsedJson::Iterator::move_to(const char *pointer, uint32_t length) { } new_pointer[new_length] = fragment; i += 3; - } catch (std::invalid_argument &e) { + } catch (std::invalid_argument &) { delete[] new_pointer; return false; // the fragment is invalid } diff --git a/tests/jsoncheck.cpp b/tests/jsoncheck.cpp index 4c861bf0f..ed8d9bdc3 100644 --- a/tests/jsoncheck.cpp +++ b/tests/jsoncheck.cpp @@ -68,7 +68,7 @@ bool validate(const char *dirname) { simdjson::padded_string p; try { simdjson::get_corpus(fullpath).swap(p); - } catch (const std::exception &e) { + } catch (const std::exception &) { std::cerr << "Could not load the file " << fullpath << std::endl; return EXIT_FAILURE; } diff --git a/tools/json2json.cpp b/tools/json2json.cpp index f9910335d..f2415575a 100644 --- a/tools/json2json.cpp +++ b/tools/json2json.cpp @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) { simdjson::padded_string p; try { simdjson::get_corpus(filename).swap(p); - } catch (const std::exception &e) { // caught by reference to base + } catch (const std::exception &) { // caught by reference to base std::cout << "Could not load the file " << filename << std::endl; return EXIT_FAILURE; } diff --git a/tools/jsonstats.cpp b/tools/jsonstats.cpp index 9fbb0e673..44e072cc3 100644 --- a/tools/jsonstats.cpp +++ b/tools/jsonstats.cpp @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) { simdjson::padded_string p; try { simdjson::get_corpus(filename).swap(p); - } catch (const std::exception &e) { // caught by reference to base + } catch (const std::exception &) { // caught by reference to base std::cerr << "Could not load the file " << filename << std::endl; return EXIT_FAILURE; } diff --git a/tools/minify.cpp b/tools/minify.cpp index 4d7fa2486..a2d70ec7b 100644 --- a/tools/minify.cpp +++ b/tools/minify.cpp @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) { std::string filename = argv[argc - 1]; try { simdjson::get_corpus(filename).swap(p); - } catch (const std::exception &e) { + } catch (const std::exception &) { std::cout << "Could not load the file " << filename << std::endl; return EXIT_FAILURE; }