This is an archive of the discontinued LLVM Phabricator instance.

[libc] add printf converter
ClosedPublic

Authored by michaelrj on May 10 2022, 10:19 AM.

Details

Summary

This adds the main pieces of the last piece of printf, the converter.
This takes the completed format section from the parser and then
converts it to a string for the writer, which is why it was the last
piece to be written. So far it supports chars and strings, but more
pieces are coming. Additionally, it supports replacing all of the
conversion functions with user supplied versions at compile time to
allow for additional functionality.

Diff Detail

Event Timeline

michaelrj created this revision.May 10 2022, 10:19 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 10 2022, 10:19 AM
michaelrj requested review of this revision.May 10 2022, 10:19 AM
sivachandra accepted this revision.May 11 2022, 11:12 PM
sivachandra added inline comments.
libc/src/stdio/printf_core/char_converter.h
14

Nit: Empty line before this.

29

Empty line after. Same in other files also.

libc/src/stdio/printf_core/converter.h
24

Will we see more state added in future to keep Converter a class?

This revision is now accepted and ready to land.May 11 2022, 11:12 PM
michaelrj marked 3 inline comments as done.

change the converter from a class to a function, and update formatting.

libc/src/stdio/printf_core/converter.h
24

no, it was mostly a class because the other two pieces are. Now that you've pointed it out it seems obvious to just pass the writer to the function.

This revision was automatically updated to reflect the committed changes.