Files
TheRock/compiler/amd-llvm/clang-tools-extra/test/clang-tidy/checkers/performance/trivially-destructible.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

85 lines
3.3 KiB
C++

// RUN: %check_clang_tidy %s performance-trivially-destructible %t
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -fix --
// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -warnings-as-errors='-*,performance-trivially-destructible' --
struct TriviallyDestructible1 {
int a;
};
struct TriviallyDestructible2 : TriviallyDestructible1 {
~TriviallyDestructible2() = default;
TriviallyDestructible1 b;
};
struct NotTriviallyDestructible1 : TriviallyDestructible2 {
~NotTriviallyDestructible1();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'NotTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
// CHECK-FIXES: ~NotTriviallyDestructible1() = default;
TriviallyDestructible2 b;
};
NotTriviallyDestructible1::~NotTriviallyDestructible1() = default; // to-be-removed
// CHECK-MESSAGES: :[[@LINE-1]]:28: note: destructor definition is here
// CHECK-FIXES: // to-be-removed
// Don't emit for class template with type-dependent fields.
template <class T>
struct MaybeTriviallyDestructible1 {
~MaybeTriviallyDestructible1() noexcept;
T t;
};
template <class T>
MaybeTriviallyDestructible1<T>::~MaybeTriviallyDestructible1() noexcept = default;
// Don't emit for specializations.
template struct MaybeTriviallyDestructible1<int>;
// Don't emit for class template with type-dependent bases.
template <class T>
struct MaybeTriviallyDestructible2 : T {
~MaybeTriviallyDestructible2() noexcept;
};
template <class T>
MaybeTriviallyDestructible2<T>::~MaybeTriviallyDestructible2() noexcept = default;
// Emit for templates without dependent bases and fields.
template <class T>
struct MaybeTriviallyDestructible1<T *> {
~MaybeTriviallyDestructible1() noexcept;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1<T *>' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
// CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
TriviallyDestructible1 t;
};
template <class T>
MaybeTriviallyDestructible1<T *>::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
// CHECK-MESSAGES: :[[@LINE-1]]:35: note: destructor definition is here
// CHECK-FIXES: // to-be-removed
// Emit for explicit specializations.
template <>
struct MaybeTriviallyDestructible1<double>: TriviallyDestructible1 {
~MaybeTriviallyDestructible1() noexcept;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1<double>' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
// CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
};
MaybeTriviallyDestructible1<double>::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
// CHECK-MESSAGES: :[[@LINE-1]]:38: note: destructor definition is here
// CHECK-FIXES: // to-be-removed
struct NotTriviallyDestructible2 {
virtual ~NotTriviallyDestructible2();
};
NotTriviallyDestructible2::~NotTriviallyDestructible2() = default;
struct NotTriviallyDestructible3: NotTriviallyDestructible2 {
~NotTriviallyDestructible3();
};
NotTriviallyDestructible3::~NotTriviallyDestructible3() = default;