loplugin:unnecessaryparen improve return check
Change-Id: I8128aa4b5fc60efd1dbf5971cdde11e588f5f64b Reviewed-on: https://gerrit.libreoffice.org/47167 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
0e5fc156da
commit
d460842616
@ -27,27 +27,33 @@ namespace {
|
|||||||
// Like clang::Stmt::IgnoreImplicit (lib/AST/Stmt.cpp), but also ignoring CXXConstructExpr and
|
// Like clang::Stmt::IgnoreImplicit (lib/AST/Stmt.cpp), but also ignoring CXXConstructExpr and
|
||||||
// looking through implicit UserDefinedConversion's member function call:
|
// looking through implicit UserDefinedConversion's member function call:
|
||||||
Expr const * ignoreAllImplicit(Expr const * expr) {
|
Expr const * ignoreAllImplicit(Expr const * expr) {
|
||||||
if (auto const e = dyn_cast<ExprWithCleanups>(expr)) {
|
while (true)
|
||||||
expr = e->getSubExpr();
|
{
|
||||||
}
|
auto oldExpr = expr;
|
||||||
if (auto const e = dyn_cast<CXXConstructExpr>(expr)) {
|
if (auto const e = dyn_cast<ExprWithCleanups>(expr)) {
|
||||||
if (e->getNumArgs() == 1) {
|
expr = e->getSubExpr();
|
||||||
expr = e->getArg(0);
|
|
||||||
}
|
}
|
||||||
}
|
else if (auto const e = dyn_cast<CXXConstructExpr>(expr)) {
|
||||||
if (auto const e = dyn_cast<MaterializeTemporaryExpr>(expr)) {
|
if (e->getNumArgs() == 1) {
|
||||||
expr = e->GetTemporaryExpr();
|
expr = e->getArg(0);
|
||||||
}
|
}
|
||||||
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<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;
|
return expr;
|
||||||
}
|
}
|
||||||
@ -261,7 +267,7 @@ bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// only non-operator-calls for now
|
// only non-operator-calls for now
|
||||||
auto subExpr = parenExpr->getSubExpr();
|
auto subExpr = ignoreAllImplicit(parenExpr->getSubExpr());
|
||||||
if (isa<CallExpr>(subExpr) && !isa<CXXOperatorCallExpr>(subExpr))
|
if (isa<CallExpr>(subExpr) && !isa<CXXOperatorCallExpr>(subExpr))
|
||||||
{
|
{
|
||||||
report(
|
report(
|
||||||
|
@ -182,7 +182,7 @@ namespace drawinglayer
|
|||||||
|
|
||||||
OUString SAL_CALL XPrimitive2DRenderer::getImplementationName()
|
OUString SAL_CALL XPrimitive2DRenderer::getImplementationName()
|
||||||
{
|
{
|
||||||
return(XPrimitive2DRenderer_getImplementationName());
|
return XPrimitive2DRenderer_getImplementationName();
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Bool SAL_CALL XPrimitive2DRenderer::supportsService(const OUString& rServiceName)
|
sal_Bool SAL_CALL XPrimitive2DRenderer::supportsService(const OUString& rServiceName)
|
||||||
|
@ -77,7 +77,7 @@ namespace accessibility
|
|||||||
uno::Reference< XAccessible > SAL_CALL AccessibleSelectionBase::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
|
uno::Reference< XAccessible > SAL_CALL AccessibleSelectionBase::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( implGetMutex() );
|
::osl::MutexGuard aGuard( implGetMutex() );
|
||||||
return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) );
|
return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ namespace emfio
|
|||||||
|
|
||||||
OUString SAL_CALL XEmfParser::getImplementationName()
|
OUString SAL_CALL XEmfParser::getImplementationName()
|
||||||
{
|
{
|
||||||
return(XEmfParser_getImplementationName());
|
return XEmfParser_getImplementationName();
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Bool SAL_CALL XEmfParser::supportsService(const OUString& rServiceName)
|
sal_Bool SAL_CALL XEmfParser::supportsService(const OUString& rServiceName)
|
||||||
|
@ -409,7 +409,7 @@ OUString LwpFontNameManager::GetNameByIndex(sal_uInt16 index)
|
|||||||
return OUString();
|
return OUString();
|
||||||
|
|
||||||
sal_uInt16 nameindex = m_pFontNames[index-1].GetFaceID();
|
sal_uInt16 nameindex = m_pFontNames[index-1].GetFaceID();
|
||||||
return (m_FontTbl.GetFaceName(nameindex));
|
return m_FontTbl.GetFaceName(nameindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LwpFontAttrManager::Read(LwpObjectStream *pStrm)
|
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)
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -5145,7 +5145,7 @@ inline OUString getCurrentPID()
|
|||||||
#else
|
#else
|
||||||
nPID = getpid();
|
nPID = getpid();
|
||||||
#endif
|
#endif
|
||||||
return (OUString::number(nPID));
|
return OUString::number(nPID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ do some clean up work after all test completed.
|
//~ do some clean up work after all test completed.
|
||||||
|
@ -1137,7 +1137,7 @@ void EffectMigration::SetPresentationOrder( SvxShape* pShape, sal_Int32 nNewPos
|
|||||||
while( aIter != aEnd )
|
while( aIter != aEnd )
|
||||||
{
|
{
|
||||||
aEffects.push_back( *(*aIter) );
|
aEffects.push_back( *(*aIter) );
|
||||||
rSequence.erase( (*aIter++) );
|
rSequence.erase( *aIter++ );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nNewPos > nCurrentPos )
|
if( nNewPos > nCurrentPos )
|
||||||
|
@ -165,7 +165,7 @@ namespace svgio
|
|||||||
|
|
||||||
OUString SAL_CALL XSvgParser::getImplementationName()
|
OUString SAL_CALL XSvgParser::getImplementationName()
|
||||||
{
|
{
|
||||||
return(XSvgParser_getImplementationName());
|
return XSvgParser_getImplementationName();
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Bool SAL_CALL XSvgParser::supportsService(const OUString& rServiceName)
|
sal_Bool SAL_CALL XSvgParser::supportsService(const OUString& rServiceName)
|
||||||
|
@ -1986,7 +1986,7 @@ class DemoPopup : public FloatingWindow
|
|||||||
aSize.Width() -= 2;
|
aSize.Width() -= 2;
|
||||||
aSize.Height() -= 2;
|
aSize.Height() -= 2;
|
||||||
Color aColor( GetLineColor() );
|
Color aColor( GetLineColor() );
|
||||||
SetLineColor( ( COL_GRAY ) );
|
SetLineColor( COL_GRAY );
|
||||||
DrawRect( tools::Rectangle( Point( 1, 1 ), aSize ) );
|
DrawRect( tools::Rectangle( Point( 1, 1 ), aSize ) );
|
||||||
SetLineColor( aColor );
|
SetLineColor( aColor );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user