Skip to content

Commit

Permalink
use boost::variant2::variant instead of std
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler92 committed Oct 10, 2024
1 parent 21131ce commit c24fd02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_fuzzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
buildtype: 'boost'
path: 'head'
toolset: clang-18
cxxstd: 14
cxxstd: 17
targets: libs/json/fuzzing//run
- name: Pack the corpus
working-directory: boost-root/libs/json/fuzzing/
Expand Down
18 changes: 5 additions & 13 deletions fuzzing/fuzz_direct_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
//

#include <boost/json/parse_into.hpp>
#include <boost/variant2/variant.hpp>
#include <boost/describe.hpp>
#include <map>

#ifndef BOOST_NO_CXX17_HDR_VARIANT
# include <variant>
# define IF_CXX17_HDR_VARIANT(...) __VA_ARGS__
#else
# define IF_CXX17_HDR_VARIANT(...)
#endif // BOOST_NO_CXX17_HDR_VARIANT

#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
# include <optional>
# define IF_CXX17_HDR_OPTIONAL(...) __VA_ARGS__
Expand Down Expand Up @@ -46,10 +40,7 @@ struct Object
std::tuple<bool, std::uint64_t, std::int64_t, double, std::string> t1;
std::tuple<std::array<std::string, 3>, std::array<double, 3>, std::nullptr_t> t2;
std::tuple<std::vector<std::string>, std::vector<double>> t3;

#ifndef BOOST_NO_CXX17_HDR_VARIANT
std::variant<bool, std::uint64_t, std::int64_t, double, std::string> v;
#endif // BOOST_NO_CXX17_HDR_VARIANT
boost::variant2::variant<bool, std::uint64_t, std::int64_t, double, std::string> v;

#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
std::optional<bool> ob;
Expand All @@ -61,8 +52,9 @@ struct Object
};

BOOST_DESCRIBE_STRUCT(Object, (),
(b, i64, u64, f, d, s, v1, v2, v3, a1, a2, a3, m1, m2, m3, t1, t2, t3,
IF_CXX17_HDR_OPTIONAL(ob, oi, ou, od, os), IF_CXX17_HDR_OPTIONAL(v)))
(b, i64, u64, f, d, s, v1, v2, v3, a1, a2, a3, m1, m2, m3, t1, t2, t3, v,
IF_CXX17_HDR_OPTIONAL(ob, oi, ou, od, os)))


bool
fuzz_direct_parse(string_view sv)
Expand Down
3 changes: 2 additions & 1 deletion fuzzing/old_crashes/direct_parse/valid_cxx14.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"m3": {"k": 0.42},
"t1": [true, 1, 2, 1.23, "s"],
"t2": [["a", "b", "c"], [1.0, 0.1, 2.2], null],
"t3": [[], []]
"t3": [[], []],
"v": "text"
}

0 comments on commit c24fd02

Please sign in to comment.