mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
There are three flavors of WriteBuffer currently, all of which could be passed into `printf_core::Writer` class. It's a tricky class, since it chooses a flavor-specific logic either based on runtime dispatch (to save code size and prevent generating three versions of the entirety of printf_core), or based on template arguments (to avoid dealing with function pointers in codegen for `FILL_BUFF_AND_DROP_OVERFLOW` path). Refactor this somewhat convoluted logic to have three concrete subclasses inheriting from the templated base class, and use static polymorphism with `reinterpret_cast` to implement dispatching above. Now we can actually have flavor-specific fields, constructors, and methods (e.g. `flush_to_stream` is now a method of `FlushingBuffer`), and the code on the user side is cleaner: the complexity of enabling/disabling runtime-dispatch and using proper template arguments is now localized in `writer.h`. This code will need to be further templatized to support buffers of type `wchar_t` to implement `swprintf()` and friends. This change would make it (ever so slightly) easier.
LLVM libc ========= This directory and its subdirectories contain source code for llvm-libc, a retargetable implementation of the C standard library. LLVM is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.