[all-commits] [llvm/llvm-project] 51d1c7: [libc] Added support for fixed-points in ``is_sign...

Abhinav Kumar via All-commits all-commits at lists.llvm.org
Wed Apr 2 13:42:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 51d1c7288662ea801b07133fd2d22aff6bac50e2
      https://github.com/llvm/llvm-project/commit/51d1c7288662ea801b07133fd2d22aff6bac50e2
  Author: Abhinav Kumar <96587705+kr-2003 at users.noreply.github.com>
  Date:   2025-04-02 (Wed, 02 Apr 2025)

  Changed paths:
    M libc/src/__support/CPP/type_traits/is_signed.h
    M libc/src/__support/CPP/type_traits/is_unsigned.h
    M libc/test/src/__support/CPP/type_traits_test.cpp

  Log Message:
  -----------
  [libc] Added support for fixed-points in ``is_signed`` and ``is_unsigned``. (#133371)

Fixes #133365

## Changes Done
- Changed the signed checking to 
```cpp
struct is_signed : bool_constant<((is_fixed_point<T> || is_arithmetic_v<T>) && (T(-1) < T(0)))>
```
in ``/libc/src/__support/CPP/type_traits/is_signed.h``. Added check for
fixed-points.
- But, got to know that this will fail for ``unsigned _Fract`` or any
unsigned fixed-point because ``unsigned _Fract`` can’t represent -1 in
T(-1), while ``unsigned int`` can handle it via wrapping.
- That's why I explicity added ``is_signed`` check for ``unsigned``
fixed-points.
- Same changes to ``/libc/src/__support/CPP/type_traits/is_unsigned.h``.
- Added tests for ``is_signed`` and ``is_unsigned``.



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