[clang] e1321fa - Revert "Reapply "[Clang][Sema] placement new initializes typedef array with correct size (#83124)" (#89036)"
Pranav Kant via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 15:09:12 PDT 2024
Author: Pranav Kant
Date: 2024-04-23T22:08:50Z
New Revision: e1321fafbc024007023ce5d9b88d987a920c3bca
URL: https://github.com/llvm/llvm-project/commit/e1321fafbc024007023ce5d9b88d987a920c3bca
DIFF: https://github.com/llvm/llvm-project/commit/e1321fafbc024007023ce5d9b88d987a920c3bca.diff
LOG: Revert "Reapply "[Clang][Sema] placement new initializes typedef array with correct size (#83124)" (#89036)"
This reverts commit 74cab546825b32f24e44d69942cdbdd129160471.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTWriter.cpp
Removed:
clang/test/SemaCXX/PR41441.cpp
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d1f7293a842bb6..3db558a1c11a3f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -557,7 +557,6 @@ Bug Fixes to C++ Support
- Fix a crash in requires expression with templated base class member function. Fixes (#GH84020).
- Fix a crash caused by defined struct in a type alias template when the structure
has fields with dependent type. Fixes (#GH75221).
-- Fix placement new initializes typedef array with correct size. Fixes (#GH41441).
- Fix the Itanium mangling of lambdas defined in a member of a local class (#GH88906)
- Fixed a crash when trying to evaluate a user-defined ``static_assert`` message whose ``size()``
function returns a large or negative value. Fixes (#GH89407).
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 539a18eb92a7ce..9404be5a46f3f7 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12943,19 +12943,6 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
ArraySize = NewArraySize.get();
}
- // Per C++0x [expr.new]p5, the type being constructed may be a
- // typedef of an array type.
- QualType AllocType = AllocTypeInfo->getType();
- if (ArraySize && E->isTypeDependent()) {
- if (const ConstantArrayType *Array =
- SemaRef.Context.getAsConstantArrayType(AllocType)) {
- ArraySize = IntegerLiteral::Create(SemaRef.Context, Array->getSize(),
- SemaRef.Context.getSizeType(),
- E->getBeginLoc());
- AllocType = Array->getElementType();
- }
- }
-
// Transform the placement arguments (if any).
bool ArgumentChanged = false;
SmallVector<Expr*, 8> PlacementArgs;
@@ -13017,6 +13004,7 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
return E;
}
+ QualType AllocType = AllocTypeInfo->getType();
if (!ArraySize) {
// If no array size was specified, but the new expression was
// instantiated with an array type (e.g., "new T" where T is
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 21cf72ab0f9121..a1b340b252fb08 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5097,7 +5097,7 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
DeclsToCheckForDeferredDiags.push_back(getDeclID(D));
if (!DeclsToCheckForDeferredDiags.empty())
Stream.EmitRecord(DECLS_TO_CHECK_FOR_DEFERRED_DIAGS,
- DeclsToCheckForDeferredDiags);
+ DeclsToCheckForDeferredDiags);
// Write the record containing CUDA-specific declaration references.
RecordData CUDASpecialDeclRefs;
diff --git a/clang/test/SemaCXX/PR41441.cpp b/clang/test/SemaCXX/PR41441.cpp
deleted file mode 100644
index 3f60b6e209207a..00000000000000
--- a/clang/test/SemaCXX/PR41441.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-
-namespace std {
- using size_t = decltype(sizeof(int));
-};
-void* operator new[](std::size_t, void*) noexcept;
-
-// CHECK: call void @llvm.memset.p0.i64(ptr align 1 %x, i8 0, i64 8, i1 false)
-// CHECK: call void @llvm.memset.p0.i64(ptr align 16 %x, i8 0, i64 32, i1 false)
-template <typename TYPE>
-void f()
-{
- typedef TYPE TArray[8];
-
- TArray x;
- new(&x) TArray();
-}
-
-template <typename T>
-void f1() {
- int (*x)[1] = new int[1][1];
-}
-template void f1<char>();
-void f2() {
- int (*x)[1] = new int[1][1];
-}
-
-int main()
-{
- f<char>();
- f<int>();
-}
More information about the cfe-commits
mailing list