[all-commits] [llvm/llvm-project] 332ac1: [clang] constexpr built-in abs function. (#112539)

c8ef via All-commits all-commits at lists.llvm.org
Fri Oct 18 04:04:12 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 332ac18e318ce0b6bf316d7f35d33d8af4c56fc5
      https://github.com/llvm/llvm-project/commit/332ac18e318ce0b6bf316d7f35d33d8af4c56fc5
  Author: c8ef <c8ef at outlook.com>
  Date:   2024-10-18 (Fri, 18 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/Builtins.td
    M clang/lib/AST/ByteCode/InterpBuiltin.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/test/AST/ByteCode/builtin-functions.cpp
    M clang/test/CodeGenCXX/builtins.cpp
    M clang/test/Sema/constant-builtins-2.c

  Log Message:
  -----------
  [clang] constexpr built-in abs function. (#112539)

According to [P0533R9](https://wg21.link/P0533R9), the C++ standard
library functions corresponding to the C macros in `[c.math.abs]` are
now `constexpr`.

To implement this feature in libc++, we must make the built-in abs
function `constexpr`. This patch adds the implementation of a
`constexpr` abs function for the current constant evaluator and the new
bytecode interpreter.

It is important to note that in 2's complement systems, the absolute
value of the most negative value is out of range. In gcc, it will result
in an out-of-range error and will not be evaluated as constants. We
follow the same approach here.



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