This is an archive of the discontinued LLVM Phabricator instance.

[libc] add scanf parser and core utilities
ClosedPublic

Authored by michaelrj on Oct 19 2022, 1:29 PM.

Details

Summary

This is the first piece of scanf. It's very similar in design to printf,
and so much of the code is copied from that. There were potential issues
with conflicting macros so I've also renamed the "ASSERT_FORMAT_EQ"
macro for printf to "ASSERT_PFORMAT_EQ".

Diff Detail

Event Timeline

michaelrj created this revision.Oct 19 2022, 1:29 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 19 2022, 1:29 PM
michaelrj requested review of this revision.Oct 19 2022, 1:29 PM
sivachandra added inline comments.Oct 27 2022, 11:33 AM
libc/src/stdio/scanf_core/core_structs.h
23

Bikeshed: Since the case is already mixed, why not just call it NONE instead of none?

32
45

Add doc-strings explaining what this method is doing and its intended use case.

80

Feel free to add a flip method to cpp::bitset in a separate CL - https://en.cppreference.com/w/cpp/utility/bitset/flip

100

Instead of literal 0, use a symbolic flag value, say NONE. So, this then becomes:

FormatFlags flags = FormatFlags::NONE;
142

Why are they not enum constants?

libc/src/stdio/scanf_core/parser.h
28

May be there is a typo somewhere in this comment?

libc/src/stdio/scanf_core/scanf_config.h
12

Add commentary explaining how are these to be used/tuned/configured.

michaelrj updated this revision to Diff 471281.Oct 27 2022, 1:36 PM
michaelrj marked 8 inline comments as done.

address comments

sivachandra accepted this revision.Oct 27 2022, 1:51 PM
sivachandra added inline comments.
libc/src/stdio/scanf_core/core_structs.h
80

Nit: The name should reflect that it is about errors. So, may be ErrorCodes.

This revision is now accepted and ready to land.Oct 27 2022, 1:51 PM
michaelrj updated this revision to Diff 471302.Oct 27 2022, 3:06 PM

address comment

michaelrj marked an inline comment as done.Oct 27 2022, 3:06 PM
This revision was landed with ongoing or failed builds.Oct 28 2022, 10:53 AM
This revision was automatically updated to reflect the committed changes.