diff options
author | Adam Czachorowski <adamcz@google.com> | 2021-11-03 13:24:39 +0100 |
---|---|---|
committer | Adam Czachorowski <adamcz@google.com> | 2021-11-10 18:11:21 +0100 |
commit | 48bb5f4cbe8d5951c1153e469dc6713a122b7fa3 (patch) | |
tree | 828389a0e2f9026409ca49f4a1752aac4ca4919e /lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h | |
parent | e64c76672f5c50d28298222047b3678ee5b2f251 (diff) | |
download | llvm-48bb5f4cbe8d5951c1153e469dc6713a122b7fa3.zip llvm-48bb5f4cbe8d5951c1153e469dc6713a122b7fa3.tar.gz llvm-48bb5f4cbe8d5951c1153e469dc6713a122b7fa3.tar.bz2 |
[clang] Add early exit when checking for const init of arrays.
Before this commit, on code like:
struct S { ... };
S arr[10000000];
while checking if arr is constexpr, clang would reserve memory for
arr before running constructor for S. If S turned out to not have a
valid constexpr c-tor, clang would still try to initialize each element
(and, in case the c-tor was trivial, even skipping the constexpr step
limit), only to discard that whole APValue later, since the first
element generated a diagnostic.
With this change, we start by allocating just 1 element in the array to
try out the c-tor and take an early exit if any diagnostics are
generated, avoiding possibly large memory allocation and a lot of work
initializing to-be-discarded APValues.
Fixes 51712 and 51843.
In the future we may want to be smarter about large possibly-constexrp
arrays and maybe make the allocation lazy.
Differential Revision: https://reviews.llvm.org/D113120
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h')
0 files changed, 0 insertions, 0 deletions