From 5688cd1d9ad4500b82d2668cc5035da5c64acd0e Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 8 Oct 2018 14:10:17 +0200 Subject: Fix loplugin:useuniqueptr for libc++ (macOS) ...after 05a337e297eb0cfe88c99503d760bd9eaf495b7d "loplugin:useuniqueptr look for deleting in loops with iterators", where it didn't emit the warning for Foo24 in compilerplugins/clang/test/useuniqueptr.cxx during CompilerTest_compilerplugins_clang, because in the initialization of HTMLAttrs::const_iterator it = m_aSetAttrTab.begin(); the HTMLAttrs::const_iterator CXXConstructExpr happens to have a second, defaulted argument. Change-Id: I882a6dfb5cab1b147f790072f2545b13172c0f9a Reviewed-on: https://gerrit.libreoffice.org/61530 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/useuniqueptr.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index c416d4be9ad1..869e368cc318 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -497,8 +497,11 @@ void UseUniquePtr::CheckLoopDelete(const FunctionDecl* functionDecl, const CXXDe { init = init->IgnoreImplicit(); if (auto x = dyn_cast(init)) - if (x->getNumArgs() == 1) + if (x->getNumArgs() == 1 + || (x->getNumArgs() >= 2 && isa(x->getArg(1)))) + { init = x->getArg(0)->IgnoreImplicit(); + } if (auto x = dyn_cast(init)) init = x->getImplicitObjectArgument(); if ((memberExpr = dyn_cast(init))) -- cgit