diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-09-26 08:35:32 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-09-26 10:01:54 +0200 |
commit | d883e3556a77303919c84652fea0f603fa350311 (patch) | |
tree | 0a71c279f555ec4727a510e8bd3307222886f913 /compilerplugins/clang/redundantcast.cxx | |
parent | Silence macOS 10.13 -Werror,-Wdeprecated-declarations (diff) | |
download | core-d883e3556a77303919c84652fea0f603fa350311.tar.gz core-d883e3556a77303919c84652fea0f603fa350311.zip |
loplugin:redundantcast: cstyle_cast within reinterpret_cast
Change-Id: Ie31c9dd6d8741aa856553b798bb5b7f695a3fe0f
Reviewed-on: https://gerrit.libreoffice.org/42776
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/redundantcast.cxx')
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index dba573387743..30914a460dc4 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -522,6 +522,20 @@ bool RedundantCast::VisitCXXReinterpretCastExpr( expr->getExprLoc()) << expr->getSubExprAsWritten()->getType() << expr->getType() << expr->getSourceRange(); + } else if (expr->getType()->isFundamentalType()) { + if (auto const sub = dyn_cast<CXXConstCastExpr>( + expr->getSubExpr()->IgnoreParens())) + { + report( + DiagnosticsEngine::Warning, + ("redundant const_cast from %0 to %1 within reinterpret_cast to" + " fundamental type %2"), + expr->getExprLoc()) + << sub->getSubExprAsWritten()->getType() + << sub->getTypeAsWritten() << expr->getTypeAsWritten() + << expr->getSourceRange(); + return true; + } } return true; } |