diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-05 12:26:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-05 12:21:19 +0000 |
commit | 572e9cde744e2b482a04ff4b457ad2cfde5f70d2 (patch) | |
tree | 78e93df178de6d17d55eef7c3907781aa131ff7c /compilerplugins | |
parent | 5f282c101a644ffc3615c3dc43ddb99febecae16 (diff) |
loplugin:redundantcast find c-style bool casts
Change-Id: I3237b93babc67de12c3771aa84766c2141ca93b2
Reviewed-on: https://gerrit.libreoffice.org/36137
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.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 17e3bac33ca7..7b3b05d8aced 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -299,14 +299,15 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) { } auto t1 = getSubExprAsWritten(expr)->getType(); auto t2 = expr->getTypeAsWritten(); - if (loplugin::TypeCheck(t1).Enum() && loplugin::TypeCheck(t2).Enum() && t1 == t2) { + if (loplugin::TypeCheck(t1).Enum() && t1 == t2) { report( 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) + bool bBuiltinTypeBool = t1->isSpecificBuiltinType(BuiltinType::Bool); + if ((bBuiltinTypeBool || loplugin::TypeCheck(t1).Typedef()) && t1 == t2) { // Ignore FD_ISSET expanding to "...(SOCKET)(fd)..." in some Microsoft // winsock2.h (TODO: improve heuristic of determining that the whole @@ -332,7 +333,7 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) { } report( DiagnosticsEngine::Warning, - "redundant cstyle typedef cast from %0 to %1", expr->getExprLoc()) + "redundant cstyle cast from %0 to %1", expr->getExprLoc()) << t1 << t2 << expr->getSourceRange(); return true; } |