diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-17 10:56:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-18 09:07:56 +0200 |
commit | 455ac9fb7a46d3bd8e0a94593388c9c474d1dd75 (patch) | |
tree | 54b9f5b06f536c6e7b9435041804921b1a36eece /compilerplugins/clang/test/useuniqueptr.cxx | |
parent | 83b840e6a08d7d990a4703b6ef67c3829c75aad4 (diff) |
loplugin:useuniqueptr check more local variables
Change-Id: I8387731747ee6eb7d74037c0eff7fc9ac0b884c8
Reviewed-on: https://gerrit.libreoffice.org/60619
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/test/useuniqueptr.cxx')
-rw-r--r-- | compilerplugins/clang/test/useuniqueptr.cxx | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx index 020bcce1981e..ad6314986a72 100644 --- a/compilerplugins/clang/test/useuniqueptr.cxx +++ b/compilerplugins/clang/test/useuniqueptr.cxx @@ -61,7 +61,7 @@ class Class5 { ~Class5() { for (auto p : m_pbar) - delete p; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + delete p; // expected-error {{rather manage this with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} } }; class Class5a { @@ -72,7 +72,7 @@ class Class5a { { int x = 1; x = x + 2; - delete p; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + delete p; // expected-error {{rather manage this with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} } } }; @@ -81,7 +81,7 @@ class Class6 { ~Class6() { for (auto p : m_pbar) - delete p; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + delete p; // expected-error {{rather manage this with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} } }; class Class7 { @@ -97,7 +97,7 @@ class Class8 { ~Class8() { for (auto i : m_pbar) - delete i.second; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + delete i.second; // expected-error {{rather manage this with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} } }; class Foo8 { @@ -152,7 +152,7 @@ class Foo11 { { for (const auto & p : m_pbar1) { - delete p; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + delete p; // expected-error {{rather manage this with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} } } }; @@ -214,7 +214,7 @@ class Foo17 { int * m_pbar1[6]; // expected-note {{member is here [loplugin:useuniqueptr]}} ~Foo17() { - delete m_pbar1[0]; // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + delete m_pbar1[0]; // expected-error {{unconditional call to delete on an array member, should be using std::unique_ptr [loplugin:useuniqueptr]}} } }; @@ -230,6 +230,26 @@ class Foo18 { }; #endif +void foo19() +{ + std::vector<char*> vec; // expected-note {{var is here [loplugin:useuniqueptr]}} + for(char * p : vec) + delete p; // expected-error {{rather manage this var with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} +} + +// no warning expected +namespace foo20 +{ + struct struct20_1 {}; + struct struct20_2 : public struct20_1 { + char * p; + }; + void foo20(struct20_1 * pMapping) + { + delete static_cast< struct20_2 * >( pMapping )->p; + } +}; + // ------------------------------------------------------------------------------------------------ // tests for passing owning pointers to constructors |