diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-15 15:43:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-15 15:45:34 +0200 |
commit | 3281628e1cf66f51f414436cd2002e0a63ec4750 (patch) | |
tree | 1a0354cabea59e5eb7c2b0130911e4e77ec2b92c /compilerplugins | |
parent | 688624b78484bcb17c732b9c14dbb516fb6b28b4 (diff) |
loplugin:redundantcast ignore functional casts involving typedefs
<sberg> noelgrandin, 718cdd43c25783d9cd402e381123efe3981cc514 now also
looks through typedef sugar, e.g. complaining about a gdouble -> double
expl. conversion in configmgr/source/dconf.cxx;
I think we want to remain silent about such conversions involving typedefs
<noelgrandin> sberg, ah, good point.
Change-Id: Icbb0d6be273f53e507c91556cf0ccb5a5c03e5a1
Reviewed-on: https://gerrit.libreoffice.org/41175
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 56afdf13f090..b9f97dce0c6b 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -633,9 +633,13 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp } auto const t1 = expr->getTypeAsWritten(); - auto const t2 = sub->getType().getDesugaredType(compiler.getASTContext()); + auto const t2 = sub->getType().getDesugaredType(compiler.getASTContext()); // look through templated wrapped types if (t1 != t2) return true; + // if we are casting from/to a typedef, ignore it, even if the underlying types are the same + if ((loplugin::TypeCheck(t1).Typedef() || loplugin::TypeCheck(sub->getType()).Typedef()) + && t1 != sub->getType()) + return true; if (!isOkToRemoveArithmeticCast(t1, t2, expr->getSubExpr())) return true; report( |