From 3281628e1cf66f51f414436cd2002e0a63ec4750 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 15 Aug 2017 15:43:31 +0200 Subject: loplugin:redundantcast ignore functional casts involving typedefs 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 sberg, ah, good point. Change-Id: Icbb0d6be273f53e507c91556cf0ccb5a5c03e5a1 Reviewed-on: https://gerrit.libreoffice.org/41175 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- compilerplugins/clang/redundantcast.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compilerplugins/clang') 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( -- cgit