diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-03 09:58:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-03 11:03:30 +0200 |
commit | 651a2dee1c8c5bb084aa6b84fd7171f35ff52305 (patch) | |
tree | 20e6cfe0288fc690da99c826c854a98ed0288089 /compilerplugins | |
parent | 4b5fcd417587cfb9e6d8b61ecb037ab165eeb5b9 (diff) |
loplugin:useuniqueptr update exclusions
Change-Id: I9c741dbaba772550b4d68406fff50d8b0ac60874
Reviewed-on: https://gerrit.libreoffice.org/59923
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/useuniqueptr.cxx | 32 |
1 files changed, 27 insertions, 5 deletions
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", |