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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 3 09:03:52 UTC 2018


 compilerplugins/clang/useuniqueptr.cxx |   32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

New commits:
commit 651a2dee1c8c5bb084aa6b84fd7171f35ff52305
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Sep 3 09:58:12 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Sep 3 11:03:30 2018 +0200

    loplugin:useuniqueptr update exclusions
    
    Change-Id: I9c741dbaba772550b4d68406fff50d8b0ac60874
    Reviewed-on: https://gerrit.libreoffice.org/59923
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index cbcde8c2fce1..313d79edf9a7 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -116,6 +116,9 @@ public:
         // WW8TabBandDesc
         if (fn == SRCDIR "/sw/source/filter/ww8/ww8par2.cxx")
             return;
+        // ZipOutputStream, ownership of ZipEntry is horribly complicated here
+        if (fn == SRCDIR "/package/source/zipapi/ZipOutputStream.cxx")
+            return;
 
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
@@ -410,6 +413,12 @@ void UseUniquePtr::CheckLoopDelete(const CXXMethodDecl* methodDecl, const CXXDel
     if (!memberExpr)
         return;
 
+    std::string fn(handler.getMainFileName());
+    loplugin::normalizeDotDotInFilePath(fn);
+    // OStorage_Impl::Commit very complicated ownership passing going on
+    if (fn == SRCDIR "/package/source/xstor/xstorage.cxx")
+        return;
+
     CheckDeleteExpr(methodDecl, deleteExpr, memberExpr, "rather manage with std::some_container<std::unique_ptr<T>>");
 }
 
@@ -433,6 +442,12 @@ void UseUniquePtr::CheckCXXForRangeStmt(const CXXMethodDecl* methodDecl, const C
     if (!fieldDecl)
         return;
 
+    std::string fn(handler.getMainFileName());
+    loplugin::normalizeDotDotInFilePath(fn);
+    // appears to just randomly leak stuff, and it involves some lex/yacc stuff
+    if (fn == SRCDIR "/idlc/source/aststack.cxx")
+        return;
+
     CheckDeleteExpr(methodDecl, deleteExpr, memberExpr, "rather manage with std::some_container<std::unique_ptr<T>>");
 }
 
@@ -654,9 +669,6 @@ bool UseUniquePtr::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr)
     // SAXEventKeeperImpl::smashBufferNode
     if (fn == SRCDIR "/xmlsecurity/source/framework/saxeventkeeperimpl.cxx")
         return true;
-    // ZipOutputStream, ownership of ZipEntry is horribly complicated here
-    if (fn == SRCDIR "/package/source/zipapi/ZipOutputStream.cxx")
-        return true;
     // SwDoc::DeleteExtTextInput
     if (fn == SRCDIR "/sw/source/core/doc/extinput.cxx")
         return true;
@@ -720,12 +732,22 @@ bool UseUniquePtr::TraverseConstructorInitializer(CXXCtorInitializer * ctorInit)
         return true;
     if (!loplugin::TypeCheck(ctorInit->getMember()->getType()).Class("unique_ptr").StdNamespace())
         return true;
-    auto constructExpr = dyn_cast<CXXConstructExpr>(ctorInit->getInit());
-    if (!constructExpr)
+    auto constructExpr = dyn_cast_or_null<CXXConstructExpr>(ctorInit->getInit());
+    if (!constructExpr || constructExpr->getNumArgs() == 0)
         return true;
     auto init = constructExpr->getArg(0)->IgnoreImpCasts();
     if (!isa<DeclRefExpr>(init))
         return true;
+
+    StringRef fn = getFileNameOfSpellingLoc(compiler.getSourceManager().getSpellingLoc(ctorInit->getSourceLocation()));
+    // don't feel like fiddling with the yacc parser
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/idlc/"))
+        return true;
+    // cannot change URE
+    if (loplugin::hasPathnamePrefix(fn, SRCDIR "/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx"))
+        return true;
+
+
     report(
         DiagnosticsEngine::Warning,
         "should be passing via std::unique_ptr param",


More information about the Libreoffice-commits mailing list