[all-commits] [llvm/llvm-project] 45ab2b: [Clang] Improve the handling of large arrays evalu...

cor3ntin via All-commits all-commits at lists.llvm.org
Fri Jul 28 05:38:37 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 45ab2b48bd55e50a86f6026ed31d2b60a118bdce
      https://github.com/llvm/llvm-project/commit/45ab2b48bd55e50a86f6026ed31d2b60a118bdce
  Author: Corentin Jabot <corentinjabot at gmail.com>
  Date:   2023-07-28 (Fri, 28 Jul 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/docs/UsersManual.rst
    M clang/include/clang/AST/Type.h
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/AST/Type.cpp
    A clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp

  Log Message:
  -----------
  [Clang] Improve the handling of large arrays evaluation.

This is a temporary fix (for clang 17) that caps the size of
any array we try to constant evaluate:

    There are 2 limits:
      * We cap to UINT_MAX the size of ant constant evaluated array,
        because the constant evaluator does not support size_t.
      * We cap to `-fconstexpr-steps` elements the size of each individual
        array and dynamic array allocations.
        This works out because the number of constexpr steps already limits
        how many array elements can be initialized, which makes this new
        limit conservatively generous.
        This ensure that the compiler does not crash when attempting to
        constant-fold valid programs.

    If the limit is reached by a given array, constant evaluation will fail,
    and the program will be ill-formed, until a bigger limit is given.
    Or, constant folding will fail and the array will be evaluated at runtime.

    Fixes #63562

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D155955




More information about the All-commits mailing list