diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-10 16:23:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-12 07:02:29 +0100 |
commit | 22bba5f377b9261fd2aecf3a20a9fc59e5d9fda3 (patch) | |
tree | d978bc10c2a50714f59b5379a253a05633a70a38 /compilerplugins/clang/test/useuniqueptr.cxx | |
parent | 920447d4a5df9a4f27726a943417e946108ad3ac (diff) |
teach useuniqueptr loplugin about "if(field != null) delete field"
Change-Id: I938deef90c8d6ceb0e72ab3f6ee2cbddc6f72b8d
Reviewed-on: https://gerrit.libreoffice.org/47730
Tested-by: Jenkins <ci@libreoffice.org>
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 | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx index 2ffdecc33a04..43002ec59a68 100644 --- a/compilerplugins/clang/test/useuniqueptr.cxx +++ b/compilerplugins/clang/test/useuniqueptr.cxx @@ -94,4 +94,22 @@ class Foo8 { delete m_pbar2; // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} } }; +class Foo9 { + XXX* m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}} + XXX* m_pbar2; // expected-note {{member is here [loplugin:useuniqueptr]}} + XXX* m_pbar3; // expected-note {{member is here [loplugin:useuniqueptr]}} + ~Foo9() + { + if (m_pbar1) + { + delete m_pbar1; // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + } + if (m_pbar2 != nullptr) + { + delete m_pbar2; // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + } + if (m_pbar3 != nullptr) + delete m_pbar3; // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + } +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |