[all-commits] [llvm/llvm-project] 120689: [libc] Migrate ctype_utils to use char instead of ...

Alexey Samsonov via All-commits all-commits at lists.llvm.org
Wed Nov 5 11:02:50 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 120689e46679c6db37cd9e839ec0721e80a22d4f
      https://github.com/llvm/llvm-project/commit/120689e46679c6db37cd9e839ec0721e80a22d4f
  Author: Alexey Samsonov <vonosmas at gmail.com>
  Date:   2025-11-05 (Wed, 05 Nov 2025)

  Changed paths:
    M libc/src/__support/ctype_utils.h
    M libc/src/__support/integer_to_string.h
    M libc/src/ctype/CMakeLists.txt
    M libc/src/ctype/isalnum.cpp
    M libc/src/ctype/isalnum_l.cpp
    M libc/src/ctype/isalpha.cpp
    M libc/src/ctype/isalpha_l.cpp
    M libc/src/ctype/isdigit.cpp
    M libc/src/ctype/isdigit_l.cpp
    M libc/src/ctype/isgraph.cpp
    M libc/src/ctype/isgraph_l.cpp
    M libc/src/ctype/islower.cpp
    M libc/src/ctype/islower_l.cpp
    M libc/src/ctype/ispunct.cpp
    M libc/src/ctype/ispunct_l.cpp
    M libc/src/ctype/isspace.cpp
    M libc/src/ctype/isspace_l.cpp
    M libc/src/ctype/isupper.cpp
    M libc/src/ctype/isupper_l.cpp
    M libc/src/ctype/isxdigit.cpp
    M libc/src/ctype/isxdigit_l.cpp
    M libc/src/ctype/tolower.cpp
    M libc/src/ctype/tolower_l.cpp
    M libc/src/ctype/toupper.cpp
    M libc/src/ctype/toupper_l.cpp
    M libc/src/stdio/printf_core/float_dec_converter_limited.h
    M libc/src/stdio/printf_core/float_hex_converter.h
    M libc/src/stdlib/l64a.cpp
    M libc/src/string/strcasestr.cpp
    M libc/src/strings/strcasecmp.cpp
    M libc/src/strings/strcasecmp_l.cpp
    M libc/src/strings/strncasecmp.cpp
    M libc/src/strings/strncasecmp_l.cpp
    M libc/test/UnitTest/MemoryMatcher.cpp
    M libc/test/src/ctype/islower_test.cpp
    M libc/test/src/stdlib/StrtolTest.h
    M utils/bazel/llvm-project-overlay/libc/BUILD.bazel

  Log Message:
  -----------
  [libc] Migrate ctype_utils to use char instead of int where applicable. (#166225)

Functions like isalpha / tolower can operate on chars internally. This
allows us to get rid of unnecessary casts and open a way to creating
wchar_t overloads with the same names (e.g. for isalpha), that would
simplify templated code for conversion functions (see
315dfe5865962d8a3d60e21d1fffce5214fe54ef).

Add the int->char converstion to public entrypoints implementation
instead. We also need to introduce bounds check on the input argument
values - these functions' behavior is unspecified if the argument is
neither EOF nor fits in "unsigned char" range, but the tests we've had
verified that they always return false for small negative values. To
preserve this behavior, cover it explicitly.



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