From 4089e1d9f67a61322b1fa4330ee10f62b3684f7f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 23 Jul 2018 12:21:25 +0200 Subject: [PATCH] loplugin:useuniqueptr fix check for DELETEZ inside compound stmt Change-Id: Id748b8b0c9cfe8c288dfafb5d0c2a83a8de2c91c Reviewed-on: https://gerrit.libreoffice.org/57871 Tested-by: Jenkins Reviewed-by: Noel Grandin --- compilerplugins/clang/test/useuniqueptr.cxx | 5 +++++ compilerplugins/clang/useuniqueptr.cxx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx index 24a34c0e54b9..844f7fb65d7e 100644 --- a/compilerplugins/clang/test/useuniqueptr.cxx +++ b/compilerplugins/clang/test/useuniqueptr.cxx @@ -154,11 +154,16 @@ class Foo12 { class Foo13 { int * m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}} int * m_pbar2; // expected-note {{member is here [loplugin:useuniqueptr]}} + int * m_pbar3; // expected-note {{member is here [loplugin:useuniqueptr]}} ~Foo13() { if (m_pbar1) DELETEZ(m_pbar1); // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} DELETEZ(m_pbar2); // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + if (m_pbar3) + { + DELETEZ(m_pbar3); // expected-error {{unconditional call to delete on a member, should be using std::unique_ptr [loplugin:useuniqueptr]}} + } } }; // check for unconditional inner compound statements diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index c7f6d7a2444c..f41b55a5eb0f 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -228,7 +228,7 @@ void UseUniquePtr::CheckForSimpleDelete(const CXXMethodDecl* methodDecl, const C auto ifDeleteExpr = dyn_cast(*j); if (ifDeleteExpr) CheckDeleteExpr(methodDecl, ifDeleteExpr); - ParenExpr const * parenExpr = dyn_cast(*i); + ParenExpr const * parenExpr = dyn_cast(*j); if (parenExpr) CheckParenExpr(methodDecl, parenExpr); }