Skip to content

[libc] Template the printf / scanf parser class #66277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions libc/fuzzing/stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ add_libc_fuzzer(
SRCS
printf_parser_fuzz.cpp
DEPENDS
libc.src.stdio.printf_core.mock_parser
COMPILE_OPTIONS
-DLIBC_COPT_MOCK_ARG_LIST
libc.src.stdio.printf_core.parser
)

add_libc_fuzzer(
Expand Down
7 changes: 2 additions & 5 deletions libc/fuzzing/stdio/printf_parser_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
///
//===----------------------------------------------------------------------===//

#ifndef LIBC_COPT_MOCK_ARG_LIST
#error The printf Parser Fuzzer must be compiled with LIBC_COPT_MOCK_ARG_LIST, and the parser itself must also be compiled with that option when it's linked against the fuzzer.
#endif

#include "src/__support/arg_list.h"
#include "src/stdio/printf_core/parser.h"

Expand All @@ -37,7 +33,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

auto mock_arg_list = internal::MockArgList();

auto parser = printf_core::Parser(in_str, mock_arg_list);
auto parser =
printf_core::Parser<internal::MockArgList>(in_str, mock_arg_list);

int str_percent_count = 0;

Expand Down
24 changes: 1 addition & 23 deletions libc/src/stdio/printf_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,8 @@ add_header_library(
libc.src.__support.FPUtil.fp_bits
)

add_object_library(
add_header_library(
parser
SRCS
parser.cpp
HDRS
parser.h
DEPENDS
.core_structs
libc.src.__support.arg_list
libc.src.__support.ctype_utils
libc.src.__support.str_to_integer
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.CPP.string_view
libc.src.__support.CPP.type_traits
libc.src.__support.common
)

add_object_library(
mock_parser
SRCS
parser.cpp
HDRS
parser.h
DEPENDS
Expand All @@ -42,8 +22,6 @@ add_object_library(
libc.src.__support.CPP.string_view
libc.src.__support.CPP.type_traits
libc.src.__support.common
COMPILE_OPTIONS
-DLIBC_COPT_MOCK_ARG_LIST
)

add_object_library(
Expand Down
Loading