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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 27 22:14:33 UTC 2020


 compilerplugins/clang/makeshared.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 1446e097e76669c0d7749ec0f8918606d3cc4c28
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Jan 27 21:07:10 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Jan 27 23:13:57 2020 +0100

    Fix loplugin:makeshared for libc++
    
    ...where the std::make_shared ctor has a default argument,
    
    > template<class _Yp>
    >     explicit shared_ptr(_Yp* __p,
    >                         typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
    
    Change-Id: Ia97d16f64a7e9b4f48112b033dcdb6722d4da791
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87552
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/compilerplugins/clang/makeshared.cxx b/compilerplugins/clang/makeshared.cxx
index b1f1c13ce640..398a3acc4654 100644
--- a/compilerplugins/clang/makeshared.cxx
+++ b/compilerplugins/clang/makeshared.cxx
@@ -68,7 +68,8 @@ bool MakeShared::VisitCXXConstructExpr(CXXConstructExpr const* constructExpr)
         return true;
     if (!loplugin::TypeCheck(constructExpr->getType()).ClassOrStruct("shared_ptr").StdNamespace())
         return true;
-    if (constructExpr->getNumArgs() != 1)
+    if (!(constructExpr->getNumArgs() == 1
+          || (constructExpr->getNumArgs() > 1 && isa<CXXDefaultArgExpr>(constructExpr->getArg(1)))))
         return true;
     auto cxxNewExpr = dyn_cast<CXXNewExpr>(constructExpr->getArg(0)->IgnoreParenImpCasts());
     if (!cxxNewExpr)


More information about the Libreoffice-commits mailing list