Kaydet (Commit) 5688cd1d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix loplugin:useuniqueptr for libc++ (macOS)

...after 05a337e2 "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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 18c628ae
......@@ -497,8 +497,11 @@ void UseUniquePtr::CheckLoopDelete(const FunctionDecl* functionDecl, const CXXDe
{
init = init->IgnoreImplicit();
if (auto x = dyn_cast<CXXConstructExpr>(init))
if (x->getNumArgs() == 1)
if (x->getNumArgs() == 1
|| (x->getNumArgs() >= 2 && isa<CXXDefaultArgExpr>(x->getArg(1))))
{
init = x->getArg(0)->IgnoreImplicit();
}
if (auto x = dyn_cast<CXXMemberCallExpr>(init))
init = x->getImplicitObjectArgument();
if ((memberExpr = dyn_cast<MemberExpr>(init)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment