Kaydet (Commit) f5893382 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst d7e08760
......@@ -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())))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment