From bb2bc98a22b68471f193a3f3a60effd9d15183e2 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 13 Oct 2020 09:18:54 -0400 Subject: [PATCH] Fix issue https://github.com/simdjson/simdjson/issues/1127 (#1224) --- benchmark/bench_dom_api.cpp | 54 +++++----- benchmark/bench_parse_call.cpp | 22 ++-- benchmark/distinctuseridcompetition.cpp | 2 +- benchmark/event_counter.h | 2 +- benchmark/json_benchmark.h | 2 +- benchmark/kostya/kostya.h | 2 +- benchmark/largerandom/largerandom.h | 2 +- benchmark/parsingcompetition.cpp | 2 +- benchmark/partial_tweets/tweet.h | 2 +- fuzz/fuzz_dump_raw_tape.cpp | 2 +- fuzz/fuzz_parser.cpp | 4 +- include/simdjson/arm64/implementation.h | 6 +- include/simdjson/common_defs.h | 8 +- include/simdjson/dom/document-inl.h | 2 +- include/simdjson/dom/element-inl.h | 6 +- include/simdjson/dom/element.h | 4 +- include/simdjson/dom/jsonparser.h | 8 +- .../simdjson/dom/parsedjson_iterator-inl.h | 2 +- include/simdjson/dom/parser-inl.h | 4 +- include/simdjson/dom/parser.h | 4 +- include/simdjson/error-inl.h | 4 +- include/simdjson/error.h | 2 +- include/simdjson/fallback/implementation.h | 6 +- include/simdjson/generic/atomparsing.h | 14 +-- .../generic/dom_parser_implementation.h | 20 ++-- .../implementation_simdjson_result_base-inl.h | 2 +- include/simdjson/generic/numberparsing.h | 20 ++-- include/simdjson/generic/ondemand/array-inl.h | 2 +- .../generic/ondemand/json_iterator-inl.h | 68 ++++++------ .../simdjson/generic/ondemand/json_iterator.h | 68 ++++++------ .../simdjson/generic/ondemand/object-inl.h | 2 +- .../simdjson/generic/ondemand/parser-inl.h | 6 +- include/simdjson/generic/ondemand/parser.h | 8 +- .../generic/ondemand/raw_json_string-inl.h | 18 ++-- .../generic/ondemand/raw_json_string.h | 18 ++-- include/simdjson/generic/ondemand/value-inl.h | 2 +- include/simdjson/generic/stringparsing.h | 6 +- include/simdjson/haswell/implementation.h | 6 +- include/simdjson/implementation.h | 10 +- .../internal/dom_parser_implementation.h | 12 +-- include/simdjson/minify.h | 2 +- include/simdjson/westmere/implementation.h | 6 +- src/arm64/dom_parser_implementation.cpp | 14 +-- src/arm64/implementation.cpp | 2 +- src/fallback/dom_parser_implementation.cpp | 12 +-- src/fallback/implementation.cpp | 2 +- src/generic/stage1/buf_block_reader.h | 6 +- src/generic/stage2/json_iterator.h | 12 +-- src/generic/stage2/logger.h | 2 +- src/generic/stage2/tape_builder.h | 100 +++++++++--------- src/haswell/dom_parser_implementation.cpp | 14 +-- src/haswell/implementation.cpp | 2 +- src/implementation.cpp | 16 +-- src/westmere/dom_parser_implementation.cpp | 14 +-- src/westmere/implementation.cpp | 2 +- tests/allparserscheckfile.cpp | 2 +- tests/basictests.cpp | 20 ++-- tests/cast_tester.h | 4 +- tests/document_stream_tests.cpp | 4 +- tests/document_tests.cpp | 2 +- tests/errortests.cpp | 4 +- tests/ondemand/ondemand_basictests.cpp | 26 ++--- tests/unicode_tests.cpp | 2 +- 63 files changed, 352 insertions(+), 352 deletions(-) diff --git a/benchmark/bench_dom_api.cpp b/benchmark/bench_dom_api.cpp index b80578f17..6fdb788ff 100644 --- a/benchmark/bench_dom_api.cpp +++ b/benchmark/bench_dom_api.cpp @@ -26,7 +26,7 @@ static void recover_one_string(State& state) { cerr << "could not parse string" << error << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::string_view v; error = doc.get(v); if (error) { @@ -58,7 +58,7 @@ static void serialize_twitter(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::string serial = simdjson::minify(doc); bytes += serial.size(); benchmark::DoNotOptimize(serial); @@ -97,7 +97,7 @@ static void serialize_big_string_to_string(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { auto serial = simdjson::to_string(doc); bytes += serial.size(); benchmark::DoNotOptimize(serial); @@ -132,7 +132,7 @@ static void serialize_twitter_to_string(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { auto serial = simdjson::to_string(doc); bytes += serial.size(); benchmark::DoNotOptimize(serial); @@ -175,7 +175,7 @@ static void serialize_twitter_string_builder(State& state) { } size_t bytes = 0; simdjson::internal::string_builder<> sb;// not part of our public API, for internal use - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { sb.clear(); sb.append(doc); std::string_view serial = sb.str(); @@ -202,7 +202,7 @@ static void numbers_scan(State& state) { cerr << "could not read " << NUMBERS_JSON << " as an array: " << error << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; for (auto e : arr) { double x; @@ -224,7 +224,7 @@ static void numbers_size_scan(State& state) { cerr << "could not read " << NUMBERS_JSON << " as an array: " << error << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; container.resize(arr.size()); size_t pos = 0; @@ -250,7 +250,7 @@ static void numbers_type_scan(State& state) { cerr << "could not read " << NUMBERS_JSON << " as an array" << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; for (auto e : arr) { dom::element_type actual_type = e.type(); @@ -276,7 +276,7 @@ static void numbers_type_size_scan(State& state) { cerr << "could not read " << NUMBERS_JSON << " as an array: " << error << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; container.resize(arr.size()); size_t pos = 0; @@ -301,7 +301,7 @@ static void numbers_load_scan(State& state) { dom::parser parser; dom::array arr; simdjson::error_code error; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { // this may hit the disk, but probably just once if ((error = parser.load(NUMBERS_JSON).get(arr))) { cerr << "could not read " << NUMBERS_JSON << " as an array: " << error << endl; @@ -324,7 +324,7 @@ static void numbers_load_size_scan(State& state) { dom::parser parser; dom::array arr; simdjson::error_code error; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { // this may hit the disk, but probably just once if ((error = parser.load(NUMBERS_JSON).get(arr))) { cerr << "could not read " << NUMBERS_JSON << " as an array" << endl; @@ -353,7 +353,7 @@ static void numbers_exceptions_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; dom::array arr = parser.load(NUMBERS_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; for (double x : arr) { container.push_back(x); @@ -368,7 +368,7 @@ static void numbers_exceptions_size_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; dom::array arr = parser.load(NUMBERS_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; container.resize(arr.size()); size_t pos = 0; @@ -388,7 +388,7 @@ static void numbers_type_exceptions_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; dom::array arr = parser.load(NUMBERS_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; for (auto e : arr) { dom::element_type actual_type = e.type(); @@ -407,7 +407,7 @@ static void numbers_type_exceptions_size_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; dom::array arr = parser.load(NUMBERS_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::vector container; container.resize(arr.size()); size_t pos = 0; @@ -428,7 +428,7 @@ BENCHMARK(numbers_type_exceptions_size_scan); static void numbers_exceptions_load_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { // this may hit the disk, but probably just once dom::array arr = parser.load(NUMBERS_JSON); std::vector container; @@ -444,7 +444,7 @@ BENCHMARK(numbers_exceptions_load_scan); static void numbers_exceptions_load_size_scan(State& state) { // Prints the number of results in twitter.json dom::parser parser; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { // this may hit the disk, but probably just once dom::array arr = parser.load(NUMBERS_JSON); std::vector container; @@ -465,7 +465,7 @@ static void twitter_count(State& state) { // Prints the number of results in twitter.json dom::parser parser; dom::element doc = parser.load(TWITTER_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { uint64_t result_count = doc["search_metadata"]["count"]; if (result_count != 100) { return; } } @@ -478,7 +478,7 @@ static void iterator_twitter_count(State& state) { // Prints the number of results in twitter.json padded_string json = padded_string::load(TWITTER_JSON); ParsedJson pj = build_parsed_json(json); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { ParsedJson::Iterator iter(pj); // uint64_t result_count = doc["search_metadata"]["count"]; if (!iter.move_to_key("search_metadata")) { return; } @@ -496,7 +496,7 @@ static void twitter_default_profile(State& state) { // Count unique users with a default profile. dom::parser parser; dom::element doc = parser.load(TWITTER_JSON); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set default_users; for (dom::object tweet : doc["statuses"]) { dom::object user = tweet["user"]; @@ -514,7 +514,7 @@ static void twitter_image_sizes(State& state) { dom::parser parser; dom::element doc = parser.load(TWITTER_JSON); simdjson::error_code error; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set> image_sizes; for (dom::object tweet : doc["statuses"]) { dom::array media; @@ -539,7 +539,7 @@ static void error_code_twitter_count(State& state) noexcept { simdjson::error_code error; dom::element doc; if ((error = parser.load(TWITTER_JSON).get(doc))) { return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { uint64_t value; if ((error = doc["search_metadata"]["count"].get(value))) { return; } if (value != 100) { return; } @@ -553,7 +553,7 @@ static void error_code_twitter_default_profile(State& state) noexcept { simdjson::error_code error; dom::element doc; if ((error = parser.load(TWITTER_JSON).get(doc))) { std::cerr << error << std::endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set default_users; dom::array tweets; @@ -583,7 +583,7 @@ static void iterator_twitter_default_profile(State& state) { auto error = padded_string::load(TWITTER_JSON).get(json); if (error) { std::cerr << error << std::endl; return; } ParsedJson pj = build_parsed_json(json); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set default_users; ParsedJson::Iterator iter(pj); @@ -624,7 +624,7 @@ static void error_code_twitter_image_sizes(State& state) noexcept { simdjson::error_code error; dom::element doc; if ((error = parser.load(TWITTER_JSON).get(doc))) { std::cerr << error << std::endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set> image_sizes; dom::array statuses; if ((error = doc["statuses"].get(statuses))) { return; } @@ -656,7 +656,7 @@ static void iterator_twitter_image_sizes(State& state) { auto error = padded_string::load(TWITTER_JSON).get(json); if (error) { std::cerr << error << std::endl; return; } ParsedJson pj = build_parsed_json(json); - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { set> image_sizes; ParsedJson::Iterator iter(pj); @@ -721,7 +721,7 @@ static void print_json(State& state) noexcept { int code = json_parse(json, parser); if (code) { cerr << error_message(code) << endl; return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { std::stringstream s; if (!parser.print_json(s)) { cerr << "print_json failed" << endl; return; } } diff --git a/benchmark/bench_parse_call.cpp b/benchmark/bench_parse_call.cpp index 6edcb02b5..3b999152e 100644 --- a/benchmark/bench_parse_call.cpp +++ b/benchmark/bench_parse_call.cpp @@ -25,7 +25,7 @@ static void unicode_validate_twitter(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { bool is_ok = simdjson::validate_utf8(docdata.data(), docdata.size()); bytes += docdata.size(); benchmark::DoNotOptimize(is_ok); @@ -55,7 +55,7 @@ static void parse_twitter(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { dom::element doc; bytes += docdata.size(); if ((error = parser.parse(docdata).get(doc))) { @@ -90,7 +90,7 @@ static void parse_gsoc(State& state) { return; } size_t bytes = 0; - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { bytes += docdata.size(); dom::element doc; if ((error = parser.parse(docdata).get(doc))) { @@ -116,7 +116,7 @@ SIMDJSON_DISABLE_DEPRECATED_WARNING static void json_parse(State& state) { ParsedJson pj; if (!pj.allocate_capacity(EMPTY_ARRAY.length())) { return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { auto error = json_parse(EMPTY_ARRAY, pj); if (error) { return; } } @@ -126,7 +126,7 @@ BENCHMARK(json_parse); static void parser_parse_error_code(State& state) { dom::parser parser; if (parser.allocate(EMPTY_ARRAY.length())) { return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { auto error = parser.parse(EMPTY_ARRAY).error(); if (error) { return; } } @@ -138,9 +138,9 @@ BENCHMARK(parser_parse_error_code); static void parser_parse_exception(State& state) { dom::parser parser; if (parser.allocate(EMPTY_ARRAY.length())) { return; } - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { try { - SIMDJSON_UNUSED dom::element doc = parser.parse(EMPTY_ARRAY); + simdjson_unused dom::element doc = parser.parse(EMPTY_ARRAY); } catch(simdjson_error &j) { cout << j.what() << endl; return; @@ -154,7 +154,7 @@ BENCHMARK(parser_parse_exception); SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_DEPRECATED_WARNING static void build_parsed_json(State& state) { - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { dom::parser parser = simdjson::build_parsed_json(EMPTY_ARRAY); if (!parser.valid) { return; } } @@ -163,7 +163,7 @@ SIMDJSON_POP_DISABLE_WARNINGS BENCHMARK(build_parsed_json); static void document_parse_error_code(State& state) { - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { dom::parser parser; auto error = parser.parse(EMPTY_ARRAY).error(); if (error) { return; } @@ -174,10 +174,10 @@ BENCHMARK(document_parse_error_code); #if SIMDJSON_EXCEPTIONS static void document_parse_exception(State& state) { - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { try { dom::parser parser; - SIMDJSON_UNUSED dom::element doc = parser.parse(EMPTY_ARRAY); + simdjson_unused dom::element doc = parser.parse(EMPTY_ARRAY); } catch(simdjson_error &j) { cout << j.what() << endl; return; diff --git a/benchmark/distinctuseridcompetition.cpp b/benchmark/distinctuseridcompetition.cpp index a319385ff..4d0f54e76 100644 --- a/benchmark/distinctuseridcompetition.cpp +++ b/benchmark/distinctuseridcompetition.cpp @@ -98,7 +98,7 @@ void simdjson_recurse(std::vector & v, simdjson::dom::object object) { } } simdjson_really_inline void simdjson_recurse(std::vector & v, simdjson::dom::element element) { - SIMDJSON_UNUSED simdjson::error_code error; + simdjson_unused simdjson::error_code error; simdjson::dom::array array; simdjson::dom::object object; if (not (error = element.get(array))) { diff --git a/benchmark/event_counter.h b/benchmark/event_counter.h index bd626c842..583b19d71 100644 --- a/benchmark/event_counter.h +++ b/benchmark/event_counter.h @@ -127,7 +127,7 @@ struct event_collector { return linux_events.is_working(); } #else - event_collector(SIMDJSON_UNUSED bool _quiet = false) {} + event_collector(simdjson_unused bool _quiet = false) {} bool has_events() { return false; } diff --git a/benchmark/json_benchmark.h b/benchmark/json_benchmark.h index 4c7ad6a09..3bb282e1d 100644 --- a/benchmark/json_benchmark.h +++ b/benchmark/json_benchmark.h @@ -14,7 +14,7 @@ template static void JsonBenchmark(benchmark::State &sta } // Run the benchmark - for (SIMDJSON_UNUSED auto _ : state) { + for (simdjson_unused auto _ : state) { collector.start(); if (!bench.Run(json)) { state.SkipWithError("tweet reading failed"); return; } diff --git a/benchmark/kostya/kostya.h b/benchmark/kostya/kostya.h index 1f9442e98..4bad40593 100644 --- a/benchmark/kostya/kostya.h +++ b/benchmark/kostya/kostya.h @@ -64,7 +64,7 @@ struct my_point { simdjson_really_inline bool operator!=(const my_point &other) const { return !(*this == other); } }; -SIMDJSON_UNUSED static std::ostream &operator<<(std::ostream &o, const my_point &p) { +simdjson_unused static std::ostream &operator<<(std::ostream &o, const my_point &p) { return o << p.x << "," << p.y << "," << p.z << std::endl; } diff --git a/benchmark/largerandom/largerandom.h b/benchmark/largerandom/largerandom.h index 719b939f1..f7b18c1fa 100644 --- a/benchmark/largerandom/largerandom.h +++ b/benchmark/largerandom/largerandom.h @@ -48,7 +48,7 @@ struct my_point { simdjson_really_inline bool operator!=(const my_point &other) const { return !(*this == other); } }; -SIMDJSON_UNUSED static std::ostream &operator<<(std::ostream &o, const my_point &p) { +simdjson_unused static std::ostream &operator<<(std::ostream &o, const my_point &p) { return o << p.x << "," << p.y << "," << p.z << std::endl; } diff --git a/benchmark/parsingcompetition.cpp b/benchmark/parsingcompetition.cpp index 7e316fc8b..de11a4971 100644 --- a/benchmark/parsingcompetition.cpp +++ b/benchmark/parsingcompetition.cpp @@ -56,7 +56,7 @@ using namespace rapidjson; #ifdef ALLPARSER // fastjson has a tricky interface -void on_json_error(void *, SIMDJSON_UNUSED const fastjson::ErrorContext &ec) { +void on_json_error(void *, simdjson_unused const fastjson::ErrorContext &ec) { // std::cerr<<"ERROR: "< extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { simdjson::dom::parser parser; - SIMDJSON_UNUSED simdjson::dom::element elem; - SIMDJSON_UNUSED auto error = parser.parse(Data, Size).get(elem); + simdjson_unused simdjson::dom::element elem; + simdjson_unused auto error = parser.parse(Data, Size).get(elem); return 0; } diff --git a/include/simdjson/arm64/implementation.h b/include/simdjson/arm64/implementation.h index 67fafcd22..2e498ff49 100644 --- a/include/simdjson/arm64/implementation.h +++ b/include/simdjson/arm64/implementation.h @@ -15,13 +15,13 @@ using namespace simdjson::dom; class implementation final : public simdjson::implementation { public: simdjson_really_inline implementation() : simdjson::implementation("arm64", "ARM NEON", internal::instruction_set::NEON) {} - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, size_t max_length, std::unique_ptr& dst ) const noexcept final; - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; - SIMDJSON_WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final; + simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; + simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; }; } // namespace arm64 diff --git a/include/simdjson/common_defs.h b/include/simdjson/common_defs.h index dd76bd2ea..d50bde062 100644 --- a/include/simdjson/common_defs.h +++ b/include/simdjson/common_defs.h @@ -73,8 +73,8 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024; #define simdjson_really_inline __forceinline #define simdjson_never_inline __declspec(noinline) - #define SIMDJSON_UNUSED - #define SIMDJSON_WARN_UNUSED + #define simdjson_unused + #define simdjson_warn_unused #ifndef simdjson_likely #define simdjson_likely(x) x @@ -107,8 +107,8 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024; #define simdjson_really_inline inline __attribute__((always_inline)) #define simdjson_never_inline inline __attribute__((noinline)) - #define SIMDJSON_UNUSED __attribute__((unused)) - #define SIMDJSON_WARN_UNUSED __attribute__((warn_unused_result)) + #define simdjson_unused __attribute__((unused)) + #define simdjson_warn_unused __attribute__((warn_unused_result)) #ifndef simdjson_likely #define simdjson_likely(x) __builtin_expect(!!(x), 1) diff --git a/include/simdjson/dom/document-inl.h b/include/simdjson/dom/document-inl.h index 0725ce823..009492307 100644 --- a/include/simdjson/dom/document-inl.h +++ b/include/simdjson/dom/document-inl.h @@ -20,7 +20,7 @@ inline element document::root() const noexcept { return element(internal::tape_ref(this, 1)); } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused inline error_code document::allocate(size_t capacity) noexcept { if (capacity == 0) { string_buf.reset(); diff --git a/include/simdjson/dom/element-inl.h b/include/simdjson/dom/element-inl.h index 6793558e2..485b0e86f 100644 --- a/include/simdjson/dom/element-inl.h +++ b/include/simdjson/dom/element-inl.h @@ -33,7 +33,7 @@ simdjson_really_inline simdjson_result simdjson_result::get() c return first.get(); } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code simdjson_result::get(T &value) const noexcept { +simdjson_warn_unused simdjson_really_inline error_code simdjson_result::get(T &value) const noexcept { if (error()) { return error(); } return first.get(value); } @@ -285,12 +285,12 @@ inline simdjson_result element::get_object() const noexcept { } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code element::get(T &value) const noexcept { +simdjson_warn_unused simdjson_really_inline error_code element::get(T &value) const noexcept { return get().get(value); } // An element-specific version prevents recursion with simdjson_result::get(value) template<> -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code element::get(element &value) const noexcept { +simdjson_warn_unused simdjson_really_inline error_code element::get(element &value) const noexcept { value = element(tape); return SUCCESS; } diff --git a/include/simdjson/dom/element.h b/include/simdjson/dom/element.h index a54288e4e..c7dd024ac 100644 --- a/include/simdjson/dom/element.h +++ b/include/simdjson/dom/element.h @@ -246,7 +246,7 @@ public: * @returns The error that occurred, or SUCCESS if there was no error. */ template - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code get(T &value) const noexcept; + simdjson_warn_unused simdjson_really_inline error_code get(T &value) const noexcept; /** * Get the value as the provided type (T), setting error if it's not the given type. @@ -495,7 +495,7 @@ public: template simdjson_really_inline simdjson_result get() const noexcept; template - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code get(T &value) const noexcept; + simdjson_warn_unused simdjson_really_inline error_code get(T &value) const noexcept; simdjson_really_inline simdjson_result get_array() const noexcept; simdjson_really_inline simdjson_result get_object() const noexcept; diff --git a/include/simdjson/dom/jsonparser.h b/include/simdjson/dom/jsonparser.h index 3da37c071..bc8ccdea3 100644 --- a/include/simdjson/dom/jsonparser.h +++ b/include/simdjson/dom/jsonparser.h @@ -59,7 +59,7 @@ inline int json_parse(const padded_string &s, dom::parser &parser) noexcept { } [[deprecated("Use parser.parse() instead")]] -SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const uint8_t *buf, size_t len, bool realloc_if_needed = true) noexcept { +simdjson_warn_unused inline dom::parser build_parsed_json(const uint8_t *buf, size_t len, bool realloc_if_needed = true) noexcept { dom::parser parser; error_code code = parser.parse(buf, len, realloc_if_needed).error(); // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid @@ -71,7 +71,7 @@ SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const uint8_t *buf, si return parser; } [[deprecated("Use parser.parse() instead")]] -SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const char *buf, size_t len, bool realloc_if_needed = true) noexcept { +simdjson_warn_unused inline dom::parser build_parsed_json(const char *buf, size_t len, bool realloc_if_needed = true) noexcept { dom::parser parser; error_code code = parser.parse(buf, len, realloc_if_needed).error(); // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid @@ -83,7 +83,7 @@ SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const char *buf, size_ return parser; } [[deprecated("Use parser.parse() instead")]] -SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const std::string &s, bool realloc_if_needed = true) noexcept { +simdjson_warn_unused inline dom::parser build_parsed_json(const std::string &s, bool realloc_if_needed = true) noexcept { dom::parser parser; error_code code = parser.parse(s.data(), s.length(), realloc_if_needed).error(); // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid @@ -95,7 +95,7 @@ SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const std::string &s, return parser; } [[deprecated("Use parser.parse() instead")]] -SIMDJSON_WARN_UNUSED inline dom::parser build_parsed_json(const padded_string &s) noexcept { +simdjson_warn_unused inline dom::parser build_parsed_json(const padded_string &s) noexcept { dom::parser parser; error_code code = parser.parse(s).error(); // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid diff --git a/include/simdjson/dom/parsedjson_iterator-inl.h b/include/simdjson/dom/parsedjson_iterator-inl.h index 5133c9768..350b8c7dd 100644 --- a/include/simdjson/dom/parsedjson_iterator-inl.h +++ b/include/simdjson/dom/parsedjson_iterator-inl.h @@ -13,7 +13,7 @@ SIMDJSON_DISABLE_DEPRECATED_WARNING // Because of template weirdness, the actual class definition is inline in the document class -SIMDJSON_WARN_UNUSED bool dom::parser::Iterator::is_ok() const { +simdjson_warn_unused bool dom::parser::Iterator::is_ok() const { return location < tape_length; } diff --git a/include/simdjson/dom/parser-inl.h b/include/simdjson/dom/parser-inl.h index 480fb14e1..ee2ea6988 100644 --- a/include/simdjson/dom/parser-inl.h +++ b/include/simdjson/dom/parser-inl.h @@ -134,7 +134,7 @@ simdjson_really_inline size_t parser::max_depth() const noexcept { return implementation ? implementation->max_depth() : DEFAULT_MAX_DEPTH; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused inline error_code parser::allocate(size_t capacity, size_t max_depth) noexcept { // // Reallocate implementation and document if needed @@ -160,7 +160,7 @@ inline error_code parser::allocate(size_t capacity, size_t max_depth) noexcept { return SUCCESS; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused inline bool parser::allocate_capacity(size_t capacity, size_t max_depth) noexcept { return !allocate(capacity, max_depth); } diff --git a/include/simdjson/dom/parser.h b/include/simdjson/dom/parser.h index b4184f07f..50f4f13ec 100644 --- a/include/simdjson/dom/parser.h +++ b/include/simdjson/dom/parser.h @@ -355,7 +355,7 @@ public: * @param max_depth The new max_depth. Defaults to DEFAULT_MAX_DEPTH. * @return The error, if there is one. */ - SIMDJSON_WARN_UNUSED inline error_code allocate(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept; + simdjson_warn_unused inline error_code allocate(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept; /** * @private deprecated because it returns bool instead of error_code, which is our standard for @@ -369,7 +369,7 @@ public: * @return true if successful, false if allocation failed. */ [[deprecated("Use allocate() instead.")]] - SIMDJSON_WARN_UNUSED inline bool allocate_capacity(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept; + simdjson_warn_unused inline bool allocate_capacity(size_t capacity, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept; /** * The largest document this parser can support without reallocating. diff --git a/include/simdjson/error-inl.h b/include/simdjson/error-inl.h index 39b9b8bed..ae40fe519 100644 --- a/include/simdjson/error-inl.h +++ b/include/simdjson/error-inl.h @@ -53,7 +53,7 @@ simdjson_really_inline void simdjson_result_base::tie(T &value, error_code &e } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code simdjson_result_base::get(T &value) && noexcept { +simdjson_warn_unused simdjson_really_inline error_code simdjson_result_base::get(T &value) && noexcept { error_code error; std::forward>(*this).tie(value, error); return error; @@ -115,7 +115,7 @@ simdjson_really_inline void simdjson_result::tie(T &value, error_code &error) } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code simdjson_result::get(T &value) && noexcept { +simdjson_warn_unused simdjson_really_inline error_code simdjson_result::get(T &value) && noexcept { return std::forward>(*this).get(value); } diff --git a/include/simdjson/error.h b/include/simdjson/error.h index 0d7ae1676..8d6341f07 100644 --- a/include/simdjson/error.h +++ b/include/simdjson/error.h @@ -211,7 +211,7 @@ struct simdjson_result : public internal::simdjson_result_base { * * @param value The variable to assign the value to. May not be set if there is an error. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code get(T &value) && noexcept; + simdjson_warn_unused simdjson_really_inline error_code get(T &value) && noexcept; /** * The error. diff --git a/include/simdjson/fallback/implementation.h b/include/simdjson/fallback/implementation.h index b7c6ecfec..5d4ea8548 100644 --- a/include/simdjson/fallback/implementation.h +++ b/include/simdjson/fallback/implementation.h @@ -18,13 +18,13 @@ public: "Generic fallback implementation", 0 ) {} - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, size_t max_length, std::unique_ptr& dst ) const noexcept final; - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; - SIMDJSON_WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final; + simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; + simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; }; } // namespace fallback diff --git a/include/simdjson/generic/atomparsing.h b/include/simdjson/generic/atomparsing.h index 5655a8fe2..f9e50ff2e 100644 --- a/include/simdjson/generic/atomparsing.h +++ b/include/simdjson/generic/atomparsing.h @@ -15,7 +15,7 @@ simdjson_really_inline uint32_t string_to_uint32(const char* str) { uint32_t val // Again in str4ncmp we use a memcpy to avoid undefined behavior. The memcpy may appear expensive. // Yet all decent optimizing compilers will compile memcpy to a single instruction, just about. -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline uint32_t str4ncmp(const uint8_t *src, const char* atom) { uint32_t srcval; // we want to avoid unaligned 32-bit loads (undefined in C/C++) static_assert(sizeof(uint32_t) <= SIMDJSON_PADDING, "SIMDJSON_PADDING must be larger than 4 bytes"); @@ -23,36 +23,36 @@ simdjson_really_inline uint32_t str4ncmp(const uint8_t *src, const char* atom) { return srcval ^ string_to_uint32(atom); } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_true_atom(const uint8_t *src) { return (str4ncmp(src, "true") | jsoncharutils::is_not_structural_or_whitespace(src[4])) == 0; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_true_atom(const uint8_t *src, size_t len) { if (len > 4) { return is_valid_true_atom(src); } else if (len == 4) { return !str4ncmp(src, "true"); } else { return false; } } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_false_atom(const uint8_t *src) { return (str4ncmp(src+1, "alse") | jsoncharutils::is_not_structural_or_whitespace(src[5])) == 0; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_false_atom(const uint8_t *src, size_t len) { if (len > 5) { return is_valid_false_atom(src); } else if (len == 5) { return !str4ncmp(src+1, "alse"); } else { return false; } } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_null_atom(const uint8_t *src) { return (str4ncmp(src, "null") | jsoncharutils::is_not_structural_or_whitespace(src[4])) == 0; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool is_valid_null_atom(const uint8_t *src, size_t len) { if (len > 4) { return is_valid_null_atom(src); } else if (len == 4) { return !str4ncmp(src, "null"); } diff --git a/include/simdjson/generic/dom_parser_implementation.h b/include/simdjson/generic/dom_parser_implementation.h index b42738dc5..e2006b15a 100644 --- a/include/simdjson/generic/dom_parser_implementation.h +++ b/include/simdjson/generic/dom_parser_implementation.h @@ -31,15 +31,15 @@ public: dom_parser_implementation(const dom_parser_implementation &) = delete; dom_parser_implementation &operator=(const dom_parser_implementation &) = delete; - SIMDJSON_WARN_UNUSED error_code parse(const uint8_t *buf, size_t len, dom::document &doc) noexcept final; - SIMDJSON_WARN_UNUSED error_code stage1(const uint8_t *buf, size_t len, bool partial) noexcept final; - SIMDJSON_WARN_UNUSED error_code check_for_unclosed_array() noexcept; - SIMDJSON_WARN_UNUSED error_code stage2(dom::document &doc) noexcept final; - SIMDJSON_WARN_UNUSED error_code stage2_next(dom::document &doc) noexcept final; - inline SIMDJSON_WARN_UNUSED error_code set_capacity(size_t capacity) noexcept final; - inline SIMDJSON_WARN_UNUSED error_code set_max_depth(size_t max_depth) noexcept final; + simdjson_warn_unused error_code parse(const uint8_t *buf, size_t len, dom::document &doc) noexcept final; + simdjson_warn_unused error_code stage1(const uint8_t *buf, size_t len, bool partial) noexcept final; + simdjson_warn_unused error_code check_for_unclosed_array() noexcept; + simdjson_warn_unused error_code stage2(dom::document &doc) noexcept final; + simdjson_warn_unused error_code stage2_next(dom::document &doc) noexcept final; + inline simdjson_warn_unused error_code set_capacity(size_t capacity) noexcept final; + inline simdjson_warn_unused error_code set_max_depth(size_t max_depth) noexcept final; private: - simdjson_really_inline SIMDJSON_WARN_UNUSED error_code set_capacity_stage1(size_t capacity); + simdjson_really_inline simdjson_warn_unused error_code set_capacity_stage1(size_t capacity); }; @@ -54,7 +54,7 @@ inline dom_parser_implementation::dom_parser_implementation(dom_parser_implement inline dom_parser_implementation &dom_parser_implementation::operator=(dom_parser_implementation &&other) noexcept = default; // Leaving these here so they can be inlined if so desired -inline SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::set_capacity(size_t capacity) noexcept { +inline simdjson_warn_unused error_code dom_parser_implementation::set_capacity(size_t capacity) noexcept { // Stage 1 index output size_t max_structures = SIMDJSON_ROUNDUP_N(capacity, 64) + 2 + 7; structural_indexes.reset( new (std::nothrow) uint32_t[max_structures] ); @@ -66,7 +66,7 @@ inline SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::set_capacity(s return SUCCESS; } -inline SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::set_max_depth(size_t max_depth) noexcept { +inline simdjson_warn_unused error_code dom_parser_implementation::set_max_depth(size_t max_depth) noexcept { // Stage 2 stacks open_containers.reset(new (std::nothrow) open_container[max_depth]); is_array.reset(new (std::nothrow) bool[max_depth]); diff --git a/include/simdjson/generic/implementation_simdjson_result_base-inl.h b/include/simdjson/generic/implementation_simdjson_result_base-inl.h index 36a9e63e8..7e93645ad 100644 --- a/include/simdjson/generic/implementation_simdjson_result_base-inl.h +++ b/include/simdjson/generic/implementation_simdjson_result_base-inl.h @@ -24,7 +24,7 @@ simdjson_really_inline void implementation_simdjson_result_base::tie(T &value } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code implementation_simdjson_result_base::get(T &value) && noexcept { +simdjson_warn_unused simdjson_really_inline error_code implementation_simdjson_result_base::get(T &value) && noexcept { error_code error; std::forward>(*this).tie(value, error); return error; diff --git a/include/simdjson/generic/numberparsing.h b/include/simdjson/generic/numberparsing.h index 28507c65b..bb150e6b5 100644 --- a/include/simdjson/generic/numberparsing.h +++ b/include/simdjson/generic/numberparsing.h @@ -318,7 +318,7 @@ simdjson_really_inline bool is_made_of_eight_digits_fast(const uint8_t *chars) { } template -error_code slow_float_parsing(SIMDJSON_UNUSED const uint8_t * src, W writer) { +error_code slow_float_parsing(simdjson_unused const uint8_t * src, W writer) { double d; if (parse_float_fallback(src, &d)) { writer.append_double(d); @@ -339,7 +339,7 @@ simdjson_really_inline bool parse_digit(const uint8_t c, I &i) { return true; } -simdjson_really_inline error_code parse_decimal(SIMDJSON_UNUSED const uint8_t *const src, const uint8_t *&p, uint64_t &i, int64_t &exponent) { +simdjson_really_inline error_code parse_decimal(simdjson_unused const uint8_t *const src, const uint8_t *&p, uint64_t &i, int64_t &exponent) { // we continue with the fiction that we have an integer. If the // floating point number is representable as x * 10^z for some integer // z that fits in 53 bits, then we will be able to convert back the @@ -365,7 +365,7 @@ simdjson_really_inline error_code parse_decimal(SIMDJSON_UNUSED const uint8_t *c return SUCCESS; } -simdjson_really_inline error_code parse_exponent(SIMDJSON_UNUSED const uint8_t *const src, const uint8_t *&p, int64_t &exponent) { +simdjson_really_inline error_code parse_exponent(simdjson_unused const uint8_t *const src, const uint8_t *&p, int64_t &exponent) { // Exp Sign: -123.456e[-]78 bool neg_exp = ('-' == *p); if (neg_exp || '+' == *p) { p++; } // Skip + as well @@ -489,9 +489,9 @@ simdjson_really_inline error_code parse_number(const uint8_t *const, W &writer) return SUCCESS; // always succeeds } -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_unsigned(const uint8_t * const src) noexcept { return 0; } -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_integer(const uint8_t * const src) noexcept { return 0; } -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_double(const uint8_t * const src) noexcept { return 0; } +simdjson_unused simdjson_really_inline simdjson_result parse_unsigned(const uint8_t * const src) noexcept { return 0; } +simdjson_unused simdjson_really_inline simdjson_result parse_integer(const uint8_t * const src) noexcept { return 0; } +simdjson_unused simdjson_really_inline simdjson_result parse_double(const uint8_t * const src) noexcept { return 0; } #else @@ -588,7 +588,7 @@ simdjson_really_inline error_code parse_number(const uint8_t *const src, W &writ // SAX functions namespace { // Parse any number from 0 to 18,446,744,073,709,551,615 -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_unsigned(const uint8_t * const src) noexcept { +simdjson_unused simdjson_really_inline simdjson_result parse_unsigned(const uint8_t * const src) noexcept { const uint8_t *p = src; // @@ -628,7 +628,7 @@ SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_unsigned( // Parse any number from 0 to 18,446,744,073,709,551,615 // Call this version of the method if you regularly expect 8- or 16-digit numbers. -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_large_unsigned(const uint8_t * const src) noexcept { +simdjson_unused simdjson_really_inline simdjson_result parse_large_unsigned(const uint8_t * const src) noexcept { const uint8_t *p = src; // @@ -682,7 +682,7 @@ SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_large_uns } // Parse any number from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_integer(const uint8_t *src) noexcept { +simdjson_unused simdjson_really_inline simdjson_result parse_integer(const uint8_t *src) noexcept { // // Check for minus sign // @@ -731,7 +731,7 @@ SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_integer(co return negative ? (~i+1) : i; } -SIMDJSON_UNUSED simdjson_really_inline simdjson_result parse_double(const uint8_t * src) noexcept { +simdjson_unused simdjson_really_inline simdjson_result parse_double(const uint8_t * src) noexcept { // // Check for minus sign // diff --git a/include/simdjson/generic/ondemand/array-inl.h b/include/simdjson/generic/ondemand/array-inl.h index d2f630a26..c5156bdeb 100644 --- a/include/simdjson/generic/ondemand/array-inl.h +++ b/include/simdjson/generic/ondemand/array-inl.h @@ -48,7 +48,7 @@ simdjson_really_inline array::array(json_iterator_ref &&_iter) noexcept simdjson_really_inline array::~array() noexcept { if (iter.is_alive()) { logger::log_event(*iter, "unfinished", "array"); - SIMDJSON_UNUSED auto _err = iter->skip_container(); + simdjson_unused auto _err = iter->skip_container(); iter.release(); } } diff --git a/include/simdjson/generic/ondemand/json_iterator-inl.h b/include/simdjson/generic/ondemand/json_iterator-inl.h index a10ab46e2..7f6388353 100644 --- a/include/simdjson/generic/ondemand/json_iterator-inl.h +++ b/include/simdjson/generic/ondemand/json_iterator-inl.h @@ -42,15 +42,15 @@ simdjson_really_inline json_iterator::~json_iterator() noexcept { } #endif -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::start_object(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::start_object(const uint8_t *json) noexcept { if (*json != '{') { logger::log_error(*this, "Not an object"); return INCORRECT_TYPE; } return started_object(); } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::start_object() noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::start_object() noexcept { return start_object(advance()); } -SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_object() noexcept { +simdjson_warn_unused simdjson_really_inline bool json_iterator::started_object() noexcept { if (*peek() == '}') { logger::log_value(*this, "empty object"); advance(); @@ -60,7 +60,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_object() return true; } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::has_next_field() noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::has_next_field() noexcept { switch (*advance()) { case '}': logger::log_end_value(*this, "object"); @@ -72,7 +72,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator: } } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::find_field_raw(const char *key) noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::find_field_raw(const char *key) noexcept { bool has_next; do { raw_json_string actual_key; @@ -91,27 +91,27 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator: return false; } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::field_key() noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::field_key() noexcept { const uint8_t *key = advance(); if (*(key++) != '"') { return report_error(TAPE_ERROR, "Object key is not a string"); } return raw_json_string(key); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::field_value() noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::field_value() noexcept { if (*advance() != ':') { return report_error(TAPE_ERROR, "Missing colon in object field"); } return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::start_array(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::start_array(const uint8_t *json) noexcept { if (*json != '[') { logger::log_error(*this, "Not an array"); return INCORRECT_TYPE; } return started_array(); } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::start_array() noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::start_array() noexcept { return start_array(advance()); } -SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_array() noexcept { +simdjson_warn_unused simdjson_really_inline bool json_iterator::started_array() noexcept { if (*peek() == ']') { logger::log_value(*this, "empty array"); advance(); @@ -121,7 +121,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::started_array() return true; } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator::has_next_element() noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result json_iterator::has_next_element() noexcept { switch (*advance()) { case ']': logger::log_end_value(*this, "array"); @@ -133,42 +133,42 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result json_iterator: } } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_string(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_string(const uint8_t *json) noexcept { return parse_raw_json_string(json).unescape(current_string_buf_loc); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_string() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_string() noexcept { return parse_string(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_raw_json_string(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_raw_json_string(const uint8_t *json) noexcept { logger::log_value(*this, "string", ""); if (*json != '"') { logger::log_error(*this, "Not a string"); return INCORRECT_TYPE; } return raw_json_string(json+1); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_raw_json_string() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_raw_json_string() noexcept { return parse_raw_json_string(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_uint64(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_uint64(const uint8_t *json) noexcept { logger::log_value(*this, "uint64", ""); return numberparsing::parse_unsigned(json); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_uint64() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_uint64() noexcept { return parse_uint64(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_int64(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_int64(const uint8_t *json) noexcept { logger::log_value(*this, "int64", ""); return numberparsing::parse_integer(json); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_int64() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_int64() noexcept { return parse_int64(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_double(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_double(const uint8_t *json) noexcept { logger::log_value(*this, "double", ""); return numberparsing::parse_double(json); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_double() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_double() noexcept { return parse_double(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_bool(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_bool(const uint8_t *json) noexcept { logger::log_value(*this, "bool", ""); auto not_true = atomparsing::str4ncmp(json, "true"); auto not_false = atomparsing::str4ncmp(json, "fals") | (json[4] ^ 'e'); @@ -176,7 +176,7 @@ SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_bool(const uint8 if (error) { logger::log_error(*this, "Not a boolean"); return INCORRECT_TYPE; } return simdjson_result(!not_true); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_bool() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_bool() noexcept { return parse_bool(advance()); } simdjson_really_inline bool json_iterator::is_null(const uint8_t *json) noexcept { @@ -195,7 +195,7 @@ simdjson_really_inline bool json_iterator::is_null() noexcept { } template -SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::copy_to_buffer(const uint8_t *json, uint8_t (&tmpbuf)[N]) noexcept { +simdjson_warn_unused simdjson_really_inline bool json_iterator::copy_to_buffer(const uint8_t *json, uint8_t (&tmpbuf)[N]) noexcept { // Truncate whitespace to fit the buffer. auto len = peek_length(-1); if (len > N-1) { @@ -211,7 +211,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline bool json_iterator::copy_to_buffer(c constexpr const uint32_t MAX_INT_LENGTH = 1024; -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_uint64(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_root_uint64(const uint8_t *json) noexcept { uint8_t tmpbuf[20+1]; // <20 digits> is the longest possible unsigned integer if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 20 characters"); return NUMBER_ERROR; } logger::log_value(*this, "uint64", ""); @@ -219,10 +219,10 @@ SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_uint64( if (result.error()) { logger::log_error(*this, "Error parsing unsigned integer"); return result.error(); } return result; } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_root_uint64() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_root_uint64() noexcept { return parse_root_uint64(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_int64(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_root_int64(const uint8_t *json) noexcept { uint8_t tmpbuf[20+1]; // -<19 digits> is the longest possible integer if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 20 characters"); return NUMBER_ERROR; } logger::log_value(*this, "int64", ""); @@ -230,10 +230,10 @@ SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_int64(co if (result.error()) { report_error(result.error(), "Error parsing integer"); } return result; } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_root_int64() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_root_int64() noexcept { return parse_root_int64(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_double(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_root_double(const uint8_t *json) noexcept { // Per https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/, 1074 is the maximum number of significant fractional digits. Add 8 more digits for the biggest number: -0.e-308. uint8_t tmpbuf[1074+8+1]; if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Root number more than 1082 characters"); return NUMBER_ERROR; } @@ -242,15 +242,15 @@ SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_double(co if (result.error()) { report_error(result.error(), "Error parsing double"); } return result; } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_root_double() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_root_double() noexcept { return parse_root_double(advance()); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::parse_root_bool(const uint8_t *json) noexcept { +simdjson_warn_unused simdjson_result json_iterator::parse_root_bool(const uint8_t *json) noexcept { uint8_t tmpbuf[5+1]; if (!copy_to_buffer(json, tmpbuf)) { logger::log_error(*this, "Not a boolean"); return INCORRECT_TYPE; } return parse_bool(tmpbuf); } -SIMDJSON_WARN_UNUSED simdjson_result json_iterator::consume_root_bool() noexcept { +simdjson_warn_unused simdjson_result json_iterator::consume_root_bool() noexcept { return parse_root_bool(advance()); } simdjson_really_inline bool json_iterator::root_is_null(const uint8_t *json) noexcept { @@ -259,7 +259,7 @@ simdjson_really_inline bool json_iterator::root_is_null(const uint8_t *json) noe return is_null(tmpbuf); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::skip() noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip() noexcept { switch (*advance()) { // PERF TODO does it skip the depth check when we don't decrement depth? case '[': case '{': @@ -271,7 +271,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::skip() noe } } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::skip_container() noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::skip_container() noexcept { uint32_t depth = 1; // The loop breaks only when depth-- happens. auto end = &parser->dom_parser.structural_indexes[parser->dom_parser.n_structural_indexes]; diff --git a/include/simdjson/generic/ondemand/json_iterator.h b/include/simdjson/generic/ondemand/json_iterator.h index c2078b688..f4b726a39 100644 --- a/include/simdjson/generic/ondemand/json_iterator.h +++ b/include/simdjson/generic/ondemand/json_iterator.h @@ -35,14 +35,14 @@ public: * @returns Whether the object had any fields (returns false for empty). * @error INCORRECT_TYPE if there is no opening { */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result start_object(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result start_object(const uint8_t *json) noexcept; /** * Check for an opening { and start an object iteration. * * @returns Whether the object had any fields (returns false for empty). * @error INCORRECT_TYPE if there is no opening { */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result start_object() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result start_object() noexcept; /** * Start an object iteration after the user has already checked and moved past the {. @@ -51,7 +51,7 @@ public: * * @returns Whether the object had any fields (returns false for empty). */ - SIMDJSON_WARN_UNUSED simdjson_really_inline bool started_object() noexcept; + simdjson_warn_unused simdjson_really_inline bool started_object() noexcept; /** * Moves to the next field in an object. @@ -62,17 +62,17 @@ public: * @return whether there is another field in the object. * @error TAPE_ERROR If there is a comma missing between fields. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result has_next_field() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result has_next_field() noexcept; /** * Get the current field's key. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result field_key() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result field_key() noexcept; /** * Pass the : in the field and move to its value. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code field_value() noexcept; + simdjson_warn_unused simdjson_really_inline error_code field_value() noexcept; /** * Find the next field with the given key. @@ -83,7 +83,7 @@ public: * unescape it. This works well for typical ASCII and UTF-8 keys (almost all of them), but may * fail to match some keys with escapes (\u, \n, etc.). */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result find_field_raw(const char *key) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result find_field_raw(const char *key) noexcept; /** * Check for an opening [ and start an array iteration. @@ -92,14 +92,14 @@ public: * @returns Whether the array had any elements (returns false for empty). * @error INCORRECT_TYPE If there is no [. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result start_array(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result start_array(const uint8_t *json) noexcept; /** * Check for an opening [ and start an array iteration. * * @returns Whether the array had any elements (returns false for empty). * @error INCORRECT_TYPE If there is no [. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result start_array() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result start_array() noexcept; /** * Start an array iteration after the user has already checked and moved past the [. @@ -108,7 +108,7 @@ public: * * @returns Whether the array had any elements (returns false for empty). */ - SIMDJSON_WARN_UNUSED simdjson_really_inline bool started_array() noexcept; + simdjson_warn_unused simdjson_really_inline bool started_array() noexcept; /** * Moves to the next element in an array. @@ -119,45 +119,45 @@ public: * @return Whether there is another element in the array. * @error TAPE_ERROR If there is a comma missing between elements. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result has_next_element() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result has_next_element() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_string(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_string() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_raw_json_string(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_raw_json_string() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_uint64(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_uint64() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_int64(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_int64() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_double(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_double() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_bool(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_bool() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_string(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_string() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_raw_json_string(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_raw_json_string() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_uint64(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_uint64() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_int64(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_int64() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_double(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_double() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_bool(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_bool() noexcept; simdjson_really_inline bool is_null(const uint8_t *json) noexcept; simdjson_really_inline bool is_null() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_root_uint64(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_root_uint64() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_root_int64(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_root_int64() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_root_double(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_root_double() noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parse_root_bool(const uint8_t *json) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result consume_root_bool() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_root_uint64(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_root_uint64() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_root_int64(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_root_int64() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_root_double(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_root_double() noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result parse_root_bool(const uint8_t *json) noexcept; + simdjson_warn_unused simdjson_really_inline simdjson_result consume_root_bool() noexcept; simdjson_really_inline bool root_is_null(const uint8_t *json) noexcept; simdjson_really_inline bool root_is_null() noexcept; /** * Skips a JSON value, whether it is a scalar, array or object. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code skip() noexcept; + simdjson_warn_unused simdjson_really_inline error_code skip() noexcept; /** * Skips to the end of a JSON object or array. * * @return true if this was the end of an array, false if it was the end of an object. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code skip_container() noexcept; + simdjson_warn_unused simdjson_really_inline error_code skip_container() noexcept; /** * Tell whether the iterator is still at the start @@ -212,7 +212,7 @@ protected: simdjson_really_inline json_iterator(ondemand::parser *parser) noexcept; template - SIMDJSON_WARN_UNUSED simdjson_really_inline bool copy_to_buffer(const uint8_t *json, uint8_t (&buf)[N]) noexcept; + simdjson_warn_unused simdjson_really_inline bool copy_to_buffer(const uint8_t *json, uint8_t (&buf)[N]) noexcept; simdjson_really_inline json_iterator_ref borrow() noexcept; diff --git a/include/simdjson/generic/ondemand/object-inl.h b/include/simdjson/generic/ondemand/object-inl.h index a4e19f242..f7a1a2000 100644 --- a/include/simdjson/generic/ondemand/object-inl.h +++ b/include/simdjson/generic/ondemand/object-inl.h @@ -53,7 +53,7 @@ simdjson_really_inline object::object(json_iterator_ref &&_iter) noexcept simdjson_really_inline object::~object() noexcept { if (iter.is_alive()) { logger::log_event(*iter, "unfinished", "object"); - SIMDJSON_UNUSED auto _err = iter->skip_container(); + simdjson_unused auto _err = iter->skip_container(); iter.release(); } } diff --git a/include/simdjson/generic/ondemand/parser-inl.h b/include/simdjson/generic/ondemand/parser-inl.h index 84058f104..bb32597c8 100644 --- a/include/simdjson/generic/ondemand/parser-inl.h +++ b/include/simdjson/generic/ondemand/parser-inl.h @@ -2,7 +2,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace ondemand { -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code parser::allocate(size_t new_capacity, size_t new_max_depth) noexcept { +simdjson_warn_unused simdjson_really_inline error_code parser::allocate(size_t new_capacity, size_t new_max_depth) noexcept { if (string_buf && new_capacity == _capacity && new_max_depth == _max_depth) { return SUCCESS; } // string_capacity copied from document::allocate @@ -18,7 +18,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code parser::allocate(size_t n return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parser::iterate(const padded_string &buf) & noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result parser::iterate(const padded_string &buf) & noexcept { // Allocate if needed if (_capacity < buf.size() || !string_buf) { SIMDJSON_TRY( allocate(buf.size(), _max_depth) ); @@ -29,7 +29,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parser::it return document::start(this); } -SIMDJSON_WARN_UNUSED simdjson_really_inline simdjson_result parser::iterate_raw(const padded_string &buf) & noexcept { +simdjson_warn_unused simdjson_really_inline simdjson_result parser::iterate_raw(const padded_string &buf) & noexcept { // Allocate if needed if (_capacity < buf.size()) { SIMDJSON_TRY( allocate(buf.size(), _max_depth) ); diff --git a/include/simdjson/generic/ondemand/parser.h b/include/simdjson/generic/ondemand/parser.h index 2ed541be8..4cecbe351 100644 --- a/include/simdjson/generic/ondemand/parser.h +++ b/include/simdjson/generic/ondemand/parser.h @@ -62,8 +62,8 @@ public: * - UNESCAPED_CHARS if a string contains control characters that must be escaped * - UNCLOSED_STRING if there is an unclosed string in the document. */ - SIMDJSON_WARN_UNUSED simdjson_result iterate(const padded_string &json) & noexcept; - SIMDJSON_WARN_UNUSED simdjson_result iterate(const std::string &json) & noexcept = delete; + simdjson_warn_unused simdjson_result iterate(const padded_string &json) & noexcept; + simdjson_warn_unused simdjson_result iterate(const std::string &json) & noexcept = delete; /** * @private * @@ -98,7 +98,7 @@ public: * - UNESCAPED_CHARS if a string contains control characters that must be escaped * - UNCLOSED_STRING if there is an unclosed string in the document. */ - SIMDJSON_WARN_UNUSED simdjson_result iterate_raw(const padded_string &json) & noexcept; + simdjson_warn_unused simdjson_result iterate_raw(const padded_string &json) & noexcept; private: dom_parser_implementation dom_parser{}; @@ -114,7 +114,7 @@ private: * @param max_depth The new max_depth. Defaults to DEFAULT_MAX_DEPTH. * @return The error, if there is one. */ - SIMDJSON_WARN_UNUSED error_code allocate(size_t capacity, size_t max_depth=DEFAULT_MAX_DEPTH) noexcept; + simdjson_warn_unused error_code allocate(size_t capacity, size_t max_depth=DEFAULT_MAX_DEPTH) noexcept; friend class json_iterator; }; diff --git a/include/simdjson/generic/ondemand/raw_json_string-inl.h b/include/simdjson/generic/ondemand/raw_json_string-inl.h index e8392f300..e29a04ae8 100644 --- a/include/simdjson/generic/ondemand/raw_json_string-inl.h +++ b/include/simdjson/generic/ondemand/raw_json_string-inl.h @@ -5,7 +5,7 @@ namespace ondemand { simdjson_really_inline raw_json_string::raw_json_string(const uint8_t * _buf) noexcept : buf{_buf} {} simdjson_really_inline const char * raw_json_string::raw() const noexcept { return (const char *)buf; } -simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result raw_json_string::unescape(uint8_t *&dst) const noexcept { +simdjson_really_inline simdjson_warn_unused simdjson_result raw_json_string::unescape(uint8_t *&dst) const noexcept { uint8_t *end = stringparsing::parse_string(buf, dst); if (!end) { return STRING_ERROR; } std::string_view result((const char *)dst, end-dst); @@ -13,27 +13,27 @@ simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result ra return result; } -simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result raw_json_string::unescape(json_iterator &iter) const noexcept { +simdjson_really_inline simdjson_warn_unused simdjson_result raw_json_string::unescape(json_iterator &iter) const noexcept { return unescape(iter.current_string_buf_loc); } -SIMDJSON_UNUSED simdjson_really_inline bool operator==(const raw_json_string &a, std::string_view b) noexcept { +simdjson_unused simdjson_really_inline bool operator==(const raw_json_string &a, std::string_view b) noexcept { return !memcmp(a.raw(), b.data(), b.size()); } -SIMDJSON_UNUSED simdjson_really_inline bool operator==(std::string_view a, const raw_json_string &b) noexcept { +simdjson_unused simdjson_really_inline bool operator==(std::string_view a, const raw_json_string &b) noexcept { return b == a; } -SIMDJSON_UNUSED simdjson_really_inline bool operator!=(const raw_json_string &a, std::string_view b) noexcept { +simdjson_unused simdjson_really_inline bool operator!=(const raw_json_string &a, std::string_view b) noexcept { return !(a == b); } -SIMDJSON_UNUSED simdjson_really_inline bool operator!=(std::string_view a, const raw_json_string &b) noexcept { +simdjson_unused simdjson_really_inline bool operator!=(std::string_view a, const raw_json_string &b) noexcept { return !(a == b); } -SIMDJSON_UNUSED simdjson_really_inline std::ostream &operator<<(std::ostream &out, const raw_json_string &str) noexcept { +simdjson_unused simdjson_really_inline std::ostream &operator<<(std::ostream &out, const raw_json_string &str) noexcept { bool in_escape = false; const char *s = str.raw(); while (true) { @@ -62,11 +62,11 @@ simdjson_really_inline simdjson_result simdjson_result simdjson_result::unescape(uint8_t *&dst) const noexcept { +simdjson_really_inline simdjson_warn_unused simdjson_result simdjson_result::unescape(uint8_t *&dst) const noexcept { if (error()) { return error(); } return first.unescape(dst); } -simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result simdjson_result::unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept { +simdjson_really_inline simdjson_warn_unused simdjson_result simdjson_result::unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept { if (error()) { return error(); } return first.unescape(iter); } diff --git a/include/simdjson/generic/ondemand/raw_json_string.h b/include/simdjson/generic/ondemand/raw_json_string.h index 87de8aea5..be135f3ce 100644 --- a/include/simdjson/generic/ondemand/raw_json_string.h +++ b/include/simdjson/generic/ondemand/raw_json_string.h @@ -50,7 +50,7 @@ public: * @return A string_view pointing at the unescaped string in dst * @error STRING_ERROR if escapes are incorrect. */ - simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result unescape(uint8_t *&dst) const noexcept; + simdjson_really_inline simdjson_warn_unused simdjson_result unescape(uint8_t *&dst) const noexcept; /** * Unescape this JSON string, replacing \\ with \, \n with newline, etc. * @@ -60,19 +60,19 @@ public: * * @param iter A json_iterator, which contains a buffer where the string will be written. */ - simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result unescape(json_iterator &iter) const noexcept; + simdjson_really_inline simdjson_warn_unused simdjson_result unescape(json_iterator &iter) const noexcept; private: const uint8_t * buf{}; friend class object; }; -SIMDJSON_UNUSED simdjson_really_inline bool operator==(const raw_json_string &a, std::string_view b) noexcept; -SIMDJSON_UNUSED simdjson_really_inline bool operator==(std::string_view a, const raw_json_string &b) noexcept; -SIMDJSON_UNUSED simdjson_really_inline bool operator!=(const raw_json_string &a, std::string_view b) noexcept; -SIMDJSON_UNUSED simdjson_really_inline bool operator!=(std::string_view a, const raw_json_string &b) noexcept; +simdjson_unused simdjson_really_inline bool operator==(const raw_json_string &a, std::string_view b) noexcept; +simdjson_unused simdjson_really_inline bool operator==(std::string_view a, const raw_json_string &b) noexcept; +simdjson_unused simdjson_really_inline bool operator!=(const raw_json_string &a, std::string_view b) noexcept; +simdjson_unused simdjson_really_inline bool operator!=(std::string_view a, const raw_json_string &b) noexcept; -SIMDJSON_UNUSED simdjson_really_inline std::ostream &operator<<(std::ostream &, const raw_json_string &) noexcept; +simdjson_unused simdjson_really_inline std::ostream &operator<<(std::ostream &, const raw_json_string &) noexcept; } // namespace ondemand } // namespace SIMDJSON_IMPLEMENTATION @@ -91,8 +91,8 @@ public: simdjson_really_inline ~simdjson_result() noexcept = default; ///< @private simdjson_really_inline simdjson_result raw() const noexcept; - simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result unescape(uint8_t *&dst) const noexcept; - simdjson_really_inline SIMDJSON_WARN_UNUSED simdjson_result unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept; + simdjson_really_inline simdjson_warn_unused simdjson_result unescape(uint8_t *&dst) const noexcept; + simdjson_really_inline simdjson_warn_unused simdjson_result unescape(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) const noexcept; }; } // namespace simdjson diff --git a/include/simdjson/generic/ondemand/value-inl.h b/include/simdjson/generic/ondemand/value-inl.h index 6f4e8b0a4..ff2c4b054 100644 --- a/include/simdjson/generic/ondemand/value-inl.h +++ b/include/simdjson/generic/ondemand/value-inl.h @@ -18,7 +18,7 @@ simdjson_really_inline value::~value() noexcept { if (iter.is_alive()) { if (*json == '[' || *json == '{') { logger::log_start_value(*iter, "unused"); - SIMDJSON_UNUSED auto _err = iter->skip_container(); + simdjson_unused auto _err = iter->skip_container(); } else { logger::log_value(*iter, "unused"); } diff --git a/include/simdjson/generic/stringparsing.h b/include/simdjson/generic/stringparsing.h index 3e83b8056..2b92eba84 100644 --- a/include/simdjson/generic/stringparsing.h +++ b/include/simdjson/generic/stringparsing.h @@ -39,7 +39,7 @@ static const uint8_t escape_map[256] = { // dest will advance a variable amount (return via pointer) // return true if the unicode codepoint was valid // We work in little-endian then swap at write time -SIMDJSON_WARN_UNUSED +simdjson_warn_unused simdjson_really_inline bool handle_unicode_codepoint(const uint8_t **src_ptr, uint8_t **dst_ptr) { // jsoncharutils::hex_to_u32_nocheck fills high 16 bits of the return value with 1s if the @@ -73,7 +73,7 @@ simdjson_really_inline bool handle_unicode_codepoint(const uint8_t **src_ptr, return offset > 0; } -SIMDJSON_WARN_UNUSED simdjson_really_inline uint8_t *parse_string(const uint8_t *src, uint8_t *dst) { +simdjson_warn_unused simdjson_really_inline uint8_t *parse_string(const uint8_t *src, uint8_t *dst) { while (1) { // Copy the next n bytes, and find the backslash and quote in them. auto bs_quote = backslash_and_quote::copy_and_find(src, dst); @@ -119,7 +119,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline uint8_t *parse_string(const uint8_t return nullptr; } -SIMDJSON_UNUSED SIMDJSON_WARN_UNUSED simdjson_really_inline error_code parse_string_to_buffer(const uint8_t *src, uint8_t *¤t_string_buf_loc, std::string_view &s) { +simdjson_unused simdjson_warn_unused simdjson_really_inline error_code parse_string_to_buffer(const uint8_t *src, uint8_t *¤t_string_buf_loc, std::string_view &s) { if (*(src++) != '"') { return STRING_ERROR; } auto end = stringparsing::parse_string(src, current_string_buf_loc); if (!end) { return STRING_ERROR; } diff --git a/include/simdjson/haswell/implementation.h b/include/simdjson/haswell/implementation.h index f779deae6..90c28830c 100644 --- a/include/simdjson/haswell/implementation.h +++ b/include/simdjson/haswell/implementation.h @@ -16,13 +16,13 @@ public: "Intel/AMD AVX2", internal::instruction_set::AVX2 | internal::instruction_set::PCLMULQDQ | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 ) {} - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, size_t max_length, std::unique_ptr& dst ) const noexcept final; - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; - SIMDJSON_WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final; + simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; + simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; }; } // namespace haswell diff --git a/include/simdjson/implementation.h b/include/simdjson/implementation.h index 2d6d266e3..00af6e6f4 100644 --- a/include/simdjson/implementation.h +++ b/include/simdjson/implementation.h @@ -17,7 +17,7 @@ namespace simdjson { * @param len the length of the string in bytes. * @return true if the string is valid UTF-8. */ -SIMDJSON_WARN_UNUSED bool validate_utf8(const char * buf, size_t len) noexcept; +simdjson_warn_unused bool validate_utf8(const char * buf, size_t len) noexcept; /** @@ -26,7 +26,7 @@ SIMDJSON_WARN_UNUSED bool validate_utf8(const char * buf, size_t len) noexcept; * @param sv the string_view to validate. * @return true if the string is valid UTF-8. */ -simdjson_really_inline SIMDJSON_WARN_UNUSED bool validate_utf8(const std::string_view sv) noexcept { +simdjson_really_inline simdjson_warn_unused bool validate_utf8(const std::string_view sv) noexcept { return validate_utf8(sv.data(), sv.size()); } @@ -36,7 +36,7 @@ simdjson_really_inline SIMDJSON_WARN_UNUSED bool validate_utf8(const std::string * @param p the string to validate. * @return true if the string is valid UTF-8. */ -simdjson_really_inline SIMDJSON_WARN_UNUSED bool validate_utf8(const std::string& s) noexcept { +simdjson_really_inline simdjson_warn_unused bool validate_utf8(const std::string& s) noexcept { return validate_utf8(s.data(), s.size()); } @@ -122,7 +122,7 @@ public: * @param dst_len the number of bytes written. Output only. * @return the error code, or SUCCESS if there was no error. */ - SIMDJSON_WARN_UNUSED virtual error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept = 0; + simdjson_warn_unused virtual error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept = 0; /** @@ -134,7 +134,7 @@ public: * @param len the length of the string in bytes. * @return true if and only if the string is valid UTF-8. */ - SIMDJSON_WARN_UNUSED virtual bool validate_utf8(const char *buf, size_t len) const noexcept = 0; + simdjson_warn_unused virtual bool validate_utf8(const char *buf, size_t len) const noexcept = 0; protected: /** @private Construct an implementation with the given name and description. For subclasses. */ diff --git a/include/simdjson/internal/dom_parser_implementation.h b/include/simdjson/internal/dom_parser_implementation.h index 01bac46e4..d615087c7 100644 --- a/include/simdjson/internal/dom_parser_implementation.h +++ b/include/simdjson/internal/dom_parser_implementation.h @@ -35,7 +35,7 @@ public: * @param len The length of the json document. * @return The error code, or SUCCESS if there was no error. */ - SIMDJSON_WARN_UNUSED virtual error_code parse(const uint8_t *buf, size_t len, dom::document &doc) noexcept = 0; + simdjson_warn_unused virtual error_code parse(const uint8_t *buf, size_t len, dom::document &doc) noexcept = 0; /** * @private For internal implementation use @@ -51,7 +51,7 @@ public: * @param streaming Whether this is being called by parser::parse_many. * @return The error code, or SUCCESS if there was no error. */ - SIMDJSON_WARN_UNUSED virtual error_code stage1(const uint8_t *buf, size_t len, bool streaming) noexcept = 0; + simdjson_warn_unused virtual error_code stage1(const uint8_t *buf, size_t len, bool streaming) noexcept = 0; /** * @private For internal implementation use @@ -65,7 +65,7 @@ public: * @param doc The document to output to. * @return The error code, or SUCCESS if there was no error. */ - SIMDJSON_WARN_UNUSED virtual error_code stage2(dom::document &doc) noexcept = 0; + simdjson_warn_unused virtual error_code stage2(dom::document &doc) noexcept = 0; /** * @private For internal implementation use @@ -78,7 +78,7 @@ public: * @param doc The document to output to. * @return The error code, SUCCESS if there was no error, or EMPTY if all documents have been parsed. */ - SIMDJSON_WARN_UNUSED virtual error_code stage2_next(dom::document &doc) noexcept = 0; + simdjson_warn_unused virtual error_code stage2_next(dom::document &doc) noexcept = 0; /** * Change the capacity of this parser. @@ -136,7 +136,7 @@ public: * @param max_depth The new max_depth. Defaults to DEFAULT_MAX_DEPTH. * @return The error, if there is one. */ - SIMDJSON_WARN_UNUSED inline error_code allocate(size_t capacity, size_t max_depth) noexcept; + simdjson_warn_unused inline error_code allocate(size_t capacity, size_t max_depth) noexcept; protected: /** @@ -174,7 +174,7 @@ simdjson_really_inline size_t dom_parser_implementation::max_depth() const noexc return _max_depth; } -SIMDJSON_WARN_UNUSED +simdjson_warn_unused inline error_code dom_parser_implementation::allocate(size_t capacity, size_t max_depth) noexcept { if (this->max_depth() != max_depth) { error_code err = set_max_depth(max_depth); diff --git a/include/simdjson/minify.h b/include/simdjson/minify.h index e85c2a40b..f6ddd659d 100644 --- a/include/simdjson/minify.h +++ b/include/simdjson/minify.h @@ -25,7 +25,7 @@ namespace simdjson { * @param dst_len the number of bytes written. Output only. * @return the error code, or SUCCESS if there was no error. */ -SIMDJSON_WARN_UNUSED error_code minify(const char *buf, size_t len, char *dst, size_t &dst_len) noexcept; +simdjson_warn_unused error_code minify(const char *buf, size_t len, char *dst, size_t &dst_len) noexcept; } // namespace simdjson diff --git a/include/simdjson/westmere/implementation.h b/include/simdjson/westmere/implementation.h index 8f083a256..c4573adce 100644 --- a/include/simdjson/westmere/implementation.h +++ b/include/simdjson/westmere/implementation.h @@ -15,13 +15,13 @@ using namespace simdjson::dom; class implementation final : public simdjson::implementation { public: simdjson_really_inline implementation() : simdjson::implementation("westmere", "Intel/AMD SSE4.2", internal::instruction_set::SSE42 | internal::instruction_set::PCLMULQDQ) {} - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, size_t max_length, std::unique_ptr& dst ) const noexcept final; - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; - SIMDJSON_WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final; + simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final; + simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; }; } // namespace westmere diff --git a/src/arm64/dom_parser_implementation.cpp b/src/arm64/dom_parser_implementation.cpp index ce77b235c..0703647c3 100644 --- a/src/arm64/dom_parser_implementation.cpp +++ b/src/arm64/dom_parser_implementation.cpp @@ -79,7 +79,7 @@ simdjson_really_inline bool is_ascii(const simd8x64& input) { return bits.max_val() < 0b10000000u; } -SIMDJSON_UNUSED simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { +simdjson_unused simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { simd8 is_second_byte = prev1 >= uint8_t(0b11000000u); simd8 is_third_byte = prev2 >= uint8_t(0b11100000u); simd8 is_fourth_byte = prev3 >= uint8_t(0b11110000u); @@ -129,29 +129,29 @@ simdjson_really_inline uint64_t json_string_scanner::find_escaped(uint64_t backs } // namespace stage1 } // unnamed namespace -SIMDJSON_WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { +simdjson_warn_unused error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { return arm64::stage1::json_minifier::minify<64>(buf, len, dst, dst_len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { this->buf = _buf; this->len = _len; return arm64::stage1::json_structural_indexer::index<64>(buf, len, *this, streaming); } -SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { +simdjson_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { return arm64::stage1::generic_validate_utf8(buf,len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { auto error = stage1(_buf, _len, false); if (error) { return error; } return stage2(_doc); diff --git a/src/arm64/implementation.cpp b/src/arm64/implementation.cpp index a81b7f579..7a1929d7b 100644 --- a/src/arm64/implementation.cpp +++ b/src/arm64/implementation.cpp @@ -3,7 +3,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { -SIMDJSON_WARN_UNUSED error_code implementation::create_dom_parser_implementation( +simdjson_warn_unused error_code implementation::create_dom_parser_implementation( size_t capacity, size_t max_depth, std::unique_ptr& dst diff --git a/src/fallback/dom_parser_implementation.cpp b/src/fallback/dom_parser_implementation.cpp index 5354cbc3e..df9ab5848 100644 --- a/src/fallback/dom_parser_implementation.cpp +++ b/src/fallback/dom_parser_implementation.cpp @@ -180,7 +180,7 @@ private: } // namespace stage1 } // unnamed namespace -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool partial) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool partial) noexcept { this->buf = _buf; this->len = _len; stage1::structural_scanner scanner(*this, partial); @@ -222,7 +222,7 @@ static uint8_t jump_table[256 * 3] = { 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, }; -SIMDJSON_WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { +simdjson_warn_unused error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { size_t i = 0, pos = 0; uint8_t quote = 0; uint8_t nonescape = 1; @@ -244,7 +244,7 @@ SIMDJSON_WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_ } // credit: based on code from Google Fuchsia (Apache Licensed) -SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { +simdjson_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { const uint8_t *data = (const uint8_t *)buf; uint64_t pos = 0; uint64_t next_pos = 0; @@ -318,15 +318,15 @@ SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { auto error = stage1(_buf, _len, false); if (error) { return error; } return stage2(_doc); diff --git a/src/fallback/implementation.cpp b/src/fallback/implementation.cpp index cba31482b..1f6c1643c 100644 --- a/src/fallback/implementation.cpp +++ b/src/fallback/implementation.cpp @@ -3,7 +3,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { -SIMDJSON_WARN_UNUSED error_code implementation::create_dom_parser_implementation( +simdjson_warn_unused error_code implementation::create_dom_parser_implementation( size_t capacity, size_t max_depth, std::unique_ptr& dst diff --git a/src/generic/stage1/buf_block_reader.h b/src/generic/stage1/buf_block_reader.h index 813e13554..b598e1b53 100644 --- a/src/generic/stage1/buf_block_reader.h +++ b/src/generic/stage1/buf_block_reader.h @@ -29,7 +29,7 @@ private: }; // Routines to print masks and text for debugging bitmask operations -SIMDJSON_UNUSED static char * format_input_text_64(const uint8_t *text) { +simdjson_unused static char * format_input_text_64(const uint8_t *text) { static char *buf = (char*)malloc(sizeof(simd8x64) + 1); for (size_t i=0; i); i++) { buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); @@ -39,7 +39,7 @@ SIMDJSON_UNUSED static char * format_input_text_64(const uint8_t *text) { } // Routines to print masks and text for debugging bitmask operations -SIMDJSON_UNUSED static char * format_input_text(const simd8x64& in) { +simdjson_unused static char * format_input_text(const simd8x64& in) { static char *buf = (char*)malloc(sizeof(simd8x64) + 1); in.store((uint8_t*)buf); for (size_t i=0; i); i++) { @@ -49,7 +49,7 @@ SIMDJSON_UNUSED static char * format_input_text(const simd8x64& in) { return buf; } -SIMDJSON_UNUSED static char * format_mask(uint64_t mask) { +simdjson_unused static char * format_mask(uint64_t mask) { static char *buf = (char*)malloc(64 + 1); for (size_t i=0; i<64; i++) { buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; diff --git a/src/generic/stage2/json_iterator.h b/src/generic/stage2/json_iterator.h index 91fce480c..242d8abd7 100644 --- a/src/generic/stage2/json_iterator.h +++ b/src/generic/stage2/json_iterator.h @@ -36,7 +36,7 @@ public: * - increment_count(iter) - each time a value is found in an array or object. */ template - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code walk_document(V &visitor) noexcept; + simdjson_warn_unused simdjson_really_inline error_code walk_document(V &visitor) noexcept; /** * Create an iterator capable of walking a JSON document. @@ -103,13 +103,13 @@ public: simdjson_really_inline void log_error(const char *error) const noexcept; template - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_primitive(V &visitor, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_primitive(V &visitor, const uint8_t *value) noexcept; template - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_primitive(V &visitor, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_primitive(V &visitor, const uint8_t *value) noexcept; }; template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_document(V &visitor) noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::walk_document(V &visitor) noexcept { logger::log_start(); // @@ -279,7 +279,7 @@ simdjson_really_inline void json_iterator::log_error(const char *error) const no } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::visit_root_primitive(V &visitor, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::visit_root_primitive(V &visitor, const uint8_t *value) noexcept { switch (*value) { case '"': return visitor.visit_root_string(*this, value); case 't': return visitor.visit_root_true_atom(*this, value); @@ -295,7 +295,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::visit_root } } template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::visit_primitive(V &visitor, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code json_iterator::visit_primitive(V &visitor, const uint8_t *value) noexcept { switch (*value) { case '"': return visitor.visit_string(*this, value); case 't': return visitor.visit_true_atom(*this, value); diff --git a/src/generic/stage2/logger.h b/src/generic/stage2/logger.h index f3f5c7abf..47d4ca303 100644 --- a/src/generic/stage2/logger.h +++ b/src/generic/stage2/logger.h @@ -38,7 +38,7 @@ namespace logger { } } - SIMDJSON_UNUSED static simdjson_really_inline void log_string(const char *message) { + simdjson_unused static simdjson_really_inline void log_string(const char *message) { if (LOG_ENABLED) { printf("%s\n", message); } diff --git a/src/generic/stage2/tape_builder.h b/src/generic/stage2/tape_builder.h index 2cf8276dc..c8bd98057 100644 --- a/src/generic/stage2/tape_builder.h +++ b/src/generic/stage2/tape_builder.h @@ -8,40 +8,40 @@ namespace stage2 { struct tape_builder { template - SIMDJSON_WARN_UNUSED static simdjson_really_inline error_code parse_document( + simdjson_warn_unused static simdjson_really_inline error_code parse_document( dom_parser_implementation &dom_parser, dom::document &doc) noexcept; /** Called when a non-empty document starts. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_document_start(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_document_start(json_iterator &iter) noexcept; /** Called when a non-empty document ends without error. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_document_end(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_document_end(json_iterator &iter) noexcept; /** Called when a non-empty array starts. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_array_start(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_array_start(json_iterator &iter) noexcept; /** Called when a non-empty array ends. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_array_end(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_array_end(json_iterator &iter) noexcept; /** Called when an empty array is found. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_empty_array(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_empty_array(json_iterator &iter) noexcept; /** Called when a non-empty object starts. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_object_start(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_object_start(json_iterator &iter) noexcept; /** * Called when a key in a field is encountered. * * primitive, visit_object_start, visit_empty_object, visit_array_start, or visit_empty_array * will be called after this with the field value. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_key(json_iterator &iter, const uint8_t *key) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_key(json_iterator &iter, const uint8_t *key) noexcept; /** Called when a non-empty object ends. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_object_end(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_object_end(json_iterator &iter) noexcept; /** Called when an empty object is found. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_empty_object(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_empty_object(json_iterator &iter) noexcept; /** * Called when a string, number, boolean or null is found. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_primitive(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_primitive(json_iterator &iter, const uint8_t *value) noexcept; /** * Called when a string, number, boolean or null is found at the top level of a document (i.e. * when there is no array or object and the entire document is a single string, number, boolean or @@ -50,22 +50,22 @@ struct tape_builder { * This is separate from primitive() because simdjson's normal primitive parsing routines assume * there is at least one more token after the value, which is only true in an array or object. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_primitive(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_primitive(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_string(json_iterator &iter, const uint8_t *value, bool key = false) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_number(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_true_atom(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_false_atom(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_null_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_string(json_iterator &iter, const uint8_t *value, bool key = false) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_number(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_true_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_false_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_null_atom(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_string(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_number(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_true_atom(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_false_atom(json_iterator &iter, const uint8_t *value) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code visit_root_null_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_string(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_number(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_true_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_false_atom(json_iterator &iter, const uint8_t *value) noexcept; + simdjson_warn_unused simdjson_really_inline error_code visit_root_null_atom(json_iterator &iter, const uint8_t *value) noexcept; /** Called each time a new field or element in an array or object is found. */ - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code increment_count(json_iterator &iter) noexcept; + simdjson_warn_unused simdjson_really_inline error_code increment_count(json_iterator &iter) noexcept; /** Next location to write to tape */ tape_writer tape; @@ -77,14 +77,14 @@ private: simdjson_really_inline uint32_t next_tape_index(json_iterator &iter) const noexcept; simdjson_really_inline void start_container(json_iterator &iter) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code end_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept; - SIMDJSON_WARN_UNUSED simdjson_really_inline error_code empty_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept; + simdjson_warn_unused simdjson_really_inline error_code end_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept; + simdjson_warn_unused simdjson_really_inline error_code empty_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept; simdjson_really_inline uint8_t *on_start_string(json_iterator &iter) noexcept; simdjson_really_inline void on_end_string(uint8_t *dst) noexcept; }; // class tape_builder template -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::parse_document( +simdjson_warn_unused simdjson_really_inline error_code tape_builder::parse_document( dom_parser_implementation &dom_parser, dom::document &doc) noexcept { dom_parser.doc = &doc; @@ -93,56 +93,56 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::parse_docum return iter.walk_document(builder); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_primitive(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_primitive(json_iterator &iter, const uint8_t *value) noexcept { return iter.visit_root_primitive(*this, value); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_primitive(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_primitive(json_iterator &iter, const uint8_t *value) noexcept { return iter.visit_primitive(*this, value); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_empty_object(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_empty_object(json_iterator &iter) noexcept { return empty_container(iter, internal::tape_type::START_OBJECT, internal::tape_type::END_OBJECT); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_empty_array(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_empty_array(json_iterator &iter) noexcept { return empty_container(iter, internal::tape_type::START_ARRAY, internal::tape_type::END_ARRAY); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_document_start(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_document_start(json_iterator &iter) noexcept { start_container(iter); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_object_start(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_object_start(json_iterator &iter) noexcept { start_container(iter); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_array_start(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_array_start(json_iterator &iter) noexcept { start_container(iter); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_object_end(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_object_end(json_iterator &iter) noexcept { return end_container(iter, internal::tape_type::START_OBJECT, internal::tape_type::END_OBJECT); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_array_end(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_array_end(json_iterator &iter) noexcept { return end_container(iter, internal::tape_type::START_ARRAY, internal::tape_type::END_ARRAY); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_document_end(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_document_end(json_iterator &iter) noexcept { constexpr uint32_t start_tape_index = 0; tape.append(start_tape_index, internal::tape_type::ROOT); tape_writer::write(iter.dom_parser.doc->tape[start_tape_index], next_tape_index(iter), internal::tape_type::ROOT); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_key(json_iterator &iter, const uint8_t *key) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_key(json_iterator &iter, const uint8_t *key) noexcept { return visit_string(iter, key, true); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::increment_count(json_iterator &iter) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::increment_count(json_iterator &iter) noexcept { iter.dom_parser.open_containers[iter.depth].count++; // we have a key value pair in the object at parser.dom_parser.depth - 1 return SUCCESS; } simdjson_really_inline tape_builder::tape_builder(dom::document &doc) noexcept : tape{doc.tape.get()}, current_string_buf_loc{doc.string_buf.get()} {} -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_string(json_iterator &iter, const uint8_t *value, bool key) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_string(json_iterator &iter, const uint8_t *value, bool key) noexcept { iter.log_value(key ? "key" : "string"); uint8_t *dst = on_start_string(iter); dst = stringparsing::parse_string(value+1, dst); @@ -154,16 +154,16 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_strin return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_string(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_string(json_iterator &iter, const uint8_t *value) noexcept { return visit_string(iter, value); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_number(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_number(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("number"); return numberparsing::parse_number(value, tape); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_number(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_number(json_iterator &iter, const uint8_t *value) noexcept { // // We need to make a copy to make sure that the string is space terminated. // This is not about padding the input, which should already padded up @@ -186,42 +186,42 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_ return error; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_true_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_true_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("true"); if (!atomparsing::is_valid_true_atom(value)) { return T_ATOM_ERROR; } tape.append(0, internal::tape_type::TRUE_VALUE); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_true_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_true_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("true"); if (!atomparsing::is_valid_true_atom(value, iter.remaining_len())) { return T_ATOM_ERROR; } tape.append(0, internal::tape_type::TRUE_VALUE); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_false_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_false_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("false"); if (!atomparsing::is_valid_false_atom(value)) { return F_ATOM_ERROR; } tape.append(0, internal::tape_type::FALSE_VALUE); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_false_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_false_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("false"); if (!atomparsing::is_valid_false_atom(value, iter.remaining_len())) { return F_ATOM_ERROR; } tape.append(0, internal::tape_type::FALSE_VALUE); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_null_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_null_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("null"); if (!atomparsing::is_valid_null_atom(value)) { return N_ATOM_ERROR; } tape.append(0, internal::tape_type::NULL_VALUE); return SUCCESS; } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::visit_root_null_atom(json_iterator &iter, const uint8_t *value) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::visit_root_null_atom(json_iterator &iter, const uint8_t *value) noexcept { iter.log_value("null"); if (!atomparsing::is_valid_null_atom(value, iter.remaining_len())) { return N_ATOM_ERROR; } tape.append(0, internal::tape_type::NULL_VALUE); @@ -234,7 +234,7 @@ simdjson_really_inline uint32_t tape_builder::next_tape_index(json_iterator &ite return uint32_t(tape.next_tape_loc - iter.dom_parser.doc->tape.get()); } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::empty_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::empty_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept { auto start_index = next_tape_index(iter); tape.append(start_index+2, start); tape.append(start_index, end); @@ -247,7 +247,7 @@ simdjson_really_inline void tape_builder::start_container(json_iterator &iter) n tape.skip(); // We don't actually *write* the start element until the end. } -SIMDJSON_WARN_UNUSED simdjson_really_inline error_code tape_builder::end_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept { +simdjson_warn_unused simdjson_really_inline error_code tape_builder::end_container(json_iterator &iter, internal::tape_type start, internal::tape_type end) noexcept { // Write the ending tape element, pointing at the start location const uint32_t start_tape_index = iter.dom_parser.open_containers[iter.depth].tape_index; tape.append(start_tape_index, end); diff --git a/src/haswell/dom_parser_implementation.cpp b/src/haswell/dom_parser_implementation.cpp index ade441900..f21da0d01 100644 --- a/src/haswell/dom_parser_implementation.cpp +++ b/src/haswell/dom_parser_implementation.cpp @@ -86,7 +86,7 @@ simdjson_really_inline bool is_ascii(const simd8x64& input) { return input.reduce_or().is_ascii(); } -SIMDJSON_UNUSED simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { +simdjson_unused simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { simd8 is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0 simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 @@ -130,29 +130,29 @@ simdjson_really_inline uint64_t json_string_scanner::find_escaped(uint64_t backs } // namespace stage1 } // unnamed namespace -SIMDJSON_WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { +simdjson_warn_unused error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { return haswell::stage1::json_minifier::minify<128>(buf, len, dst, dst_len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { this->buf = _buf; this->len = _len; return haswell::stage1::json_structural_indexer::index<128>(_buf, _len, *this, streaming); } -SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { +simdjson_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { return haswell::stage1::generic_validate_utf8(buf,len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { auto error = stage1(_buf, _len, false); if (error) { return error; } return stage2(_doc); diff --git a/src/haswell/implementation.cpp b/src/haswell/implementation.cpp index cdea702db..d41b25381 100644 --- a/src/haswell/implementation.cpp +++ b/src/haswell/implementation.cpp @@ -3,7 +3,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { -SIMDJSON_WARN_UNUSED error_code implementation::create_dom_parser_implementation( +simdjson_warn_unused error_code implementation::create_dom_parser_implementation( size_t capacity, size_t max_depth, std::unique_ptr& dst diff --git a/src/implementation.cpp b/src/implementation.cpp index afbc33102..021674bba 100644 --- a/src/implementation.cpp +++ b/src/implementation.cpp @@ -35,17 +35,17 @@ public: const std::string &name() const noexcept final { return set_best()->name(); } const std::string &description() const noexcept final { return set_best()->description(); } uint32_t required_instruction_sets() const noexcept final { return set_best()->required_instruction_sets(); } - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, size_t max_length, std::unique_ptr& dst ) const noexcept final { return set_best()->create_dom_parser_implementation(capacity, max_length, dst); } - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final { + simdjson_warn_unused error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final { return set_best()->minify(buf, len, dst, dst_len); } - SIMDJSON_WARN_UNUSED bool validate_utf8(const char * buf, size_t len) const noexcept final override { + simdjson_warn_unused bool validate_utf8(const char * buf, size_t len) const noexcept final override { return set_best()->validate_utf8(buf, len); } simdjson_really_inline detect_best_supported_implementation_on_first_use() noexcept : implementation("best_supported_detector", "Detects the best supported implementation and sets it", 0) {} @@ -73,17 +73,17 @@ const std::initializer_list available_implementation_poi // So we can return UNSUPPORTED_ARCHITECTURE from the parser when there is no support class unsupported_implementation final : public implementation { public: - SIMDJSON_WARN_UNUSED error_code create_dom_parser_implementation( + simdjson_warn_unused error_code create_dom_parser_implementation( size_t, size_t, std::unique_ptr& ) const noexcept final { return UNSUPPORTED_ARCHITECTURE; } - SIMDJSON_WARN_UNUSED error_code minify(const uint8_t *, size_t, uint8_t *, size_t &) const noexcept final override { + simdjson_warn_unused error_code minify(const uint8_t *, size_t, uint8_t *, size_t &) const noexcept final override { return UNSUPPORTED_ARCHITECTURE; } - SIMDJSON_WARN_UNUSED bool validate_utf8(const char *, size_t) const noexcept final override { + simdjson_warn_unused bool validate_utf8(const char *, size_t) const noexcept final override { return false; // Just refuse to validate. Given that we have a fallback implementation // it seems unlikely that unsupported_implementation will ever be used. If it is used, // then it will flag all strings as invalid. The alternative is to return an error_code @@ -140,10 +140,10 @@ const implementation *detect_best_supported_implementation_on_first_use::set_bes SIMDJSON_DLLIMPORTEXPORT const internal::available_implementation_list available_implementations{}; SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr active_implementation{&internal::detect_best_supported_implementation_on_first_use_singleton}; -SIMDJSON_WARN_UNUSED error_code minify(const char *buf, size_t len, char *dst, size_t &dst_len) noexcept { +simdjson_warn_unused error_code minify(const char *buf, size_t len, char *dst, size_t &dst_len) noexcept { return active_implementation->minify((const uint8_t *)buf, len, (uint8_t *)dst, dst_len); } -SIMDJSON_WARN_UNUSED bool validate_utf8(const char *buf, size_t len) noexcept { +simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept { return active_implementation->validate_utf8(buf, len); } diff --git a/src/westmere/dom_parser_implementation.cpp b/src/westmere/dom_parser_implementation.cpp index 9edbe79a3..67bce00cb 100644 --- a/src/westmere/dom_parser_implementation.cpp +++ b/src/westmere/dom_parser_implementation.cpp @@ -84,7 +84,7 @@ simdjson_really_inline bool is_ascii(const simd8x64& input) { return input.reduce_or().is_ascii(); } -SIMDJSON_UNUSED simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { +simdjson_unused simdjson_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { simd8 is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0 simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 @@ -129,29 +129,29 @@ simdjson_really_inline uint64_t json_string_scanner::find_escaped(uint64_t backs } // namespace stage1 } // unnamed namespace -SIMDJSON_WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { +simdjson_warn_unused error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { return westmere::stage1::json_minifier::minify<64>(buf, len, dst, dst_len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept { this->buf = _buf; this->len = _len; return westmere::stage1::json_structural_indexer::index<64>(_buf, _len, *this, streaming); } -SIMDJSON_WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { +simdjson_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { return westmere::stage1::generic_validate_utf8(buf,len); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept { return stage2::tape_builder::parse_document(*this, _doc); } -SIMDJSON_WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { +simdjson_warn_unused error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept { auto error = stage1(_buf, _len, false); if (error) { return error; } return stage2(_doc); diff --git a/src/westmere/implementation.cpp b/src/westmere/implementation.cpp index 71237c3c6..46f0a9a04 100644 --- a/src/westmere/implementation.cpp +++ b/src/westmere/implementation.cpp @@ -3,7 +3,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { -SIMDJSON_WARN_UNUSED error_code implementation::create_dom_parser_implementation( +simdjson_warn_unused error_code implementation::create_dom_parser_implementation( size_t capacity, size_t max_depth, std::unique_ptr& dst diff --git a/tests/allparserscheckfile.cpp b/tests/allparserscheckfile.cpp index 9eda379fb..26c4e9dde 100644 --- a/tests/allparserscheckfile.cpp +++ b/tests/allparserscheckfile.cpp @@ -29,7 +29,7 @@ extern "C" { SIMDJSON_POP_DISABLE_WARNINGS // fastjson has a tricky interface -void on_json_error(void *, SIMDJSON_UNUSED const fastjson::ErrorContext &ec) { +void on_json_error(void *, simdjson_unused const fastjson::ErrorContext &ec) { // std::cerr<<"ERROR: "<().first, 1 ); simdjson::error_code error; - SIMDJSON_UNUSED element val; + simdjson_unused element val; #ifndef _LIBCPP_VERSION // should work everywhere but with libc++, must include the header. std::tie(val,error) = object["d"]; ASSERT_ERROR( error, NO_SUCH_FIELD ); @@ -819,7 +819,7 @@ namespace dom_api_tests { ASSERT_EQUAL( obj["b"].get().first, 2 ); ASSERT_EQUAL( obj["a"].get().first, 1 ); - SIMDJSON_UNUSED element val; + simdjson_unused element val; ASSERT_ERROR( doc["d"].get(val), NO_SUCH_FIELD); return true; } diff --git a/tests/cast_tester.h b/tests/cast_tester.h index d03895a27..18309b5f6 100644 --- a/tests/cast_tester.h +++ b/tests/cast_tester.h @@ -168,7 +168,7 @@ bool cast_tester::test_implicit_cast(simdjson_result element, T expe template bool cast_tester::test_implicit_cast_error(element element, error_code expected_error) { try { - SIMDJSON_UNUSED T actual; + simdjson_unused T actual; actual = element; return false; } catch(simdjson_error &e) { @@ -180,7 +180,7 @@ bool cast_tester::test_implicit_cast_error(element element, error_code expect template bool cast_tester::test_implicit_cast_error(simdjson_result element, error_code expected_error) { try { - SIMDJSON_UNUSED T actual; + simdjson_unused T actual; actual = element; return false; } catch(simdjson_error &e) { diff --git a/tests/document_stream_tests.cpp b/tests/document_stream_tests.cpp index ef86c761d..1dd2ce51a 100644 --- a/tests/document_stream_tests.cpp +++ b/tests/document_stream_tests.cpp @@ -21,11 +21,11 @@ std::string trim(const std::string s) { namespace document_stream_tests { static simdjson::dom::document_stream parse_many_stream_return(simdjson::dom::parser &parser, simdjson::padded_string &str) { simdjson::dom::document_stream stream; - SIMDJSON_UNUSED auto error = parser.parse_many(str).get(stream); + simdjson_unused auto error = parser.parse_many(str).get(stream); return stream; } // this is a compilation test - SIMDJSON_UNUSED static void parse_many_stream_assign() { + simdjson_unused static void parse_many_stream_assign() { simdjson::dom::parser parser; simdjson::padded_string str("{}",2); simdjson::dom::document_stream s1 = parse_many_stream_return(parser, str); diff --git a/tests/document_tests.cpp b/tests/document_tests.cpp index 49f46488e..a5697ce3a 100644 --- a/tests/document_tests.cpp +++ b/tests/document_tests.cpp @@ -94,7 +94,7 @@ namespace document_tests { myStream << parser.parse(json); #else simdjson::dom::element doc; - SIMDJSON_UNUSED auto error = parser.parse(json).get(doc); + simdjson_unused auto error = parser.parse(json).get(doc); myStream << doc; #endif std::string newjson = myStream.str(); diff --git a/tests/errortests.cpp b/tests/errortests.cpp index ca3532e00..d623734be 100644 --- a/tests/errortests.cpp +++ b/tests/errortests.cpp @@ -117,14 +117,14 @@ namespace parser_load { bool parser_load_chain() { TEST_START(); dom::parser parser; - SIMDJSON_UNUSED uint64_t foo; + simdjson_unused uint64_t foo; ASSERT_ERROR( parser.load(NONEXISTENT_FILE)["foo"].get(foo), IO_ERROR); TEST_SUCCEED(); } bool parser_load_many_chain() { TEST_START(); dom::parser parser; - SIMDJSON_UNUSED dom::document_stream stream; + simdjson_unused dom::document_stream stream; ASSERT_ERROR( parser.load_many(NONEXISTENT_FILE).get(stream), IO_ERROR ); TEST_SUCCEED(); } diff --git a/tests/ondemand/ondemand_basictests.cpp b/tests/ondemand/ondemand_basictests.cpp index 552a5262c..bd207b9cc 100644 --- a/tests/ondemand/ondemand_basictests.cpp +++ b/tests/ondemand/ondemand_basictests.cpp @@ -214,7 +214,7 @@ namespace parse_api_tests { TEST_START(); ondemand::parser parser; auto doc = parser.iterate(BASIC_JSON); - SIMDJSON_UNUSED ondemand::array array = doc; + simdjson_unused ondemand::array array = doc; return true; } #endif @@ -275,14 +275,14 @@ namespace dom_api_tests { ondemand::array array; ASSERT_SUCCESS( doc_result.get(array) ); int i=0; - for (SIMDJSON_UNUSED auto value : array) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } + for (simdjson_unused auto value : array) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } ASSERT_EQUAL(i*sizeof(uint64_t), sizeof(expected_value)); return true; })); SUBTEST("simdjson_result", test_ondemand_doc(json, [&](auto doc_result) { simdjson_result array = doc_result.get_array(); int i=0; - for (SIMDJSON_UNUSED auto value : array) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } + for (simdjson_unused auto value : array) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } ASSERT_EQUAL(i*sizeof(uint64_t), sizeof(expected_value)); return true; })); @@ -290,13 +290,13 @@ namespace dom_api_tests { ondemand::document doc; ASSERT_SUCCESS( std::move(doc_result).get(doc) ); int i=0; - for (SIMDJSON_UNUSED auto value : doc) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } + for (simdjson_unused auto value : doc) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } ASSERT_EQUAL(i*sizeof(uint64_t), sizeof(expected_value)); return true; })); SUBTEST("simdjson_result", test_ondemand_doc(json, [&](auto doc_result) { int i=0; - for (SIMDJSON_UNUSED auto value : doc_result) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } + for (simdjson_unused auto value : doc_result) { int64_t actual; ASSERT_SUCCESS( value.get(actual) ); ASSERT_EQUAL(actual, expected_value[i]); i++; } ASSERT_EQUAL(i*sizeof(uint64_t), sizeof(expected_value)); return true; })); @@ -310,14 +310,14 @@ namespace dom_api_tests { SUBTEST("ondemand::object", test_ondemand_doc(json, [&](auto doc_result) { ondemand::object object; ASSERT_SUCCESS( doc_result.get(object) ); - for (SIMDJSON_UNUSED auto field : object) { + for (simdjson_unused auto field : object) { TEST_FAIL("Unexpected field"); } return true; })); SUBTEST("simdjson_result", test_ondemand_doc(json, [&](auto doc_result) { simdjson_result object_result = doc_result.get_object(); - for (SIMDJSON_UNUSED auto field : object_result) { + for (simdjson_unused auto field : object_result) { TEST_FAIL("Unexpected field"); } return true; @@ -331,22 +331,22 @@ namespace dom_api_tests { SUBTEST("ondemand::array", test_ondemand_doc(json, [&](auto doc_result) { ondemand::array array; ASSERT_SUCCESS( doc_result.get(array) ); - for (SIMDJSON_UNUSED auto value : array) { TEST_FAIL("Unexpected value"); } + for (simdjson_unused auto value : array) { TEST_FAIL("Unexpected value"); } return true; })); SUBTEST("simdjson_result", test_ondemand_doc(json, [&](auto doc_result) { simdjson_result array_result = doc_result.get_array(); - for (SIMDJSON_UNUSED auto value : array_result) { TEST_FAIL("Unexpected value"); } + for (simdjson_unused auto value : array_result) { TEST_FAIL("Unexpected value"); } return true; })); SUBTEST("ondemand::document", test_ondemand_doc(json, [&](auto doc_result) { ondemand::document doc; ASSERT_SUCCESS( std::move(doc_result).get(doc) ); - for (SIMDJSON_UNUSED auto value : doc) { TEST_FAIL("Unexpected value"); } + for (simdjson_unused auto value : doc) { TEST_FAIL("Unexpected value"); } return true; })); SUBTEST("simdjson_result", test_ondemand_doc(json, [&](auto doc_result) { - for (SIMDJSON_UNUSED auto value : doc_result) { TEST_FAIL("Unexpected value"); } + for (simdjson_unused auto value : doc_result) { TEST_FAIL("Unexpected value"); } return true; })); TEST_SUCCEED(); @@ -529,7 +529,7 @@ namespace dom_api_tests { auto json = R"({})"_padded; ASSERT_TRUE(test_ondemand_doc(json, [&](auto doc_result) { - for (SIMDJSON_UNUSED ondemand::field field : doc_result.get_object()) { + for (simdjson_unused ondemand::field field : doc_result.get_object()) { TEST_FAIL("Unexpected field"); } return true; @@ -543,7 +543,7 @@ namespace dom_api_tests { auto json = "[]"_padded; ASSERT_TRUE(test_ondemand_doc(json, [&](auto doc_result) { - for (SIMDJSON_UNUSED ondemand::value value : doc_result) { TEST_FAIL("Unexpected value"); } + for (simdjson_unused ondemand::value value : doc_result) { TEST_FAIL("Unexpected value"); } return true; })); diff --git a/tests/unicode_tests.cpp b/tests/unicode_tests.cpp index e9c9c282c..bc58ff574 100644 --- a/tests/unicode_tests.cpp +++ b/tests/unicode_tests.cpp @@ -99,7 +99,7 @@ std::vector RandomUTF8::generate(size_t output_bytes, long seed) { } // credit: based on code from Google Fuchsia (Apache Licensed) -SIMDJSON_WARN_UNUSED bool basic_validate_utf8(const char *buf, size_t len) noexcept { +simdjson_warn_unused bool basic_validate_utf8(const char *buf, size_t len) noexcept { const uint8_t *data = (const uint8_t *)buf; uint64_t pos = 0; uint64_t next_pos = 0;