[Libreoffice-commits] core.git: compilerplugins/clang sc/source sd/source writerfilter/source

Stephan Bergmann sbergman at redhat.com
Fri Sep 15 16:51:09 UTC 2017


 compilerplugins/clang/redundantcast.cxx           |   10 +++-------
 compilerplugins/clang/test/redundantcast.cxx      |   17 +++++++++++++++++
 compilerplugins/clang/test/redundantcast.hxx      |    2 ++
 sc/source/ui/unoobj/PivotTableDataProvider.cxx    |    4 ++--
 sd/source/ui/unoidl/unopage.cxx                   |    2 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    2 +-
 6 files changed, 26 insertions(+), 11 deletions(-)

New commits:
commit 7282b25f226bf73ed88dbd3d0a6f265f1626d190
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 15 18:45:17 2017 +0200

    Fix loplugin:redundantcast's VisitCXXFunctionalCastExpr
    
    ...when t1 is ElaboratedType sugar (which isn't only used when the type is
    written with an elaborated type keyword, but also when it is written with a
    qualified name).
    
    (I originally wrote testArithmeticTypedefs to track down a different issue,
    which turned out to be a non-issue, with this fix as fall-out.  So that test
    doesn't quite match the theme of this commit, but is a worthwhile addition
    nonetheless.)
    
    Change-Id: Ic447da4399853d7d045e3e2e7ade8ddf52d89749

diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 32f7e8bd7fd9..dba573387743 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -650,19 +650,15 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp
     }
 
     auto const t1 = expr->getTypeAsWritten();
-    auto const t2 = sub->getType().getDesugaredType(compiler.getASTContext()); // look through templated wrapped types
-    if (t1 != t2)
-        return true;
-    // if we are casting from/to a typedef, ignore it, even if the underlying types are the same
-    if ((loplugin::TypeCheck(t1).Typedef() || loplugin::TypeCheck(sub->getType()).Typedef())
-        && t1 != sub->getType())
+    auto const t2 = sub->getType();
+    if (t1.getCanonicalType() != t2.getCanonicalType())
         return true;
     if (!isOkToRemoveArithmeticCast(t1, t2, expr->getSubExpr()))
         return true;
     report(
         DiagnosticsEngine::Warning,
         "redundant functional cast from %0 to %1", expr->getExprLoc())
-        << sub->getType() << t1 << expr->getSourceRange();
+        << t2 << t1 << expr->getSourceRange();
     return true;
 }
 
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index db1268b8b87b..5a56ec42e32e 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -300,6 +300,23 @@ bool testCStyleCastOfTemplateMethodResult(Enum1Item* item) {
     return (Enum1)item->GetValue() == Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}}
 }
 
+using T1 = int;
+T1 nt1r() { return 0; }
+void testArithmeticTypedefs() {
+    (void) static_cast<T1>(nir());
+    (void) T1(nir());
+    (void) (T1) nir();
+    (void) static_cast<int>(nt1r());
+    (void) int(nt1r());
+    (void) (int) nt1r();
+    using T2 = T1;
+    (void) static_cast<T2>(nt1r());
+    (void) T2(nt1r());
+    (void) (T2) nt1r();
+    (void) static_cast<T1>(nt1r()); // expected-error {{redundant}}
+    (void) T1(nt1r()); // expected-error {{redundant}}
+    (void) (T1) nt1r(); // expected-error {{redundant}}
+}
 
 int main() {
     testConstCast();
diff --git a/compilerplugins/clang/test/redundantcast.hxx b/compilerplugins/clang/test/redundantcast.hxx
index e87da7a55fe4..014aecea4dc3 100644
--- a/compilerplugins/clang/test/redundantcast.hxx
+++ b/compilerplugins/clang/test/redundantcast.hxx
@@ -30,6 +30,8 @@ S const && csx();
 S nsr();
 S const csr();
 
+void testArithmeticTypedefs();
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index 7d5a3bfa90c7..581e5a9c9b25 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -358,9 +358,9 @@ void PivotTableDataProvider::collectPivotTableData()
         if (!xDimProp.is() || !xDimSupp.is())
             continue;
 
-        sheet::DataPilotFieldOrientation eDimOrient = sheet::DataPilotFieldOrientation(
+        sheet::DataPilotFieldOrientation eDimOrient =
             ScUnoHelpFunctions::GetEnumProperty(xDimProp, SC_UNO_DP_ORIENTATION,
-                                                sheet::DataPilotFieldOrientation_HIDDEN));
+                                                sheet::DataPilotFieldOrientation_HIDDEN);
 
         if (eDimOrient == sheet::DataPilotFieldOrientation_HIDDEN)
             continue;
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 5976b90b56fa..84f7a8399f36 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1046,7 +1046,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
             : view::PaperOrientation_LANDSCAPE);
         break;
     case WID_PAGE_EFFECT:
-        aAny <<= presentation::FadeEffect(GetPage()->GetFadeEffect());
+        aAny <<= GetPage()->GetFadeEffect();
         break;
     case WID_PAGE_CHANGE:
         aAny <<= (sal_Int32)( GetPage()->GetPresChange() );
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1b777821b8b3..86bc36629fa7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1040,7 +1040,7 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
                 aFrameProperties.push_back(comphelper::makePropertyValue("VertOrientRelation", sal_Int16(rAppendContext.pLastParagraphProperties->GetvAnchor())));
 
             if( rAppendContext.pLastParagraphProperties->GetWrap() >= text::WrapTextMode_NONE )
-                aFrameProperties.push_back(comphelper::makePropertyValue("Surround", text::WrapTextMode(rAppendContext.pLastParagraphProperties->GetWrap())));
+                aFrameProperties.push_back(comphelper::makePropertyValue("Surround", rAppendContext.pLastParagraphProperties->GetWrap()));
 
             lcl_MoveBorderPropertiesToFrame(aFrameProperties,
                 rAppendContext.pLastParagraphProperties->GetStartingRange(),


More information about the Libreoffice-commits mailing list