[PATCH] D155955: [Clang] Improve the handling of large arrays evaluation.

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 07:12:02 PDT 2023


cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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 100MB the size of allocations made during constant folding and other non-mandated constant evaluations so that we reduce the risk of crashing when compiling programs that are valid. Constant folding may still happen in the backend otherwise the code will be runtime evaluated.

  The 100MB linit is a bit arbitrary, but it seems like something that would be readily available on any system compiling a non trivial c++ program.

Fixes #63562


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155955

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Type.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155955.542904.patch
Type: text/x-patch
Size: 9055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230721/f1c05b6b/attachment-0001.bin>


More information about the cfe-commits mailing list