summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-01-27 21:07:10 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-01-27 23:13:57 +0100
commit1446e097e76669c0d7749ec0f8918606d3cc4c28 (patch)
treed8d04120f09512d8d9186b6df5f0b17d80794860
parent859ad3f1a4cf3d614c7cb88c71500c6f84af37c0 (diff)
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@redhat.com>
-rw-r--r--compilerplugins/clang/makeshared.cxx3
1 files changed, 2 insertions, 1 deletions
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)