[libc-commits] [PATCH] D155902: [wip][libc] Overload integer_to_string methods for fixed size buffers

Jon Chesterfield via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 20 17:08:17 PDT 2023


JonChesterfield created this revision.
JonChesterfield added reviewers: jhuber6, sivachandra, gchatelet, michaelrj, abrachet.
Herald added subscribers: libc-commits, tpr.
Herald added projects: libc-project, All.
JonChesterfield requested review of this revision.

Existing integer_to_string methods return an optional<view>.
In the common case for a perfectly sized buffer, we can return a view.

WIP because I haven't built it for non-amdgpu yet and the wider than T
test is appending a spurious zero at present so some test cases fail.

The wider-than-T hex case has a comment for an invariant, planning to
make that a compile time fault as part of this.

Posting in WIP state as a sanity check that exact overloads are acceptable
The char (&buffer) [N] is for fixed size buffer of unknown contents, it 
might be possible to detect a constexpr size string view. Ideas welcome.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155902

Files:
  libc/src/__support/CPP/string.h
  libc/src/__support/CPP/stringstream.h
  libc/src/__support/integer_to_string.h
  libc/src/__support/libc_assert.h
  libc/src/stdio/printf_core/float_dec_converter.h
  libc/test/UnitTest/LibcTest.cpp
  libc/test/UnitTest/TestLogger.cpp
  libc/test/src/__support/integer_to_string_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155902.542725.patch
Type: text/x-patch
Size: 16308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230721/3867fa53/attachment-0001.bin>


More information about the libc-commits mailing list