basegfx/source/polygon/b2dsvgpolypolygon.cxx        |    4 ++--
 compilerplugins/clang/redundantcast.cxx             |    9 +++++++++
 compilerplugins/clang/test/redundantcast.cxx        |   12 ++++++++++++
 emfio/source/reader/mtftools.cxx                    |    2 +-
 sd/source/ui/dlg/animobjs.cxx                       |    2 +-
 sd/source/ui/dlg/titledockwin.cxx                   |    2 +-
 toolkit/source/controls/table/gridtablerenderer.cxx |    2 +-
 vcl/source/window/window.cxx                        |    2 +-
 8 files changed, 28 insertions(+), 7 deletions(-)

New commits:
commit 1f2ff4a0a31c7919bc6d4e0ac63024252f0bd889
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Jul 20 15:55:59 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Jul 21 11:05:05 2023 +0200

    loplugin:redundantcast small improvement
    
    Change-Id: I2c96b367138b94d6178a3c4a0f83049f13a04f82
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154679
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx 
b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 6bb34614c6ae..fe4f646eb3ba 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -272,7 +272,7 @@ namespace basegfx::utils
 
                             // get first control point. It's the reflection of 
the PrevControlPoint
                             // of the last point. If not existent, use current 
point (see SVG)
-                            B2DPoint aPrevControl(B2DPoint(nLastX, nLastY));
+                            B2DPoint aPrevControl(nLastX, nLastY);
                             const sal_uInt32 nIndex(aCurrPoly.count() - 1);
 
                             if(aCurrPoly.areControlPointsUsed() && 
aCurrPoly.isPrevControlPointUsed(nIndex))
@@ -421,7 +421,7 @@ namespace basegfx::utils
 
                             // get first control point. It's the reflection of 
the PrevControlPoint
                             // of the last point. If not existent, use current 
point (see SVG)
-                            B2DPoint aPrevControl(B2DPoint(nLastX, nLastY));
+                            B2DPoint aPrevControl(nLastX, nLastY);
                             const sal_uInt32 nIndex(aCurrPoly.count() - 1);
                             const B2DPoint 
aPrevPoint(aCurrPoly.getB2DPoint(nIndex));
 
diff --git a/compilerplugins/clang/redundantcast.cxx 
b/compilerplugins/clang/redundantcast.cxx
index 80485e0e9bd6..eea609005228 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -373,6 +373,15 @@ bool RedundantCast::VisitVarDecl(VarDecl const * varDecl) {
     if (!varDecl->getInit())
         return true;
     visitAssign(varDecl->getType(), varDecl->getInit());
+    if (varDecl->getInitStyle() != VarDecl::CInit
+        && isa<CXXTemporaryObjectExpr>(varDecl->getInit())
+        && 
!compiler.getSourceManager().isMacroBodyExpansion(varDecl->getInit()->getBeginLoc()))
+    {
+        report(
+            DiagnosticsEngine::Warning, "redundant functional cast",
+            varDecl->getBeginLoc())
+            << varDecl->getSourceRange();
+    }
     return true;
 }
 
diff --git a/compilerplugins/clang/test/redundantcast.cxx 
b/compilerplugins/clang/test/redundantcast.cxx
index 0c1087ab32af..f3573d0ad20d 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -473,6 +473,18 @@ void testSalIntTypes() {
     (void) static_cast<Other>(n); // doesn't warn either
 }
 
+void testFunctionalCast2() {
+    struct S1 { S1(int, int, int, int) {} };
+
+    // expected-error@+1 {{redundant functional cast [loplugin:redundantcast]}}
+    S1 aTitleBarBox(S1(0, 0, 0, 0));
+    (void)aTitleBarBox;
+
+    // no warning expected
+#define S1_COL S1(0,0,0,0)
+    S1 aTest2(S1_COL);
+}
+
 int main() {
     testConstCast();
     testStaticCast();
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index f2446e1864de..0ba13d49727a 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -256,7 +256,7 @@ namespace emfio
 
         aFont.SetOrientation( 
Degree10(static_cast<sal_Int16>(rFont.lfEscapement)) );
 
-        Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) );
+        Size aFontSize( rFont.lfWidth, rFont.lfHeight );
         if ( rFont.lfHeight > 0 )
         {
             // #i117968# VirtualDevice is not thread safe, but filter is used 
in multithreading
diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 9abb892e037c..0174855e1825 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -516,7 +516,7 @@ void AnimationWindow::UpdateControl(bool const 
bDisableCtrls)
             ScopedVclPtrInstance< VirtualDevice > pVD;
             ::tools::Rectangle       aObjRect( pObject->GetCurrentBoundRect() 
);
             Size            aObjSize( aObjRect.GetSize() );
-            Point           aOrigin( Point( -aObjRect.Left(), -aObjRect.Top() 
) );
+            Point           aOrigin( -aObjRect.Left(), -aObjRect.Top() );
             MapMode         aMap( pVD->GetMapMode() );
             aMap.SetMapUnit( MapUnit::Map100thMM );
             aMap.SetOrigin( aOrigin );
diff --git a/sd/source/ui/dlg/titledockwin.cxx 
b/sd/source/ui/dlg/titledockwin.cxx
index 5a3f04c70f30..0550f05d2f8b 100644
--- a/sd/source/ui/dlg/titledockwin.cxx
+++ b/sd/source/ui/dlg/titledockwin.cxx
@@ -155,7 +155,7 @@ namespace sd
         int nInnerBottom = nOuterBottom - m_aBorder.Bottom() + 1;
 
         // Paint title bar background.
-        ::tools::Rectangle aTitleBarBox(::tools::Rectangle(nOuterLeft, 0, 
nOuterRight, nInnerTop - 1));
+        ::tools::Rectangle aTitleBarBox(nOuterLeft, 0, nOuterRight, nInnerTop 
- 1);
         rRenderContext.DrawRect(aTitleBarBox);
 
         if (nInnerLeft > nOuterLeft)
diff --git a/toolkit/source/controls/table/gridtablerenderer.cxx 
b/toolkit/source/controls/table/gridtablerenderer.cxx
index cb3fe2ec1228..aa49f4afddc1 100644
--- a/toolkit/source/controls/table/gridtablerenderer.cxx
+++ b/toolkit/source/controls/table/gridtablerenderer.cxx
@@ -444,7 +444,7 @@ namespace svt::table
 
     void GridTableRenderer::impl_paintCellImage( CellRenderContext const & 
i_context, Image const & i_image )
     {
-        Point imagePos( Point( i_context.aContentArea.Left(), 
i_context.aContentArea.Top() ) );
+        Point imagePos( i_context.aContentArea.Left(), 
i_context.aContentArea.Top() );
         Size imageSize = i_image.GetSizePixel();
         if ( i_context.aContentArea.GetWidth() > imageSize.Width() )
         {
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 79d966383877..6e5575b9013c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1519,7 +1519,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, 
tools::Long nY,
     if ( nFlags & PosSizeFlags::X )
     {
         tools::Long nOrgX = nX;
-        Point aPtDev( Point( nX+GetOutDev()->mnOutOffX, 0 ) );
+        Point aPtDev( nX+GetOutDev()->mnOutOffX, 0 );
         OutputDevice *pOutDev = GetOutDev();
         if( pOutDev->HasMirroredGraphics() )
         {

Reply via email to