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>
This commit is contained in:
Noel Grandin
2019-10-08 10:30:36 +02:00
parent c71896debc
commit 682fdbf131
16 changed files with 28 additions and 26 deletions

View File

@@ -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;
}