diff options
30 files changed, 68 insertions, 43 deletions
diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx index 8cd4f895b14a..ed36a83b9a39 100644 --- a/basegfx/source/polygon/b2dpolygontriangulator.cxx +++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx @@ -371,7 +371,7 @@ namespace basegfx while(aIter != maNewEdgeEntries.end()) { - delete (*aIter++); + delete *aIter++; } } diff --git a/compilerplugins/clang/test/unnecessaryparen.cxx b/compilerplugins/clang/test/unnecessaryparen.cxx index b7117a126edb..8621fe9e8746 100644 --- a/compilerplugins/clang/test/unnecessaryparen.cxx +++ b/compilerplugins/clang/test/unnecessaryparen.cxx @@ -91,6 +91,9 @@ int main() // "throw(x);"); it is unlikely that there are any actual occurrences of code like "-(-1)" that // would benefit from the parentheses readability-wise, compared to "- -1": (void) -(-1); // expected-error {{unnecessary parentheses around signed numeric literal [loplugin:unnecessaryparen]}} + + char *p = nullptr; + delete (p); // expected-error {{parentheses immediately inside delete expr [loplugin:unnecessaryparen]}} }; struct S2 { diff --git a/compilerplugins/clang/unnecessaryparen.cxx b/compilerplugins/clang/unnecessaryparen.cxx index 8e038319fda8..caeadcac0072 100644 --- a/compilerplugins/clang/unnecessaryparen.cxx +++ b/compilerplugins/clang/unnecessaryparen.cxx @@ -93,6 +93,7 @@ public: bool VisitConditionalOperator(ConditionalOperator const * expr); bool VisitBinaryConditionalOperator(BinaryConditionalOperator const * expr); bool VisitMemberExpr(const MemberExpr *f); + bool VisitCXXDeleteExpr(const CXXDeleteExpr *); private: void VisitSomeStmt(Stmt const * stmt, const Expr* cond, StringRef stmtName); @@ -339,6 +340,28 @@ bool UnnecessaryParen::VisitCallExpr(const CallExpr* callExpr) return true; } +bool UnnecessaryParen::VisitCXXDeleteExpr(const CXXDeleteExpr* deleteExpr) +{ + if (ignoreLocation(deleteExpr)) + return true; + + auto parenExpr = dyn_cast<ParenExpr>(ignoreAllImplicit(deleteExpr->getArgument())); + if (!parenExpr) + return true; + if (parenExpr->getLocStart().isMacroID()) + return true; + // assignments need extra parentheses or they generate a compiler warning + auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr()); + if (binaryOp && binaryOp->getOpcode() == BO_Assign) + return true; + report( + DiagnosticsEngine::Warning, "parentheses immediately inside delete expr", + parenExpr->getLocStart()) + << parenExpr->getSourceRange(); + handled_.insert(parenExpr); + return true; +} + bool UnnecessaryParen::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr* callExpr) { if (ignoreLocation(callExpr)) diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx index 94f07cdfd3f3..3d3271ab86c0 100644 --- a/connectivity/source/drivers/mork/MQueryHelper.cxx +++ b/connectivity/source/drivers/mork/MQueryHelper.cxx @@ -99,7 +99,7 @@ void MQueryHelper::clear_results() { resultsArray::iterator iter = m_aResults.begin(); while ( iter != m_aResults.end() ) { - delete (*iter); + delete *iter; ++iter; } m_aResults.clear(); diff --git a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx index aaa506303d5c..6f1d6e67e55c 100644 --- a/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx +++ b/dbaccess/source/core/dataaccess/myucp_datasupplier.cxx @@ -80,7 +80,7 @@ DataSupplier_Impl::~DataSupplier_Impl() while ( it != end ) { - delete (*it); + delete *it; ++it; } } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 1dcff3df8fb8..ce1fd074f69f 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -549,11 +549,11 @@ void UpdateDialog::dispose() for ( std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); i != m_ListboxEntries.end(); ++i ) { - delete (*i); + delete *i; } for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) { - delete (*i); + delete *i; } m_pUpdates.disposeAndClear(); m_pchecking.clear(); diff --git a/filter/source/flash/swfexporter.cxx b/filter/source/flash/swfexporter.cxx index c56a6ea1871e..608de8b4fdd8 100644 --- a/filter/source/flash/swfexporter.cxx +++ b/filter/source/flash/swfexporter.cxx @@ -65,7 +65,7 @@ PageInfo::~PageInfo() const std::vector<ShapeInfo*>::iterator aEnd( maShapesVector.end() ); while( aIter != aEnd ) { - delete (*aIter++); + delete *aIter++; } } diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index 823f71ca82f6..07c200d90dc8 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -76,13 +76,13 @@ void TypeDetectionImporter::fillFilterVector( XMLFilterVector& rFilters ) if( pFilter ) rFilters.push_back( pFilter ); - delete (*aIter++); + delete *aIter++; } // now delete type nodes aIter = maTypeNodes.begin(); while( aIter != maTypeNodes.end() ) - delete (*aIter++); + delete *aIter++; } static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rData ) diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx index 896f6e8dc05d..1b92af47f6c5 100644 --- a/filter/source/xsltdialog/xmlfilterjar.cxx +++ b/filter/source/xsltdialog/xmlfilterjar.cxx @@ -284,7 +284,7 @@ void XMLFilterJarHelper::openPackage( const OUString& rPackageURL, XMLFilterVect else { // failed to copy all files - delete (*aIter); + delete *aIter; } ++aIter; } diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 2146ddd1a1be..c0f607e7f139 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -1001,7 +1001,7 @@ void XMLFilterSettingsDialog::disposeFilterList() std::vector< filter_info_impl* >::iterator aIter( maFilterVector.begin() ); while( aIter != maFilterVector.end() ) { - delete (*aIter++); + delete *aIter++; } maFilterVector.clear(); diff --git a/idlc/source/aststack.cxx b/idlc/source/aststack.cxx index 13afe71bd886..f5a3315e3b24 100644 --- a/idlc/source/aststack.cxx +++ b/idlc/source/aststack.cxx @@ -35,7 +35,7 @@ AstStack::~AstStack() for(sal_uInt32 i=0; i < m_top; i++) { if (m_stack[i]) - delete(m_stack[i]); + delete m_stack[i]; } rtl_freeMemory(m_stack); diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx index d6ef48719790..28aa9030d44e 100644 --- a/sc/source/filter/lotus/tool.cxx +++ b/sc/source/filter/lotus/tool.cxx @@ -391,7 +391,7 @@ LotusRangeList::~LotusRangeList () { std::vector<LotusRange*>::iterator pIter; for (pIter = maRanges.begin(); pIter != maRanges.end(); ++pIter) - delete (*pIter); + delete *pIter; } LR_ID LotusRangeList::GetIndex( const LotusRange &rRef ) diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index d80c867c092f..f3147046c2fd 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -864,7 +864,7 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) else { if (*aItr) - delete (*aItr); + delete *aItr; aItr = aActions.erase(aItr); } } @@ -876,7 +876,7 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc) OSL_ENSURE((*aItr)->nActionType == SC_CAT_CONTENT, "wrong action type"); SetNewCell(static_cast<ScMyContentAction*>(*aItr)); if (*aItr) - delete (*aItr); + delete *aItr; aItr = aActions.erase(aItr); } if (aProtect.getLength()) diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index c6f56ee27a78..9257197af101 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -495,8 +495,7 @@ void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBinding return; } - if ( pContext ) - delete( pContext ); + delete pContext; pContext = pCon; pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() ); pContext->GetWindow()->Show(); diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx index 2f7310410719..8b675e975d13 100644 --- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx +++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx @@ -221,7 +221,7 @@ public: if( ( *aIter )->mpView == rView ) { SAL_INFO("slideshow", "view removed" ); - delete ( *aIter ); + delete *aIter; maTransitions.erase( aIter ); break; } diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 3591a25cc18e..6ef160d87a0f 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -142,7 +142,7 @@ FmParentData::~FmParentData() { for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin(); i != m_aChildren.end(); ++i) - delete (*i); + delete *i; } Image FmFormItem::GetImage() const @@ -509,7 +509,7 @@ void FmFilterModel::Clear() for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin(); i != m_aChildren.end(); ++i) - delete (*i); + delete *i; m_aChildren.clear(); } diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index a4b65b5297aa..219ced254d44 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -617,7 +617,7 @@ bool Gallery::CreateTheme( const OUString& rThemeName ) false, true, 0, false ); aThemeList.push_back( pNewEntry ); - delete( new GalleryTheme( this, pNewEntry ) ); + delete new GalleryTheme( this, pNewEntry ); Broadcast( GalleryHint( GalleryHintType::THEME_CREATED, rThemeName ) ); bRet = true; } diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx index 6b9f2405a7d8..a9fcb50a9673 100644 --- a/svx/source/sidebar/nbdtmg.cxx +++ b/svx/source/sidebar/nbdtmg.cxx @@ -735,7 +735,7 @@ void OutlineTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uI pItemArr->bIsCustomized = true; }else if ((eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) { if (_pSet->pBrushItem) { - delete (_pSet->pBrushItem); + delete _pSet->pBrushItem; _pSet->pBrushItem=nullptr; } if (aFmt.GetBrush()) diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 854d445f83fd..9361d3620fbf 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -714,7 +714,7 @@ void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFo if(rPaintWindow.getTemporaryTarget()) { // get rid of temp target again - delete (&rPaintWindow); + delete &rPaintWindow; } else { diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 1fd2aca90d1d..ecc2c78d90dd 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -1420,7 +1420,7 @@ SdrUndoPageList::~SdrUndoPageList() { if(bItsMine) { - delete (&mrPage); + delete &mrPage; } } diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 6dd0a3a6cd11..e19316445785 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -490,7 +490,7 @@ void SwDoc::SetDefaultTOXBase(const SwTOXBase& rBase) } if (!prBase) return; - delete (*prBase); + delete *prBase; (*prBase) = new SwTOXBase(rBase); } diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index a821eb5b10c4..a0621956e730 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -55,7 +55,7 @@ class SwPageNumAndTypeOfAnchors for ( std::vector< tEntry* >::iterator aIter = maObjList.begin(); aIter != maObjList.end(); ++aIter ) { - delete (*aIter); + delete *aIter; } maObjList.clear(); } diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 3a13cc7f8ae4..61315e73e4b3 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -109,7 +109,7 @@ void SwPagePreviewLayout::ClearPreviewPageData() aPageDelIter != maPreviewPages.end(); ++aPageDelIter ) { - delete (*aPageDelIter); + delete *aPageDelIter; } maPreviewPages.clear(); } diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index ba01d7508f7b..e8fe5322d5fe 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -2657,7 +2657,7 @@ TaskManager::notifyInsert( std::vector< ContentEventNotifier* >* listeners,const while( it != listeners->end() ) { (*it)->notifyChildInserted( aChildName ); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2671,7 +2671,7 @@ TaskManager::notifyContentDeleted( std::vector< ContentEventNotifier* >* listene while( it != listeners->end() ) { (*it)->notifyDeleted(); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2686,7 +2686,7 @@ TaskManager::notifyContentRemoved( std::vector< ContentEventNotifier* >* listene while( it != listeners->end() ) { (*it)->notifyRemoved( aChildName ); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2724,7 +2724,7 @@ TaskManager::notifyPropertyAdded( std::vector< PropertySetInfoChangeNotifier* >* while( it != listeners->end() ) { (*it)->notifyPropertyAdded( aPropertyName ); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2739,7 +2739,7 @@ TaskManager::notifyPropertyRemoved( std::vector< PropertySetInfoChangeNotifier* while( it != listeners->end() ) { (*it)->notifyPropertyRemoved( aPropertyName ); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2853,7 +2853,7 @@ TaskManager::notifyContentExchanged( std::vector< std::vector< ContentEventNotif while( it != listeners->end() ) { (*it)->notifyExchanged(); - delete (*it); + delete *it; ++it; } delete listeners; @@ -2892,7 +2892,7 @@ void TaskManager::notifyPropertyChanges( std::vector< PropertyChangeNotifier* >* while( it != listeners->end() ) { (*it)->notifyPropertyChanged( seqChanged ); - delete (*it); + delete *it; ++it; } delete listeners; diff --git a/ucb/source/ucp/gio/gio_datasupplier.cxx b/ucb/source/ucp/gio/gio_datasupplier.cxx index bbb0cbcca594..d459ec12ff85 100644 --- a/ucb/source/ucp/gio/gio_datasupplier.cxx +++ b/ucb/source/ucp/gio/gio_datasupplier.cxx @@ -90,7 +90,7 @@ DataSupplier::~DataSupplier() while ( it != end ) { - delete (*it); + delete *it; ++it; } } diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx index 9d6f4074090c..a1852326c14a 100644 --- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx +++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx @@ -95,7 +95,7 @@ DataSupplier_Impl::~DataSupplier_Impl() while ( it != end ) { - delete (*it); + delete *it; ++it; } } diff --git a/ucb/source/ucp/package/pkgdatasupplier.cxx b/ucb/source/ucp/package/pkgdatasupplier.cxx index 36baef380ae6..dff19828ceed 100644 --- a/ucb/source/ucp/package/pkgdatasupplier.cxx +++ b/ucb/source/ucp/package/pkgdatasupplier.cxx @@ -95,7 +95,7 @@ DataSupplier_Impl::~DataSupplier_Impl() while ( it != end ) { - delete (*it); + delete *it; ++it; } } diff --git a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx index f33a116d978f..5a36dded1271 100644 --- a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx +++ b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx @@ -91,7 +91,7 @@ DataSupplier_Impl::~DataSupplier_Impl() while ( it != end ) { - delete (*it); + delete *it; ++it; } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 80af9ea8d937..a55365914fb2 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -2694,7 +2694,7 @@ SvStream& ReadGDIMetaFile( SvStream& rIStm, GDIMetaFile& rGDIMetaFile ) { // to avoid possible compiler optimizations => new/delete rIStm.Seek( nStmPos ); - delete( new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ) ); + delete new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ); } } catch (...) @@ -2727,7 +2727,7 @@ SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile ) } else { - delete( new SVMConverter( rOStm, const_cast< GDIMetaFile& >( rGDIMetaFile ), CONVERT_TO_SVM1 ) ); + delete new SVMConverter( rOStm, const_cast< GDIMetaFile& >( rGDIMetaFile ), CONVERT_TO_SVM1 ); } #ifdef DEBUG diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 9679bfe8a669..81293655dea7 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -3305,21 +3305,21 @@ void XMLShapeExport::ImpExportMediaShape( xPropSet->getPropertyValue( aLoopStr ) >>= bLoop; mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aLoopStr ); mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bLoop ? aTrueStr : aFalseStr ); - delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) ); + delete new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ); bool bMute = false; const OUString aMuteStr( "Mute" ); xPropSet->getPropertyValue( aMuteStr ) >>= bMute; mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aMuteStr ); mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bMute ? aTrueStr : aFalseStr ); - delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) ); + delete new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ); sal_Int16 nVolumeDB = 0; const OUString aVolumeDBStr( "VolumeDB" ); xPropSet->getPropertyValue("VolumeDB") >>= nVolumeDB; mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aVolumeDBStr ); mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, OUString::number( nVolumeDB ) ); - delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) ); + delete new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ); media::ZoomLevel eZoom; const OUString aZoomStr( "Zoom" ); @@ -3344,7 +3344,7 @@ void XMLShapeExport::ImpExportMediaShape( { mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aZoomStr ); mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aZoomValue ); - delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) ); + delete new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ); } } |