[all-commits] [llvm/llvm-project] c309dc: [Clang][Sema] placement new initializes typedef ar...
mahtohappy via All-commits
all-commits at lists.llvm.org
Tue Apr 16 05:19:06 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c309dc6d0759b23b570c563f611530ff1a49e1bd
https://github.com/llvm/llvm-project/commit/c309dc6d0759b23b570c563f611530ff1a49e1bd
Author: mahtohappy <Happy.Kumar at Windriver.com>
Date: 2024-04-16 (Tue, 16 Apr 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/TreeTransform.h
A clang/test/SemaCXX/instantiate-new-placement-size.cpp
Log Message:
-----------
[Clang][Sema] placement new initializes typedef array with correct size (#83124)
When in-place new-ing a local variable of an array of trivial type, the
generated code calls 'memset' with the correct size of the array,
earlier it was generating size (squared of the typedef array + size).
The cause: `typedef TYPE TArray[8]; TArray x;` The type of declarator is
Tarray[8] and in `SemaExprCXX.cpp::BuildCXXNew` we check if it's of
typedef and of constant size then we get the original type and it works
fine for non-dependent cases.
But in case of template we do `TreeTransform.h:TransformCXXNEWExpr` and
there we again check the allocated type which is TArray[8] and it stays
that way, so ArraySize=(Tarray[8] type, alloc Tarray[8*type]) so the
squared size allocation.
ArraySize gets calculated earlier in `TreeTransform.h` so that
`if(!ArraySize)` condition was failing.
fix: I changed that condition to `if(ArraySize)`.
Fixes #41441
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