summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/redundantpointerops.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-09 14:25:36 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-09 20:42:21 +0200
commit4b0afe968ed62ac65d5f04918f4cda501ecf1619 (patch)
tree861b5911bc3a24517f5e14fccca0d8310a1580b5 /compilerplugins/clang/redundantpointerops.cxx
parent39090afac268f9ae985832c2f08863b41e6c06f2 (diff)
Improve loplugin:redundantpointerops diagnostic messages
Change-Id: If09f5c916f2db98c5d1754d2fbc8f53c502799c9 Reviewed-on: https://gerrit.libreoffice.org/80543 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/redundantpointerops.cxx')
-rw-r--r--compilerplugins/clang/redundantpointerops.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/compilerplugins/clang/redundantpointerops.cxx b/compilerplugins/clang/redundantpointerops.cxx
index 5406989696c5..dbb3ef7882fd 100644
--- a/compilerplugins/clang/redundantpointerops.cxx
+++ b/compilerplugins/clang/redundantpointerops.cxx
@@ -75,8 +75,10 @@ bool RedundantPointerOps::VisitMemberExpr(MemberExpr const * memberExpr)
{
if (unaryOp->getOpcode() == UO_AddrOf)
report(
- DiagnosticsEngine::Warning, "'&' followed by '->', rather use '.'",
+ DiagnosticsEngine::Warning,
+ "'&' followed by '->' operating on %0, rather use '.'",
compat::getBeginLoc(memberExpr))
+ << memberExpr->getBase()->getType()->getPointeeType()
<< memberExpr->getSourceRange();
}
@@ -84,8 +86,10 @@ bool RedundantPointerOps::VisitMemberExpr(MemberExpr const * memberExpr)
{
if (operatorCallExpr->getOperator() == OO_Amp)
report(
- DiagnosticsEngine::Warning, "'&' followed by '->', rather use '.'",
+ DiagnosticsEngine::Warning,
+ "'&' followed by '->' operating on %0, rather use '.'",
compat::getBeginLoc(memberExpr))
+ << memberExpr->getBase()->getType()->getPointeeType()
<< memberExpr->getSourceRange();
}
@@ -117,9 +121,9 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator
auto innerOp = dyn_cast<UnaryOperator>(subExpr);
if (innerOp && innerOp->getOpcode() == UO_AddrOf)
report(
- DiagnosticsEngine::Warning, "'&' followed by '*', rather use '.'",
+ DiagnosticsEngine::Warning, "'&' followed by '*' operating on %0, rather use '.'",
compat::getBeginLoc(unaryOperator))
- << unaryOperator->getSourceRange();
+ << innerOp->getSubExpr()->getType() << unaryOperator->getSourceRange();
if (auto cxxMemberCallExpr = dyn_cast<CXXMemberCallExpr>(subExpr))
{
auto methodDecl = cxxMemberCallExpr->getMethodDecl();
@@ -128,9 +132,10 @@ bool RedundantPointerOps::VisitUnaryOperator(UnaryOperator const * unaryOperator
auto className = cxxMemberCallExpr->getRecordDecl()->getName();
if (className == "unique_ptr" || className == "shared_ptr" || className == "Reference" || className == "SvRef")
report(
- DiagnosticsEngine::Warning, "'*' followed by '.get()', just use '*'",
+ DiagnosticsEngine::Warning,
+ "'*' followed by '.get()' operating on %0, just use '*'",
compat::getBeginLoc(unaryOperator))
- << unaryOperator->getSourceRange();
+ << compat::getObjectType(cxxMemberCallExpr) << unaryOperator->getSourceRange();
}
}