improve useuniqueptr loplugin to find arrays
Change-Id: I81e9d0cd4f430b11d20037054055683240792240 Reviewed-on: https://gerrit.libreoffice.org/39825 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -8,13 +8,33 @@
|
||||
*/
|
||||
|
||||
|
||||
class Foo {
|
||||
class Foo1 {
|
||||
char* m_pbar; // expected-note {{member is here [loplugin:useuniqueptr]}}
|
||||
~Foo()
|
||||
~Foo1()
|
||||
{
|
||||
delete m_pbar; // expected-error {{a destructor with only a single unconditional call to delete on a member, is a sure sign it should be using std::unique_ptr for that field [loplugin:useuniqueptr]}}
|
||||
m_pbar = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Foo2 {
|
||||
char* m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}}
|
||||
char* m_pbar2; // expected-note {{member is here [loplugin:useuniqueptr]}}
|
||||
~Foo2()
|
||||
{
|
||||
delete[] m_pbar1; // expected-error {{managing array of trival type 'char' manually, rather use std::vector / std::array / std::unique_ptr [loplugin:useuniqueptr]}}
|
||||
delete[] m_pbar2; // expected-error {{managing array of trival type 'char' manually, rather use std::vector / std::array / std::unique_ptr [loplugin:useuniqueptr]}}
|
||||
}
|
||||
};
|
||||
|
||||
class Foo3 {
|
||||
char* m_pbar;
|
||||
bool bMine;
|
||||
~Foo3()
|
||||
{
|
||||
if (bMine)
|
||||
delete[] m_pbar;
|
||||
}
|
||||
};
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
Reference in New Issue
Block a user