diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-08 10:30:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-09 07:44:49 +0200 |
commit | 682fdbf1312cf6ca70fe209bf4d7051dad8f5008 (patch) | |
tree | d001d22a20752086c6aa0f56d6c83791406fae9b /compilerplugins | |
parent | c71896debc7ef5f6d6e918f59fa44423eb5df480 (diff) |
loplugin:redundantpointerops check other pointer types
as well as unique_ptr
Change-Id: I54842bca161ee460fb96c46ca31b6f9c0a7dbbdf
Reviewed-on: https://gerrit.libreoffice.org/80455
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/redundantpointerops.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compilerplugins/clang/redundantpointerops.cxx b/compilerplugins/clang/redundantpointerops.cxx index 7c82825bd01d..5406989696c5 100644 --- a/compilerplugins/clang/redundantpointerops.cxx +++ b/compilerplugins/clang/redundantpointerops.cxx @@ -123,13 +123,16 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator if (auto cxxMemberCallExpr = dyn_cast<CXXMemberCallExpr>(subExpr)) { auto methodDecl = cxxMemberCallExpr->getMethodDecl(); - if (methodDecl->getIdentifier() && methodDecl->getName() == "get" - && cxxMemberCallExpr->getRecordDecl()->getName() == "unique_ptr") - report( - DiagnosticsEngine::Warning, "'*' followed by '.get()', just use '*'", - compat::getBeginLoc(unaryOperator)) - << unaryOperator->getSourceRange(); + if (methodDecl->getIdentifier() && methodDecl->getName() == "get") + { + auto className = cxxMemberCallExpr->getRecordDecl()->getName(); + if (className == "unique_ptr" || className == "shared_ptr" || className == "Reference" || className == "SvRef") + report( + DiagnosticsEngine::Warning, "'*' followed by '.get()', just use '*'", + compat::getBeginLoc(unaryOperator)) + << unaryOperator->getSourceRange(); + } } return true; } |