[PATCH] D112659: Add a limit to __make_integer_seq builtin.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 27 13:27:58 PDT 2021


erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, majnemer, EricWF.
Herald added subscribers: dexonsmith, dang.
erichkeane requested review of this revision.

As brought up in PR48246, passing a large value to `__make_integer_seq`
results in the compiler getting stuck in a large loop and potentially
crashing if it runs out of memory as a result.

This patch puts a command-line configurable limit in place to limit the
size to something reasonable.

I chose 2^24 as default after a brief experimentation with the debug compiler,
which made it take a few minutes.  On a release build, a program with a 2^24
value takes roughly 30 seconds, and uses about 3.3GB of ram.


https://reviews.llvm.org/D112659

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/make_integer_seq.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112659.382768.patch
Type: text/x-patch
Size: 5695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211027/d34ce9c5/attachment.bin>


More information about the cfe-commits mailing list