diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-08-16 22:15:05 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-08-17 08:19:48 +0200 |
commit | f58933829dc6c11a06255ae8d5417dea56264c49 (patch) | |
tree | e27210c2e0424216acd08cb40a306ed9796279a5 /compilerplugins | |
parent | d7e087608eba7dc6f966204f0e57e88c2ab37764 (diff) |
Avoid loplugin:redundantcast false positive involving decltype
..with libc++ on macOS:
> /Users/stephan/Software/lo2/core/sw/source/core/doc/CntntIdxStore.cxx:238:44: error: static_cast from 'decltype(__x.base() - __y.base())' (aka 'long') prvalue to 'long' prvalue is redundant [loplugin:redundantcast]
> const MarkEntry aEntry = { static_cast<long>(ppBkmk - pMarkAccess->getAllMarksBegin()), false, pBkmk->GetMarkPos().nContent.GetIndex() };
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change-Id: I94ab3d828482462c0fde26e19c9cc6508efa00fe
Reviewed-on: https://gerrit.libreoffice.org/59240
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/check.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx index 86484d6828cf..acda74adacd6 100644 --- a/compilerplugins/clang/check.cxx +++ b/compilerplugins/clang/check.cxx @@ -261,7 +261,7 @@ bool isOkToRemoveArithmeticCast( clang::ASTContext & context, clang::QualType t1, clang::QualType t2, const clang::Expr* subExpr) { // Don't warn if the types are arithmetic (in the C++ meaning), and: either - // at least one is a typedef (and if both are typedefs,they're different), + // at least one is a typedef or decltype (and if both are, they're different), // or the sub-expression involves some operation that is likely to change // types through promotion, or the sub-expression is an integer literal (so // its type generally depends on its value and suffix if any---even with a @@ -270,7 +270,8 @@ bool isOkToRemoveArithmeticCast( || t1->isRealFloatingType()) && ((t1.getLocalUnqualifiedType() != t2.getLocalUnqualifiedType() && (loplugin::TypeCheck(t1).Typedef() - || loplugin::TypeCheck(t2).Typedef())) + || loplugin::TypeCheck(t2).Typedef() + || llvm::isa<clang::DecltypeType>(t1) || llvm::isa<clang::DecltypeType>(t2))) || isArithmeticOp(subExpr) || llvm::isa<clang::IntegerLiteral>(subExpr->IgnoreParenImpCasts()))) { |