From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- build/clang-plugin/alpha/tests/TestNonStdMove.cpp | 125 ++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 build/clang-plugin/alpha/tests/TestNonStdMove.cpp (limited to 'build/clang-plugin/alpha/tests/TestNonStdMove.cpp') diff --git a/build/clang-plugin/alpha/tests/TestNonStdMove.cpp b/build/clang-plugin/alpha/tests/TestNonStdMove.cpp new file mode 100644 index 0000000000..379f9655dd --- /dev/null +++ b/build/clang-plugin/alpha/tests/TestNonStdMove.cpp @@ -0,0 +1,125 @@ +#include + +// we can't include nsCOMPtr.h here, so let's redefine a basic version +template +struct nsCOMPtr { + nsCOMPtr() = default; + + template + MOZ_IMPLICIT nsCOMPtr(already_AddRefed&& aSrc); + + template + nsCOMPtr& operator=(already_AddRefed&& aSrc); +}; + + +using namespace mozilla; + +struct RefCountedBase { + void AddRef(); + void Release(); + + void method_test(); +}; + +struct RefCountedDerived : RefCountedBase {}; + +struct RefCountedBaseHolder { + RefPtr GetRefCountedBase() const { + return mRefCountedBase; + } + +private: + RefPtr mRefCountedBase = MakeRefPtr(); +}; + + +void test_assign_same_type() { + RefPtr a = MakeRefPtr(); + RefPtr b; + + b = a.forget(); // expected-warning {{non-standard move assignment}} +} + +void test_assign_implicit_cast() { + RefPtr a = MakeRefPtr(); + RefPtr b; + + b = a.forget(); // expected-warning {{non-standard move assignment}} +} + +void test_assign_different_template() { + RefPtr a = MakeRefPtr(); + nsCOMPtr b; + + b = a.forget(); // expected-warning {{non-standard move assignment}} +} + +void test_construct_different_template() { + RefPtr a = MakeRefPtr(); + nsCOMPtr b = a.forget(); // expected-warning {{non-standard move construction}} +} + +void test_assign_already_addrefed() { + RefPtr a = MakeRefPtr(); + already_AddRefed b; + + b = a.forget(); +} + +void test_construct_already_addrefed() { + RefPtr a = MakeRefPtr(); + already_AddRefed b = a.forget(); +} + +void test_construct_same_type() { + RefPtr a = MakeRefPtr(); + RefPtr b = a.forget(); // expected-warning {{non-standard move construction}} +} + +void test_construct_implicit_cast() { + RefPtr a = MakeRefPtr(); + RefPtr b = a.forget(); // expected-warning {{non-standard move construction}} +} + +void test_construct_brace_same_type() { + RefPtr a = MakeRefPtr(); + auto b = RefPtr{a.forget()}; // expected-warning {{non-standard move construction}} +} + +void test_construct_brace_implicit_cast() { + RefPtr a = MakeRefPtr(); + auto b = RefPtr{a.forget()}; // expected-warning {{non-standard move construction}} +} + +void test_construct_function_style_same_type() { + RefPtr a = MakeRefPtr(); + auto b = RefPtr(a.forget()); // expected-warning {{non-standard move construction}} +} + +void test_construct_function_style_implicit_cast() { + RefPtr a = MakeRefPtr(); + auto b = RefPtr(a.forget()); // expected-warning {{non-standard move construction}} +} + +void test_construct_result_type() { + RefPtr a = MakeRefPtr(); + already_AddRefed b = a.forget(); +} + +void test_construct_implicitly_cast_result_type() { + RefPtr a = MakeRefPtr(); + already_AddRefed b = a.forget(); +} + +void foo(already_AddRefed&& aArg); + +void test_call_with_result_type() { + RefPtr a = MakeRefPtr(); + foo(a.forget()); +} + +void test_call_with_implicitly_cast_result_type() { + RefPtr a = MakeRefPtr(); + foo(a.forget()); +} -- cgit v1.2.3