[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 24 06:34:46 UTC 2018


 compilerplugins/clang/test/useuniqueptr.cxx |    5 +++++
 compilerplugins/clang/useuniqueptr.cxx      |    2 +-
 sw/source/uibase/config/dbconfig.cxx        |   13 +++++--------
 sw/source/uibase/inc/dbconfig.hxx           |    4 ++--
 4 files changed, 13 insertions(+), 11 deletions(-)

New commits:
commit 4089e1d9f67a61322b1fa4330ee10f62b3684f7f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 23 12:21:25 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 24 08:34:32 2018 +0200

    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 <noel.grandin at collabora.co.uk>

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<CXXDeleteExpr>(*j);
             if (ifDeleteExpr)
                 CheckDeleteExpr(methodDecl, ifDeleteExpr);
-            ParenExpr const * parenExpr = dyn_cast<ParenExpr>(*i);
+            ParenExpr const * parenExpr = dyn_cast<ParenExpr>(*j);
             if (parenExpr)
                 CheckParenExpr(methodDecl, parenExpr);
         }
commit fbd757349ea0dd2e9daecc2b6d1aa2e80aa7a319
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 23 12:08:56 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 24 08:34:21 2018 +0200

    loplugin:useuniqueptr in SwDBConfig
    
    Change-Id: Ibf9cdf4e09275325a876b81067245f76597ae08e
    Reviewed-on: https://gerrit.libreoffice.org/57870
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/uibase/config/dbconfig.cxx b/sw/source/uibase/config/dbconfig.cxx
index 91b24488bf36..34d0650dcde0 100644
--- a/sw/source/uibase/config/dbconfig.cxx
+++ b/sw/source/uibase/config/dbconfig.cxx
@@ -42,16 +42,14 @@ const Sequence<OUString>& SwDBConfig::GetPropertyNames()
 
 SwDBConfig::SwDBConfig() :
     ConfigItem("Office.DataAccess",
-        ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree),
-    pAdrImpl(nullptr),
-    pBibImpl(nullptr)
+        ConfigItemMode::DelayedUpdate|ConfigItemMode::ReleaseTree)
 {
 };
 
 SwDBConfig::~SwDBConfig()
 {
-    delete pAdrImpl;
-    delete pBibImpl;
+    pAdrImpl.reset();
+    pBibImpl.reset();
 }
 
 void SwDBConfig::Load()
@@ -59,10 +57,9 @@ void SwDBConfig::Load()
     const Sequence<OUString>& rNames = GetPropertyNames();
     if(!pAdrImpl)
     {
-
-        pAdrImpl = new SwDBData;
+        pAdrImpl.reset(new SwDBData);
         pAdrImpl->nCommandType = 0;
-        pBibImpl = new SwDBData;
+        pBibImpl.reset(new SwDBData);
         pBibImpl->nCommandType = 0;
     }
     Sequence<Any> aValues = GetProperties(rNames);
diff --git a/sw/source/uibase/inc/dbconfig.hxx b/sw/source/uibase/inc/dbconfig.hxx
index 5ea79f423853..5a611f5d8be0 100644
--- a/sw/source/uibase/inc/dbconfig.hxx
+++ b/sw/source/uibase/inc/dbconfig.hxx
@@ -30,8 +30,8 @@ private:
     SAL_DLLPRIVATE static const css::uno::Sequence<OUString>& GetPropertyNames();
     virtual void ImplCommit() override;
 
-    SwDBData*       pAdrImpl;
-    SwDBData*       pBibImpl;
+    std::unique_ptr<SwDBData> pAdrImpl;
+    std::unique_ptr<SwDBData> pBibImpl;
 
 public:
     SwDBConfig();


More information about the Libreoffice-commits mailing list