[libc-commits] [PATCH] D122773: [libc][NFC] add outline of printf
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 31 15:13:03 PDT 2022
sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.
LGTM but we might tweak as we go.
================
Comment at: libc/src/stdio/printf_files/writer.h:29
+
+ size_t max_length;
+ size_t chars_written;
----------------
What is `max_length`?
================
Comment at: libc/src/stdio/printf_files/writer.h:38
+ // written. It always increments chars_written by length.
+ void write(const char *new_string, size_t length);
+
----------------
These functions should be implemented inline to avoid multiple indirections?
================
Comment at: libc/src/stdio/printf_files/writer.h:20
+
+class Writer {
+ void *output;
----------------
michaelrj wrote:
> sivachandra wrote:
> > Is this class envisioned to be a `final` class? If yes, then we should have documentation of the expectations. For example, what is `output`, `raw_write` etc. If not also, we should add documentation about how it is to be specialized.
> I was under the impression that virtual functions were disallowed in libc, so all classes were implicitly final.
>
> I've added comments with more explanation on how this specialization works.
Couple of things:
1. A class can be final without a virtual function.
2. Going by your comments, this is class is a wrapper over the actual write streams. Which makes me feel it is a final class (as in, the intention is not to specialize it.) You don't need to mark it final though.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122773/new/
https://reviews.llvm.org/D122773
More information about the libc-commits
mailing list