[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Thanks @vitalybuka for fixing the remain issues.
It has been about 2 days since this PR was merged and there is no other issue, 
I think we finally make sized deallocation default this time! Cheers!

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Thanks @vitalybuka! After some investigations, I think this PR just uncovered 
the existed ASAN problem.
```cpp
#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
#  define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION
#endif

#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && 
defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
#  define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
#endif

#if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || 
defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
#  define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
#endif

template 
_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t 
__size, _Args... __args) {
#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
  (void)__size;
  return std::__libcpp_operator_delete(__ptr, __args...);
#else
  return std::__libcpp_operator_delete(__ptr, __size, __args...);
#endif
}
```
The `__do_deallocate_handle_size` ignored the `__size` before this PR.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Internally ::allocate uses sided new:

```
 void*
allocate(size_t __bytes, size_t __alignment = _S_max_align)
__attribute__((__returns_nonnull__,__alloc_size__(2),__alloc_align__(3)))
{ return ::operator new(__bytes, do_allocate(__bytes, __alignment)); }

```

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> > > Based on my rough understanding, this is expected?
> > 
> > 
> > What do you mean?
> > Isn't this test needs to be updated or disabled?
> 
> I think this ASAN failure is not caused by this PR because these memorys are 
> allocated/deallocated by

100% sure by this PR
https://lab.llvm.org/buildbot/#/builders/168/builds/20461 only two patches on 
the blame list and the second one is unrelated for sure.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> > Based on my rough understanding, this is expected?
> 
> What do you mean?
> 
> Isn't this test needs to be updated or disabled?

I think this ASAN failure is not caused by this PR because these memorys are 
allocated/deallocated by `memory_resource` directly, **there is nothing about 
`new`/`delete`**. We allocate 50 bytes via `void* ret = r1.allocate(50);` and 
deallocate 1 byte via `r1.deallocate(ret, 1);` and that's the reason why ASAN 
failed, because the size of the allocated type (50 bytes) and the size of the 
deallocated type (1 byte) are really not matched.

I don't know if this is what we want to test, if so, we may add `// 
UNSUPPORTED: asan` to skip this test in ASAN builds.
cc @ldionne @Quuxplusone

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Based on my rough understanding, this is expected?

What do you mean?

Isn't this test needs to be updated or disabled?

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-22 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> This one is broken https://lab.llvm.org/buildbot/#/builders/168/builds/20461

The broken case is:
```cpp
void test_allocate_deallocate() {
  std::pmr::memory_resource& r1 = *std::pmr::new_delete_resource();

  globalMemCounter.reset();

  void* ret = r1.allocate(50);
  assert(ret);
  
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkOutstandingNewEq(1));
  
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeEq(50));

  r1.deallocate(ret, 1);
  assert(globalMemCounter.checkOutstandingNewEq(0));
  
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkDeleteCalledEq(1));
}
```
The errors are:
```
# .---command stderr
# | =
# | ==3452201==ERROR: AddressSanitizer: new-delete-type-mismatch on 
0x50600020 in thread T0:
# |   object passed to delete has wrong type:
# |   size of the allocated type:   50 bytes;
# |   size of the deallocated type: 1 bytes.
# | #0 0x565094abbd02  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14ad02)
# | #1 0x565094abe168  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14d168)
# | #2 0x565094abd941  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14c941)
# | #3 0x565094abda24  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14ca24)
# | #4 0x7f8643c2814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 
b20cbdb62d7717c13dc61a48b7b2e673a7edf233)
# | #5 0x7f8643c28208  (/lib/x86_64-linux-gnu/libc.so.6+0x28208) (BuildId: 
b20cbdb62d7717c13dc61a48b7b2e673a7edf233)
# | #6 0x5650949dbed4  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x6aed4)
# | 
# | 0x50600020 is located 0 bytes inside of 50-byte region 
[0x50600020,0x50600052)
# | allocated by thread T0 here:
# | #0 0x565094abb09d  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14a09d)
# | #1 0x565094abe098  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14d098)
# | #2 0x565094abd83f  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14c83f)
# | #3 0x565094abda24  
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14ca24)
# | #4 0x7f8643c2814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 
b20cbdb62d7717c13dc61a48b7b2e673a7edf233)
# | 
# | SUMMARY: AddressSanitizer: new-delete-type-mismatch 
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/test/std/utilities/utility/mem.res/mem.res.global/Output/new_delete_resource.pass.cpp.dir/t.tmp.exe+0x14ad02)
 
# | ==3452201==HINT: if you don't care about these errors you may set 
ASAN_OPTIONS=new_delete_type_mismatch=0
# | ==3452201==ABORTING
# `-
# error: command failed with exit status: 1
```

Based on my rough understanding, this is expected? Because we allocate 50 bytes 
via `void* ret = r1.allocate(50);` and deallocate 1 byte via 
`r1.deallocate(ret, 1);`.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-22 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This one is broken https://lab.llvm.org/buildbot/#/builders/168/builds/20461

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-21 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp closed 
https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-21 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/90373

>From a18f57e23c0d4fd23647eb2ef610352e402b45f6 Mon Sep 17 00:00:00 2001
From: Pengcheng Wang 
Date: Fri, 26 Apr 2024 16:59:12 +0800
Subject: [PATCH] [clang] Enable sized deallocation by default in C++14 onwards

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061
---
 .../clangd/unittests/FindTargetTests.cpp  |   4 +-
 .../checkers/misc/new-delete-overloads.cpp|  10 -
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/Driver/Options.td |   8 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  58 -
 clang/lib/Driver/ToolChains/Darwin.h  |   4 +
 clang/lib/Driver/ToolChains/ZOS.cpp   |   6 +
 clang/test/AST/ast-dump-expr-json.cpp |   2 +-
 clang/test/AST/ast-dump-expr.cpp  |   2 +-
 clang/test/AST/ast-dump-stmt-json.cpp | 244 +-
 clang/test/Analysis/cxxnewexpr-callback.cpp   |   4 +-
 .../basic.stc.dynamic.deallocation/p2.cpp |   2 +-
 clang/test/CXX/drs/cwg292.cpp |  17 +-
 .../test/CXX/expr/expr.unary/expr.new/p14.cpp |   2 +-
 .../CodeGenCXX/cxx1y-sized-deallocation.cpp   |  10 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   |   6 +-
 .../CodeGenCXX/cxx2a-destroying-delete.cpp|   4 +-
 clang/test/CodeGenCXX/delete-two-arg.cpp  |   4 +-
 clang/test/CodeGenCXX/delete.cpp  |  12 +-
 clang/test/CodeGenCXX/dllimport.cpp   |   4 +-
 clang/test/CodeGenCXX/new.cpp |   6 +-
 .../coro-aligned-alloc-2.cpp  |   2 -
 .../CodeGenCoroutines/coro-aligned-alloc.cpp  |   6 +-
 clang/test/CodeGenCoroutines/coro-alloc.cpp   |   6 +-
 clang/test/CodeGenCoroutines/coro-cleanup.cpp |   6 +-
 clang/test/CodeGenCoroutines/coro-dealloc.cpp |   2 -
 clang/test/CodeGenCoroutines/coro-gro.cpp |   3 +-
 clang/test/CodeGenCoroutines/pr56919.cpp  |   9 +-
 clang/test/Lexer/cxx-features.cpp |  20 +-
 clang/test/PCH/cxx1z-aligned-alloc.cpp|  10 +-
 clang/test/SemaCXX/MicrosoftExtensions.cpp|   8 +-
 .../SemaCXX/builtin-operator-new-delete.cpp   |   2 +-
 .../test/SemaCXX/cxx1y-sized-deallocation.cpp |   2 +-
 .../unavailable_aligned_allocation.cpp|  15 +-
 clang/tools/clang-repl/CMakeLists.txt |  43 +++
 clang/unittests/Interpreter/CMakeLists.txt|  43 +++
 .../StaticAnalyzer/CallEventTest.cpp  |   2 +-
 clang/www/cxx_status.html |  11 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  |   3 +
 .../sized_delete_array14.pass.cpp |   8 +-
 .../new.delete.single/sized_delete14.pass.cpp |   8 +-
 42 files changed, 523 insertions(+), 113 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 0b2273f0a9a6e..3220a5a6a9825 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -836,7 +836,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e1..f86fe8a4c5b14 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  // placement operations.
-  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
-  void *operator new(size_t size) noexcept;
-  void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
-};
-
 struct U {
   void *operator new(size_t size) noexcept;
   void operator delete(void *ptr) 

[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-21 Thread Louis Dionne via cfe-commits

https://github.com/ldionne approved this pull request.

Let's try this again. Thanks for your perseverance, this is obviously not easy 
to land but it's important to get it done. Let's hope everything has been 
addressed this time around.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-21 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Please review this PR as all noticable issues have been fixed I think.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-21 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/90373

>From fd015302585fc8149811868636cb0da5c422cf7a Mon Sep 17 00:00:00 2001
From: Pengcheng Wang 
Date: Fri, 26 Apr 2024 16:59:12 +0800
Subject: [PATCH] [clang] Enable sized deallocation by default in C++14 onwards

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061
---
 .../clangd/unittests/FindTargetTests.cpp  |   4 +-
 .../checkers/misc/new-delete-overloads.cpp|  10 -
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/Driver/Options.td |   8 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  58 -
 clang/lib/Driver/ToolChains/Darwin.h  |   4 +
 clang/lib/Driver/ToolChains/ZOS.cpp   |   6 +
 clang/test/AST/ast-dump-expr-json.cpp |   2 +-
 clang/test/AST/ast-dump-expr.cpp  |   2 +-
 clang/test/AST/ast-dump-stmt-json.cpp | 244 +-
 clang/test/Analysis/cxxnewexpr-callback.cpp   |   4 +-
 .../basic.stc.dynamic.deallocation/p2.cpp |   2 +-
 clang/test/CXX/drs/cwg292.cpp |  17 +-
 .../test/CXX/expr/expr.unary/expr.new/p14.cpp |   2 +-
 .../CodeGenCXX/cxx1y-sized-deallocation.cpp   |  10 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   |   6 +-
 .../CodeGenCXX/cxx2a-destroying-delete.cpp|   4 +-
 clang/test/CodeGenCXX/delete-two-arg.cpp  |   4 +-
 clang/test/CodeGenCXX/delete.cpp  |  12 +-
 clang/test/CodeGenCXX/dllimport.cpp   |   4 +-
 clang/test/CodeGenCXX/new.cpp |   6 +-
 .../coro-aligned-alloc-2.cpp  |   2 -
 .../CodeGenCoroutines/coro-aligned-alloc.cpp  |   6 +-
 clang/test/CodeGenCoroutines/coro-alloc.cpp   |   6 +-
 clang/test/CodeGenCoroutines/coro-cleanup.cpp |   6 +-
 clang/test/CodeGenCoroutines/coro-dealloc.cpp |   2 -
 clang/test/CodeGenCoroutines/coro-gro.cpp |   3 +-
 clang/test/CodeGenCoroutines/pr56919.cpp  |   9 +-
 clang/test/Lexer/cxx-features.cpp |  20 +-
 clang/test/PCH/cxx1z-aligned-alloc.cpp|  10 +-
 clang/test/SemaCXX/MicrosoftExtensions.cpp|   8 +-
 .../SemaCXX/builtin-operator-new-delete.cpp   |   2 +-
 .../test/SemaCXX/cxx1y-sized-deallocation.cpp |   2 +-
 .../unavailable_aligned_allocation.cpp|  15 +-
 clang/tools/clang-repl/CMakeLists.txt |  43 +++
 clang/unittests/Interpreter/CMakeLists.txt|  43 +++
 .../StaticAnalyzer/CallEventTest.cpp  |   2 +-
 clang/www/cxx_status.html |  11 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  |   3 +
 .../sized_delete_array14.pass.cpp |   8 +-
 .../new.delete.single/sized_delete14.pass.cpp |   8 +-
 42 files changed, 523 insertions(+), 113 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 0b2273f0a9a6e..3220a5a6a9825 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -836,7 +836,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e1..f86fe8a4c5b14 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  // placement operations.
-  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
-  void *operator new(size_t size) noexcept;
-  void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
-};
-
 struct U {
   void *operator new(size_t size) noexcept;
   void operator delete(void *ptr) 

[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-30 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Thanks a lot, that was quick! There is another AddressSanitizer issue that 
> may possibly be fixed by #90292. cc @vitalybuka

Yes, please wait for #90292.


https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-28 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> > > @dyung Can you help me to comfirm whether the Windows builder is passing 
> > > now? I don't have such environment. Thanks in advance!
> > 
> > 
> > Sure, I'll try it on our internal builder and see if it passes and let you 
> > know the result.
> 
> I can confirm that this change builds successfully on our Windows 
> configuration.

Thanks a lot, that was quick!
There is another AddressSanitizer issue that may possibly be fixed by 
https://github.com/llvm/llvm-project/pull/90292. cc @vitalybuka

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-28 Thread via cfe-commits

dyung wrote:

> > @dyung Can you help me to comfirm whether the Windows builder is passing 
> > now? I don't have such environment. Thanks in advance!
> 
> Sure, I'll try it on our internal builder and see if it passes and let you 
> know the result.

I can confirm that this change builds successfully on our Windows configuration.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-27 Thread via cfe-commits

dyung wrote:

> @dyung Can you help me to comfirm whether the Windows builder is passing now? 
> I don't have such environment. Thanks in advance!

Sure, I'll try it on our internal builder and see if it passes and let you know 
the result.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-27 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

@dyung Can you help me to comfirm whether the Windows builder is passing now? I 
don't have such environment. Thanks in advance!

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Pengcheng Wang (wangpc-pp)


Changes

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061


---

Patch is 56.61 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/90373.diff


42 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+3-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp (-10) 
- (modified) clang/docs/ReleaseNotes.rst (+5) 
- (modified) clang/include/clang/Driver/Options.td (+4-4) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+9-4) 
- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+55-3) 
- (modified) clang/lib/Driver/ToolChains/Darwin.h (+4) 
- (modified) clang/lib/Driver/ToolChains/ZOS.cpp (+6) 
- (modified) clang/test/AST/ast-dump-expr-json.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-expr.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-stmt-json.cpp (+241-3) 
- (modified) clang/test/Analysis/cxxnewexpr-callback.cpp (+2-2) 
- (modified) 
clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
 (+1-1) 
- (modified) clang/test/CXX/drs/cwg292.cpp (+9-8) 
- (modified) clang/test/CXX/expr/expr.unary/expr.new/p14.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp (+5-5) 
- (modified) clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp (+3-3) 
- (modified) clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/delete-two-arg.cpp (+3-1) 
- (modified) clang/test/CodeGenCXX/delete.cpp (+7-5) 
- (modified) clang/test/CodeGenCXX/dllimport.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/new.cpp (+3-3) 
- (modified) clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp (-2) 
- (modified) clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-alloc.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-cleanup.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-dealloc.cpp (-2) 
- (modified) clang/test/CodeGenCoroutines/coro-gro.cpp (+2-1) 
- (modified) clang/test/CodeGenCoroutines/pr56919.cpp (+6-3) 
- (modified) clang/test/Lexer/cxx-features.cpp (+10-10) 
- (modified) clang/test/PCH/cxx1z-aligned-alloc.cpp (+5-5) 
- (modified) clang/test/SemaCXX/MicrosoftExtensions.cpp (+7-1) 
- (modified) clang/test/SemaCXX/builtin-operator-new-delete.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx1y-sized-deallocation.cpp (+1-1) 
- (modified) clang/test/SemaCXX/unavailable_aligned_allocation.cpp (+9-6) 
- (modified) clang/tools/clang-repl/CMakeLists.txt (+43) 
- (modified) clang/unittests/Interpreter/CMakeLists.txt (+43) 
- (modified) clang/unittests/StaticAnalyzer/CallEventTest.cpp (+1-1) 
- (modified) clang/www/cxx_status.html (+5-6) 
- (modified) 
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp 
(+3) 
- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
 (+4-4) 
- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
 (+4-4) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..88aae2729904f4 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,7 +839,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e19..f86fe8a4c5b14f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  

[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-27 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-libcxx

Author: Pengcheng Wang (wangpc-pp)


Changes

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061


---

Patch is 56.61 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/90373.diff


42 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+3-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp (-10) 
- (modified) clang/docs/ReleaseNotes.rst (+5) 
- (modified) clang/include/clang/Driver/Options.td (+4-4) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+9-4) 
- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+55-3) 
- (modified) clang/lib/Driver/ToolChains/Darwin.h (+4) 
- (modified) clang/lib/Driver/ToolChains/ZOS.cpp (+6) 
- (modified) clang/test/AST/ast-dump-expr-json.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-expr.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-stmt-json.cpp (+241-3) 
- (modified) clang/test/Analysis/cxxnewexpr-callback.cpp (+2-2) 
- (modified) 
clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
 (+1-1) 
- (modified) clang/test/CXX/drs/cwg292.cpp (+9-8) 
- (modified) clang/test/CXX/expr/expr.unary/expr.new/p14.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp (+5-5) 
- (modified) clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp (+3-3) 
- (modified) clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/delete-two-arg.cpp (+3-1) 
- (modified) clang/test/CodeGenCXX/delete.cpp (+7-5) 
- (modified) clang/test/CodeGenCXX/dllimport.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/new.cpp (+3-3) 
- (modified) clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp (-2) 
- (modified) clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-alloc.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-cleanup.cpp (+4-2) 
- (modified) clang/test/CodeGenCoroutines/coro-dealloc.cpp (-2) 
- (modified) clang/test/CodeGenCoroutines/coro-gro.cpp (+2-1) 
- (modified) clang/test/CodeGenCoroutines/pr56919.cpp (+6-3) 
- (modified) clang/test/Lexer/cxx-features.cpp (+10-10) 
- (modified) clang/test/PCH/cxx1z-aligned-alloc.cpp (+5-5) 
- (modified) clang/test/SemaCXX/MicrosoftExtensions.cpp (+7-1) 
- (modified) clang/test/SemaCXX/builtin-operator-new-delete.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx1y-sized-deallocation.cpp (+1-1) 
- (modified) clang/test/SemaCXX/unavailable_aligned_allocation.cpp (+9-6) 
- (modified) clang/tools/clang-repl/CMakeLists.txt (+43) 
- (modified) clang/unittests/Interpreter/CMakeLists.txt (+43) 
- (modified) clang/unittests/StaticAnalyzer/CallEventTest.cpp (+1-1) 
- (modified) clang/www/cxx_status.html (+5-6) 
- (modified) 
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp 
(+3) 
- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
 (+4-4) 
- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
 (+4-4) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..88aae2729904f4 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,7 +839,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e19..f86fe8a4c5b14f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do 

[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-27 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/90373

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061


>From cc722438155619cb0524eb26191be0465ccddbf0 Mon Sep 17 00:00:00 2001
From: Pengcheng Wang 
Date: Fri, 26 Apr 2024 16:59:12 +0800
Subject: [PATCH] [clang] Enable sized deallocation by default in C++14 onwards

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061
---
 .../clangd/unittests/FindTargetTests.cpp  |   4 +-
 .../checkers/misc/new-delete-overloads.cpp|  10 -
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/Driver/Options.td |   8 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  58 -
 clang/lib/Driver/ToolChains/Darwin.h  |   4 +
 clang/lib/Driver/ToolChains/ZOS.cpp   |   6 +
 clang/test/AST/ast-dump-expr-json.cpp |   2 +-
 clang/test/AST/ast-dump-expr.cpp  |   2 +-
 clang/test/AST/ast-dump-stmt-json.cpp | 244 +-
 clang/test/Analysis/cxxnewexpr-callback.cpp   |   4 +-
 .../basic.stc.dynamic.deallocation/p2.cpp |   2 +-
 clang/test/CXX/drs/cwg292.cpp |  17 +-
 .../test/CXX/expr/expr.unary/expr.new/p14.cpp |   2 +-
 .../CodeGenCXX/cxx1y-sized-deallocation.cpp   |  10 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   |   6 +-
 .../CodeGenCXX/cxx2a-destroying-delete.cpp|   4 +-
 clang/test/CodeGenCXX/delete-two-arg.cpp  |   4 +-
 clang/test/CodeGenCXX/delete.cpp  |  12 +-
 clang/test/CodeGenCXX/dllimport.cpp   |   4 +-
 clang/test/CodeGenCXX/new.cpp |   6 +-
 .../coro-aligned-alloc-2.cpp  |   2 -
 .../CodeGenCoroutines/coro-aligned-alloc.cpp  |   6 +-
 clang/test/CodeGenCoroutines/coro-alloc.cpp   |   6 +-
 clang/test/CodeGenCoroutines/coro-cleanup.cpp |   6 +-
 clang/test/CodeGenCoroutines/coro-dealloc.cpp |   2 -
 clang/test/CodeGenCoroutines/coro-gro.cpp |   3 +-
 clang/test/CodeGenCoroutines/pr56919.cpp  |   9 +-
 clang/test/Lexer/cxx-features.cpp |  20 +-
 clang/test/PCH/cxx1z-aligned-alloc.cpp|  10 +-
 clang/test/SemaCXX/MicrosoftExtensions.cpp|   8 +-
 .../SemaCXX/builtin-operator-new-delete.cpp   |   2 +-
 .../test/SemaCXX/cxx1y-sized-deallocation.cpp |   2 +-
 .../unavailable_aligned_allocation.cpp|  15 +-
 clang/tools/clang-repl/CMakeLists.txt |  43 +++
 clang/unittests/Interpreter/CMakeLists.txt|  43 +++
 .../StaticAnalyzer/CallEventTest.cpp  |   2 +-
 clang/www/cxx_status.html |  11 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  |   3 +
 .../sized_delete_array14.pass.cpp |   8 +-
 .../new.delete.single/sized_delete14.pass.cpp |   8 +-
 42 files changed, 523 insertions(+), 113 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..88aae2729904f4 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,7 +839,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e19..f86fe8a4c5b14f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  // placement operations.
-  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: