diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-10-08 14:10:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-10-08 16:58:44 +0200 |
commit | 5688cd1d9ad4500b82d2668cc5035da5c64acd0e (patch) | |
tree | 9f7cab097484f7bf0cd87f687d61e528e5839393 /compilerplugins | |
parent | 18c628ae6ef2664db40ef46e21064f3ac4713e5c (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/useuniqueptr.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
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<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))) |