[all-commits] [llvm/llvm-project] 315dfe: [libc] Templatize strtointeger implementation. (#1...

Alexey Samsonov via All-commits all-commits at lists.llvm.org
Fri Oct 31 11:57:31 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 315dfe5865962d8a3d60e21d1fffce5214fe54ef
      https://github.com/llvm/llvm-project/commit/315dfe5865962d8a3d60e21d1fffce5214fe54ef
  Author: Alexey Samsonov <vonosmas at gmail.com>
  Date:   2025-10-31 (Fri, 31 Oct 2025)

  Changed paths:
    M libc/src/__support/CMakeLists.txt
    M libc/src/__support/str_to_integer.h
    R libc/src/__support/wcs_to_integer.h
    M libc/src/wchar/CMakeLists.txt
    M libc/src/wchar/wcstol.cpp
    M libc/src/wchar/wcstoll.cpp
    M libc/src/wchar/wcstoul.cpp
    M libc/src/wchar/wcstoull.cpp
    M libc/test/src/__support/CMakeLists.txt
    M libc/test/src/__support/str_to_integer_test.cpp
    M libc/test/src/__support/wcs_to_integer_test.cpp
    M utils/bazel/llvm-project-overlay/libc/BUILD.bazel

  Log Message:
  -----------
  [libc] Templatize strtointeger implementation. (#165884)

* Removes the copy-pasta implementation of wcstointeger,
  and migrate the wcsto* family of functions to use a template
  version of strtointeger.
* Fixes the out-of-bound read in the original implementation(s)
  when the entire input string consists of whitespaces
  (then the sign check can access OOB memory)

The code is currently slightly peppered with "if constexpr" statements
to distinguish between char and wchar_t. We can probably
simplify it in subsequent changes by:
* using overrides, so that internal::isalnum() is overriden for
  both char and wchar_t (since C++ luckily allows us to reuse names).
* this wouldn't help for direct comparison with literals -
for this as a somewhat ugly workaround like is_char_literal(c, '0',
L'0')



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list