summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-23 09:47:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-23 09:48:10 +0000
commited76d1d3504c92bff6bb3e6417e4440572fcd959 (patch)
tree6d06b4a20bef5acf0c1a4118685f09acdd27fbb7 /compilerplugins
parenta61c4ae9cef23a53ea88f957e090bd5ee9b28ca6 (diff)
loplugins:redundantcast teach it about c-style typedef casts
Change-Id: I1ac11a2481c0f4d8be1e1fd7c7637ac0ece3d65c Reviewed-on: https://gerrit.libreoffice.org/35558 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/redundantcast.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 4bef116f481b..c18e1cf5be0e 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -304,6 +304,16 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
DiagnosticsEngine::Warning,
"redundant cstyle enum cast from %0 to %1", expr->getExprLoc())
<< t1 << t2 << expr->getSourceRange();
+ return true;
+ }
+ if (loplugin::TypeCheck(t1).Typedef() && loplugin::TypeCheck(t2).Typedef() && t1 == t2
+ && !compiler.getSourceManager().isMacroBodyExpansion(expr->getLocStart()))
+ {
+ report(
+ DiagnosticsEngine::Warning,
+ "redundant cstyle typedef cast from %0 to %1", expr->getExprLoc())
+ << t1 << t2 << expr->getSourceRange();
+ return true;
}
return true;
}