From 1446e097e76669c0d7749ec0f8918606d3cc4c28 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 27 Jan 2020 21:07:10 +0100 Subject: Fix loplugin:makeshared for libc++ ...where the std::make_shared ctor has a default argument, > template > explicit shared_ptr(_Yp* __p, > typename enable_if::value, __nat>::type = __nat()); Change-Id: Ia97d16f64a7e9b4f48112b033dcdb6722d4da791 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87552 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/makeshared.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(constructExpr->getArg(1))))) return true; auto cxxNewExpr = dyn_cast(constructExpr->getArg(0)->IgnoreParenImpCasts()); if (!cxxNewExpr) -- cgit