diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 08:45:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 11:21:36 +0200 |
commit | cda88ec7a43162df37098c4525c33451266a1575 (patch) | |
tree | 4f80310ab0ef1210b7dcd4d769b70c59fbc09f1e | |
parent | f45ff1a7147e6a9479c669f082dd74349c6bcb4b (diff) |
loplugin:simplifybool a little more aggressive
with expressions like !(a && b)
Change-Id: Id2acec2a8d0eaaa8e5e37dbd2cae7281be36572e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100040
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
21 files changed, 42 insertions, 38 deletions
diff --git a/compilerplugins/clang/buriedassign.cxx b/compilerplugins/clang/buriedassign.cxx index 1758a4fcbca8..658ad4789d87 100644 --- a/compilerplugins/clang/buriedassign.cxx +++ b/compilerplugins/clang/buriedassign.cxx @@ -255,12 +255,6 @@ static bool isAssignmentOp(clang::OverloadedOperatorKind Opc) || Opc == OO_AmpEqual || Opc == OO_CaretEqual || Opc == OO_PipeEqual; } -static bool isComparisonOp(clang::OverloadedOperatorKind op) -{ - return op == OO_Less || op == OO_Greater || op == OO_LessEqual || op == OO_GreaterEqual - || op == OO_EqualEqual || op == OO_ExclaimEqual; -} - static const Expr* IgnoreImplicitAndConversionOperator(const Expr* expr) { expr = compat::IgnoreImplicit(expr); @@ -570,7 +564,7 @@ void BuriedAssign::MarkConditionForControlLoops(Expr const* expr) else if (auto cxxOper = dyn_cast<CXXOperatorCallExpr>(expr)) { // handle: ((xxx = foo()) != error) - if (isComparisonOp(cxxOper->getOperator())) + if (compat::isComparisonOp(cxxOper)) { MarkIfAssignment(compat::IgnoreImplicit(cxxOper->getArg(0))->IgnoreParens()); MarkIfAssignment(compat::IgnoreImplicit(cxxOper->getArg(1))->IgnoreParens()); diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index ed9d3ec942dc..fb8791f978b4 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -300,6 +300,15 @@ inline clang::QualType getDeclaredReturnType(clang::FunctionDecl const * decl) { #endif } +// The isComparisonOp method on CXXOperatorCallExpr is not available yet for the clang we require +inline bool isComparisonOp(clang::CXXOperatorCallExpr const * callExpr) +{ + using namespace clang; + auto op = callExpr->getOperator(); + return op == OO_Less || op == OO_Greater || op == OO_LessEqual || op == OO_GreaterEqual + || op == OO_EqualEqual || op == OO_ExclaimEqual; +} + } #endif diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx index ff50cb47f0c7..89c262f54c98 100644 --- a/compilerplugins/clang/simplifybool.cxx +++ b/compilerplugins/clang/simplifybool.cxx @@ -302,7 +302,7 @@ bool SimplifyBool::VisitUnaryOperator(UnaryOperator const * expr) { if (binaryOp->isComparisonOp()) return expr; if (auto cxxOpCall = dyn_cast<CXXOperatorCallExpr>(expr)) - if (cxxOpCall->getOperator() == OO_ExclaimEqual) + if (compat::isComparisonOp(cxxOpCall)) return expr; return (Expr const*)nullptr; }; diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index ff01f3b6ba37..7ad53b04c97d 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -708,8 +708,8 @@ Sequence< Type > SAL_CALL ODbaseTable::getTypes( ) const Type* pEnd = pBegin + aTypes.getLength(); for(;pBegin != pEnd;++pBegin) { - if(!(*pBegin == cppu::UnoType<XKeysSupplier>::get()|| - *pBegin == cppu::UnoType<XDataDescriptorFactory>::get())) + if(*pBegin != cppu::UnoType<XKeysSupplier>::get() && + *pBegin != cppu::UnoType<XDataDescriptorFactory>::get()) { aOwnTypes.push_back(*pBegin); } diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 6e42831f21d5..7a41724f3bfa 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -791,7 +791,7 @@ void SAL_CALL Connection::documentEventOccured( const DocumentEvent& Event ) if (!m_bIsEmbedded) return; - if (!(Event.EventName == "OnSave" || Event.EventName == "OnSaveAs")) + if (Event.EventName != "OnSave" && Event.EventName != "OnSaveAs") return; commit(); // Commit and close transaction diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 401f48f7a664..29f34e3f17a0 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -159,7 +159,7 @@ void printEntries(SvxEntries* entries) bool SvxConfigPage::CanConfig( const OUString& aModuleId ) { - return !(aModuleId == "com.sun.star.script.BasicIDE" || aModuleId == "com.sun.star.frame.Bibliography"); + return aModuleId != "com.sun.star.script.BasicIDE" && aModuleId != "com.sun.star.frame.Bibliography"; } static std::unique_ptr<SfxTabPage> CreateSvxMenuConfigPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ) diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx index dd099c81fa05..4788c4d03d7a 100644 --- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx +++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx @@ -601,10 +601,11 @@ void ODefinitionContainer::approveNewObject(const OUString& _sName,const Referen // XPropertyChangeListener void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) { - MutexGuard aGuard(m_aMutex); - if( !(evt.PropertyName == PROPERTY_NAME || evt.PropertyName == "Title") ) + if( evt.PropertyName != PROPERTY_NAME && evt.PropertyName != "Title" ) return; + MutexGuard aGuard(m_aMutex); + m_bInPropertyChange = true; try { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 890fa3612a42..a6d099db9f5c 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -636,7 +636,7 @@ bool BackendImpl::PackageImpl::checkLicense( OUString sLicense = getTextFromURL(xCmdEnv, sHref); ////determine who has to agree to the license //check correct value for attribute - if ( ! (simplLicAttr->acceptBy == "user" || simplLicAttr->acceptBy == "admin")) + if ( simplLicAttr->acceptBy != "user" && simplLicAttr->acceptBy != "admin") throw css::deployment::DeploymentException( "Could not obtain attribute simple-license@accept-by or it has no valid value", nullptr, Any()); diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx index c14606db0000..19107d374019 100644 --- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx @@ -83,8 +83,8 @@ void ImageButtonToolbarController::executeControlCommand( const css::frame::Cont { SolarMutexGuard aSolarMutexGuard; // i73486 to be downward compatible use old and "wrong" also! - if( !(rControlCommand.Command == "SetImag" || - rControlCommand.Command == "SetImage") ) + if( rControlCommand.Command != "SetImag" && + rControlCommand.Command != "SetImage" ) return; for ( const NamedValue& rArg : rControlCommand.Arguments ) diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index 0ab68688c9be..b57c4696cb13 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -152,8 +152,8 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) else if (aType.startsWithIgnoreAsciiCase("http://purl.oclc.org/ooxml/officeDocument")) maOOXMLVariant = OOXMLVariant::ISO_Strict; - if ( !(aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional - || aType == "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument") ) //OOXML strict + if ( aType != "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional + && aType != "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument" ) //OOXML strict return; Reference<XUriReferenceFactory> xFactory = UriReferenceFactory::create( mxContext ); diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx index 9e3508361b56..e6c7598a2901 100644 --- a/package/source/manifest/ManifestImport.cxx +++ b/package/source/manifest/ManifestImport.cxx @@ -452,7 +452,8 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) assert(nLevel >= 1); OUString aConvertedName = ConvertName( aName ); - if ( !(!aStack.empty() && aStack.rbegin()->m_aConvertedName == aConvertedName) ) return; + if ( aStack.empty() || aStack.rbegin()->m_aConvertedName != aConvertedName ) + return; if ( aConvertedName == gsFileEntryElement && aStack.back().m_bValid ) { // root folder gets KeyInfo entry if any, for PGP encryption diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx index 81b1df15356d..fba25161b2e7 100644 --- a/sd/source/filter/eppt/pptx-text.cxx +++ b/sd/source/filter/eppt/pptx-text.cxx @@ -864,9 +864,7 @@ void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider* pBuProv, sal_Int1 else if ( aPropName == "Suffix" ) sSuffix = *o3tl::doAccess<OUString>(rPropValue.Value); #ifdef DBG_UTIL - else if ( ! ( - ( aPropName == "SymbolTextDistance" ) - || ( aPropName == "GraphicBitmap" ) ) ) + else if ( aPropName != "SymbolTextDistance" && aPropName != "GraphicBitmap" ) { OSL_FAIL( "Unknown Property" ); } diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index b39f4c9439ef..9da830b9b2b9 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2921,8 +2921,8 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharInde sal_Int32 nPos = 0; SwTextNode const* pNode(nullptr); const SwTextAttr *pHt = aHIter.next(&pNode); - while (pHt && !(nIdx >= pTextFrame->MapModelToView(pNode, pHt->GetStart()) - && nIdx < pTextFrame->MapModelToView(pNode, pHt->GetAnyEnd()))) + while (pHt && (nIdx < pTextFrame->MapModelToView(pNode, pHt->GetStart()) + || nIdx >= pTextFrame->MapModelToView(pNode, pHt->GetAnyEnd()))) { pHt = aHIter.next(&pNode); nPos++; diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 002582c6cb4a..a6ecd452e576 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1016,8 +1016,8 @@ namespace sw::mark bDeleteMark = rbIsOtherPosInRange || pMark->IsExpanded() || pSttIdx == nullptr - || !( pMark->GetMarkPos().nNode == rStt - && pMark->GetMarkPos().nContent == *pSttIdx ); + || pMark->GetMarkPos().nNode != rStt + || pMark->GetMarkPos().nContent != *pSttIdx; break; default: bDeleteMark = true; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index ceb7ada2f865..5eadf937b53e 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -161,8 +161,8 @@ void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) && // do not move if the InsPos is in the ContentArea of the Fly ( nullptr == ( pContentIdx = pFormat->GetContent().GetContentIdx() ) || - !(*pContentIdx < rInsPos.nNode && - rInsPos.nNode < pContentIdx->GetNode().EndOfSectionIndex()))) + (*pContentIdx >= rInsPos.nNode || + rInsPos.nNode >= pContentIdx->GetNode().EndOfSectionIndex()))) { bool bInsPos = false; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 477f83220f32..0f03a9265670 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2119,7 +2119,7 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, long const nOffset, } if( pOwnRedl && - !( pRStt->nNode <= aIdx && aIdx <= pREnd->nNode )) + ( pRStt->nNode > aIdx || aIdx > pREnd->nNode )) { // it's not in itself, so don't move it pOwnRedl = nullptr; diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 8da991f62451..093f8972c749 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -700,7 +700,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s !pMap->aName.isEmpty(); ++pMap ) { // OUString(UNO_NAME_PAGE_DESC_NAME) should keep its MAYBEVOID flag - if (!(RES_PAGEDESC == pMap->nWID && MID_PAGEDESC_PAGEDESCNAME == pMap->nMemberId)) + if (RES_PAGEDESC != pMap->nWID || MID_PAGEDESC_PAGEDESCNAME != pMap->nMemberId) pMap->nFlags &= ~PropertyAttribute::MAYBEVOID; } } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2e19f4e5bae6..85b215f790c8 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1509,7 +1509,7 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos ) if( pCurRedline ) { const SwPosition* pEnd = pCurRedline->End(); - if (!(pEnd->nNode == rNd && pEnd->nContent.GetIndex() <= nPos)) + if (pEnd->nNode != rNd || pEnd->nContent.GetIndex() > nPos) { switch( pCurRedline->GetType() ) { diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 11ef3d90df17..00cefea1e109 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3363,11 +3363,11 @@ void SwXTextDocument::getPostIts(tools::JsonWriter& rJsonWriter) void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments) { auto aIter = aArguments.find("type"); - if (!(aIter != aArguments.end() && aIter->second == "drop-down")) + if (aIter == aArguments.end() || aIter->second != "drop-down") return; aIter = aArguments.find("cmd"); - if (!(aIter != aArguments.end() && aIter->second == "selected")) + if (aIter == aArguments.end() || aIter->second != "selected") return; aIter = aArguments.find("data"); diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index 3b57ee5fdcdc..a5062cdeb8d0 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -628,10 +628,10 @@ rtl::Reference< Entity > readEntity( + sub.getName())); } if ((mode & RT_PARAM_REST) != 0 - && !(m == 1 - && ((reader.getMethodParameterTypeName( + && (m != 1 + || ((reader.getMethodParameterTypeName( j, 0)) - == "any"))) + != "any"))) { throw FileFormatException( key.getRegistryName(), diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index 32c61ad72497..23dc6c0a90fc 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -984,7 +984,8 @@ void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUStr Any aSelectionType ( _xProps->getPropertyValue( rPropName ) ); - if (!(aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == cppu::UnoType<view::SelectionType>::get())) + if (aSelectionType.getValueTypeClass() != TypeClass_ENUM || + aSelectionType.getValueType() != cppu::UnoType<view::SelectionType>::get()) return; ::view::SelectionType eSelectionType; |