[all-commits] [llvm/llvm-project] 74cab5: Reapply "[Clang][Sema] placement new initializes t...
mahtohappy via All-commits
all-commits at lists.llvm.org
Tue Apr 23 07:37:29 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 74cab546825b32f24e44d69942cdbdd129160471
https://github.com/llvm/llvm-project/commit/74cab546825b32f24e44d69942cdbdd129160471
Author: mahtohappy <Happy.Kumar at Windriver.com>
Date: 2024-04-23 (Tue, 23 Apr 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/TreeTransform.h
M clang/lib/Serialization/ASTWriter.cpp
A clang/test/SemaCXX/PR41441.cpp
Log Message:
-----------
Reapply "[Clang][Sema] placement new initializes typedef array with correct size (#83124)" (#89036)
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 https://github.com/llvm/llvm-project/issues/41441
---------
Co-authored-by: erichkeane <ekeane at nvidia.com>
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