[Libreoffice-commits] core.git: compilerplugins/clang drawinglayer/source editeng/source emfio/source lotuswordpro/source sal/qa sd/source svgio/source vcl/workben

Noel Grandin noel.grandin at collabora.co.uk
Fri Dec 29 17:19:47 UTC 2017


 compilerplugins/clang/unnecessaryparen.cxx                   |   46 ++++++-----
 drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx |    2 
 editeng/source/accessibility/AccessibleSelectionBase.cxx     |    2 
 emfio/source/emfuno/xemfparser.cxx                           |    2 
 lotuswordpro/source/filter/lwpfont.cxx                       |    4 
 sal/qa/osl/file/osl_File.cxx                                 |    2 
 sd/source/core/EffectMigration.cxx                           |    2 
 svgio/source/svguno/xsvgparser.cxx                           |    2 
 vcl/workben/vcldemo.cxx                                      |    2 
 9 files changed, 35 insertions(+), 29 deletions(-)

New commits:
commit d460842616d467dfaf7b51ac2db94adb1ff5cbb0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Dec 29 12:23:33 2017 +0200

    loplugin:unnecessaryparen improve return check
    
    Change-Id: I8128aa4b5fc60efd1dbf5971cdde11e588f5f64b
    Reviewed-on: https://gerrit.libreoffice.org/47167
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx
index db241024dba4..ba6c62a78e43 100644
--- a/compilerplugins/clang/unnecessaryparen.cxx
+++ b/compilerplugins/clang/unnecessaryparen.cxx
@@ -27,27 +27,33 @@ namespace {
 // Like clang::Stmt::IgnoreImplicit (lib/AST/Stmt.cpp), but also ignoring CXXConstructExpr and
 // looking through implicit UserDefinedConversion's member function call:
 Expr const * ignoreAllImplicit(Expr const * expr) {
-    if (auto const e = dyn_cast<ExprWithCleanups>(expr)) {
-        expr = e->getSubExpr();
-    }
-    if (auto const e = dyn_cast<CXXConstructExpr>(expr)) {
-        if (e->getNumArgs() == 1) {
-            expr = e->getArg(0);
+    while (true)
+    {
+        auto oldExpr = expr;
+        if (auto const e = dyn_cast<ExprWithCleanups>(expr)) {
+            expr = e->getSubExpr();
         }
-    }
-    if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) {
-        expr = e->GetTemporaryExpr();
-    }
-    if (auto const e = dyn_cast<CXXBindTemporaryExpr>(expr)) {
-        expr = e->getSubExpr();
-    }
-    while (auto const e = dyn_cast<ImplicitCastExpr>(expr)) {
-        expr = e->getSubExpr();
-        if (e->getCastKind() == CK_UserDefinedConversion) {
-            auto const ce = cast<CXXMemberCallExpr>(expr);
-            assert(ce->getNumArgs() == 0);
-            expr = ce->getImplicitObjectArgument();
+        else if (auto const e = dyn_cast<CXXConstructExpr>(expr)) {
+            if (e->getNumArgs() == 1) {
+                expr = e->getArg(0);
+            }
         }
+        else if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) {
+            expr = e->GetTemporaryExpr();
+        }
+        else if (auto const e = dyn_cast<CXXBindTemporaryExpr>(expr)) {
+            expr = e->getSubExpr();
+        }
+        else if (auto const e = dyn_cast<ImplicitCastExpr>(expr)) {
+            expr = e->getSubExpr();
+            if (e->getCastKind() == CK_UserDefinedConversion) {
+                auto const ce = cast<CXXMemberCallExpr>(expr);
+                assert(ce->getNumArgs() == 0);
+                expr = ce->getImplicitObjectArgument();
+            }
+        }
+        if (expr == oldExpr)
+            return expr;
     }
     return expr;
 }
@@ -261,7 +267,7 @@ bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt)
         return true;
 
     // only non-operator-calls for now
-    auto subExpr = parenExpr->getSubExpr();
+    auto subExpr = ignoreAllImplicit(parenExpr->getSubExpr());
     if (isa<CallExpr>(subExpr) && !isa<CXXOperatorCallExpr>(subExpr))
     {
         report(
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
index 85788ad978b3..9d0dd000bc6a 100644
--- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
+++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
@@ -182,7 +182,7 @@ namespace drawinglayer
 
         OUString SAL_CALL XPrimitive2DRenderer::getImplementationName()
         {
-            return(XPrimitive2DRenderer_getImplementationName());
+            return XPrimitive2DRenderer_getImplementationName();
         }
 
         sal_Bool SAL_CALL XPrimitive2DRenderer::supportsService(const OUString& rServiceName)
diff --git a/editeng/source/accessibility/AccessibleSelectionBase.cxx b/editeng/source/accessibility/AccessibleSelectionBase.cxx
index cc819b46db09..09975c9ecab0 100644
--- a/editeng/source/accessibility/AccessibleSelectionBase.cxx
+++ b/editeng/source/accessibility/AccessibleSelectionBase.cxx
@@ -77,7 +77,7 @@ namespace accessibility
     uno::Reference< XAccessible > SAL_CALL AccessibleSelectionBase::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     {
         ::osl::MutexGuard aGuard( implGetMutex() );
-        return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) );
+        return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex );
     }
 
 
diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx
index 7d0870025fa3..e9175de10d60 100644
--- a/emfio/source/emfuno/xemfparser.cxx
+++ b/emfio/source/emfuno/xemfparser.cxx
@@ -215,7 +215,7 @@ namespace emfio
 
         OUString SAL_CALL XEmfParser::getImplementationName()
         {
-            return(XEmfParser_getImplementationName());
+            return XEmfParser_getImplementationName();
         }
 
         sal_Bool SAL_CALL XEmfParser::supportsService(const OUString& rServiceName)
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index e9011a5ea3db..d49ca0d6ea35 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -409,7 +409,7 @@ OUString LwpFontNameManager::GetNameByIndex(sal_uInt16 index)
         return OUString();
 
     sal_uInt16 nameindex = m_pFontNames[index-1].GetFaceID();
-    return (m_FontTbl.GetFaceName(nameindex));
+    return m_FontTbl.GetFaceName(nameindex);
 }
 
 void LwpFontAttrManager::Read(LwpObjectStream *pStrm)
@@ -515,7 +515,7 @@ void LwpFontManager::Override(sal_uInt32 fontID, rtl::Reference<XFFont> const &
 
 OUString LwpFontManager::GetNameByID(sal_uInt32 fontID)
 {
-    return ( m_FNMgr.GetNameByIndex(GetFontNameIndex(fontID)) );//use font id for bullet?
+    return m_FNMgr.GetNameByIndex(GetFontNameIndex(fontID));//use font id for bullet?
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 509a78d5c0c2..a5fe20a03b9c 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -5145,7 +5145,7 @@ inline OUString getCurrentPID()
 #else
     nPID = getpid();
 #endif
-    return (OUString::number(nPID));
+    return OUString::number(nPID);
 }
 
 //~ do some clean up work after all test completed.
diff --git a/sd/source/core/EffectMigration.cxx b/sd/source/core/EffectMigration.cxx
index 9e25a7942e14..5594376234e3 100644
--- a/sd/source/core/EffectMigration.cxx
+++ b/sd/source/core/EffectMigration.cxx
@@ -1137,7 +1137,7 @@ void EffectMigration::SetPresentationOrder( SvxShape* pShape, sal_Int32 nNewPos
         while( aIter != aEnd )
         {
             aEffects.push_back( *(*aIter) );
-            rSequence.erase( (*aIter++) );
+            rSequence.erase( *aIter++ );
         }
 
         if( nNewPos > nCurrentPos )
diff --git a/svgio/source/svguno/xsvgparser.cxx b/svgio/source/svguno/xsvgparser.cxx
index 2b8e71a8df17..5a9bd9b7551e 100644
--- a/svgio/source/svguno/xsvgparser.cxx
+++ b/svgio/source/svguno/xsvgparser.cxx
@@ -165,7 +165,7 @@ namespace svgio
 
         OUString SAL_CALL XSvgParser::getImplementationName()
         {
-            return(XSvgParser_getImplementationName());
+            return XSvgParser_getImplementationName();
         }
 
         sal_Bool SAL_CALL XSvgParser::supportsService(const OUString& rServiceName)
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 623a77f695aa..fdc1f9b85098 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1986,7 +1986,7 @@ class DemoPopup : public FloatingWindow
         aSize.Width() -= 2;
         aSize.Height() -= 2;
         Color aColor( GetLineColor() );
-        SetLineColor( ( COL_GRAY ) );
+        SetLineColor( COL_GRAY );
         DrawRect( tools::Rectangle( Point( 1, 1 ), aSize ) );
         SetLineColor( aColor );
     }


More information about the Libreoffice-commits mailing list