compilerplugins/clang/check.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit f58933829dc6c11a06255ae8d5417dea56264c49
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Aug 16 22:15:05 2018 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Aug 17 08:19:48 2018 +0200

    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 <sberg...@redhat.com>

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())))
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to