Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Differential D112921 Diff 423555 clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
// RUN: %check_clang_tidy %s misc-new-delete-overloads %t | // RUN: %check_clang_tidy %s misc-new-delete-overloads %t | ||||
typedef decltype(sizeof(int)) size_t; | typedef decltype(sizeof(int)) size_t; | ||||
struct S { | struct S { | ||||
// CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope [misc-new-delete-overloads] | // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope [misc-new-delete-overloads] | ||||
void *operator new(size_t size) noexcept; | void *operator new(size_t size) noexcept; | ||||
// CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new[]' has no matching declaration of 'operator delete[]' at the same scope | // 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 new[](size_t size) noexcept; | ||||
}; | }; | ||||
// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope | // 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); | void *operator new(size_t size) noexcept(false); | ||||
struct T { | struct T { | ||||
// Sized deallocations are not enabled by default, and so this new/delete pair | // Sized deallocations are enabled by default, and so this new/delete pair | ||||
// does not match. However, we expect only one warning, for the new, because | // 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 | // the operator delete is a placement delete and we do not warn on mismatching | ||||
// placement operations. | // placement operations. | ||||
// CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope | // 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 new(size_t size) noexcept; | ||||
void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled | void operator delete(void *ptr) noexcept; | ||||
}; | }; | ||||
struct U { | struct U { | ||||
void *operator new(size_t size) noexcept; | void *operator new(size_t size) noexcept; | ||||
void operator delete(void *ptr) noexcept; | void operator delete(void *ptr) noexcept; | ||||
void *operator new[](size_t) noexcept; | void *operator new[](size_t) noexcept; | ||||
void operator delete[](void *) noexcept; | void operator delete[](void *) noexcept; | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |