[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Thu Feb 16 16:57:43 UTC 2017


 compilerplugins/clang/redundantcast.cxx |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit be067003098c9a9537b713742d14d8f502a9c0b7
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 16 17:56:08 2017 +0100

    Silence loplugin:redundantcast false warning
    
    ...that is curiously only reported when building with clang -std=gnu++17:
    
    > sc/qa/unit/ucalc_condformat.cxx:185:80: error: redundant const_cast from 'ScConditionalFormat *' to 'const ScConditionalFormat *', result is implictly cast to 'const ScConditionalFormat *const' [loplugin:redundantcast]
    >     CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong conditional format instance.", pCheck, const_cast<const ScConditionalFormat*>(pFormat));
    >     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:230:32: note: expanded from macro 'CPPUNIT_ASSERT_EQUAL_MESSAGE'
    >                               (actual),                \
    >                               ~^~~~~~~
    > 1 error generated.
    > make[1]: *** [solenv/gbuild/LinkTarget.mk:270: workdir/CxxObject/sc/qa/unit/ucalc_condformat.o] Error 1
    
    Change-Id: If2e8577bad4ec7454d584eb59106734d47f876ad

diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index c7561a7..0525fa5 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -176,11 +176,13 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
                 expr->getSubExpr()->IgnoreParenImpCasts());
             if (e != nullptr && !isRedundantConstCast(e)) {
                 auto t1 = e->getSubExpr()->getType().getCanonicalType();
-                auto t2 = expr->getType().getCanonicalType();
+                auto t3 = expr->getType().getCanonicalType();
                 bool ObjCLifetimeConversion;
-                if (t1.getTypePtr() == t2.getTypePtr()
-                    || compiler.getSema().IsQualificationConversion(
-                        t1, t2, false, ObjCLifetimeConversion))
+                if (t1.getTypePtr() == t3.getTypePtr()
+                    || (compiler.getSema().IsQualificationConversion(
+                            t1, t3, false, ObjCLifetimeConversion)
+                        && (e->getType().getCanonicalType().getTypePtr()
+                            != t3.getTypePtr())))
                 {
                     report(
                         DiagnosticsEngine::Warning,


More information about the Libreoffice-commits mailing list