update useunique_ptr loplugin
with more exclusions Change-Id: I95e7376ecf9c479d05b85c71f863d9ba40417538 Reviewed-on: https://gerrit.libreoffice.org/66552 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -299,6 +299,16 @@ void UseUniquePtr::CheckDeleteExpr(const FunctionDecl* functionDecl, const CXXDe
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool any_equal(std::string const & needle, T first) {
|
||||
return needle == first;
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
bool any_equal(std::string const & needle, T first, Args... args) {
|
||||
return needle == first || any_equal(needle, args...);
|
||||
}
|
||||
|
||||
void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const CXXDeleteExpr* deleteExpr, const VarDecl* varDecl)
|
||||
{
|
||||
// ignore globals for now
|
||||
@@ -464,6 +474,12 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C
|
||||
// linked list
|
||||
if (fn == SRCDIR "/lotuswordpro/source/filter/lwpfribptr.cxx")
|
||||
return;
|
||||
// complicated
|
||||
if (startswith(fn, SRCDIR "/connectivity/source/drivers/file/"))
|
||||
return;
|
||||
// complicated
|
||||
if (startswith(fn, SRCDIR "/unodevtools/source/skeletonmaker/"))
|
||||
return;
|
||||
|
||||
llvm::StringRef parentName;
|
||||
if (auto cxxMethodDecl = dyn_cast<CXXMethodDecl>(functionDecl))
|
||||
@@ -474,6 +490,9 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C
|
||||
// no idea what is going on here
|
||||
if (parentName == "ScChangeActionLinkEntry")
|
||||
return;
|
||||
// ok
|
||||
if (parentName == "SfxItemSet" || parentName == "SfxItemPool")
|
||||
return;
|
||||
// linked list
|
||||
if (parentName == "ScFunctionList" || parentName == "SwNodes"
|
||||
|| parentName == "SwUnoCursor" || parentName == "SortedResultSet"
|
||||
@@ -485,8 +504,11 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C
|
||||
if (parentName == "ScBroadcastAreaSlot")
|
||||
return;
|
||||
// complicated
|
||||
if (parentName == "SwFormatField" || parentName == "FontPropertyBox" || parentName == "SdFontPropertyBox"
|
||||
|| parentName == "SwHTMLParser" || parentName == "PDFWriterImpl")
|
||||
if (any_equal(parentName, "SwFormatField", "FontPropertyBox", "SdFontPropertyBox",
|
||||
"SwHTMLParser", "PDFWriterImpl", "SbiParser", "DictionaryList", "SwGlossaryHdl", "SwGlossaryGroupDlg"))
|
||||
return;
|
||||
// ok
|
||||
if (any_equal(parentName, "SbTreeListBox"))
|
||||
return;
|
||||
|
||||
if (functionDecl->getIdentifier())
|
||||
@@ -505,23 +527,61 @@ void UseUniquePtr::CheckDeleteLocalVar(const FunctionDecl* functionDecl, const C
|
||||
|| name == "reg_openRegistry")
|
||||
return;
|
||||
// linked list
|
||||
if (name == "TypeWriter::createBlop" || name == "ImplDeleteConfigData" || name == "Config::DeleteGroup"
|
||||
|| name == "Config::DeleteKey")
|
||||
if (any_equal(name, "TypeWriter::createBlop", "ImplDeleteConfigData", "Config::DeleteGroup",
|
||||
"Config::DeleteKey", "E3dView::DoDepthArrange",
|
||||
"DXFBlocks::Clear", "DXFTables::Clear", "DXFEntities::Clear",
|
||||
"PSWriter::WritePS", "PSWriter::ImplWriteActions", "CUtList::Destroy",
|
||||
"ScBroadcastAreaSlotMachine::UpdateBroadcastAreas"))
|
||||
return;
|
||||
// ok
|
||||
if (name == "write_uInt16s_FromOUString" || name == "ProgressMonitor::removeText"
|
||||
|| name == "StgDirEntry::SetSize" || name == "UCBStorage::CopyStorageElement_Impl"
|
||||
|| parentName == "SfxItemSet" || parentName == "SfxItemPool"
|
||||
|| name == "OutputDevice::ImplDrawPolyPolygon" || name == "OutputDevice::ImplDrawPolyPolygon"
|
||||
|| name == "ImplListBox::InsertEntry" || name == "Edit::dispose")
|
||||
if (any_equal(name, "write_uInt16s_FromOUString", "ProgressMonitor::removeText",
|
||||
"StgDirEntry::SetSize", "UCBStorage::CopyStorageElement_Impl"
|
||||
"OutputDevice::ImplDrawPolyPolygon", "OutputDevice::ImplDrawPolyPolygon",
|
||||
"ImplListBox::InsertEntry", "Edit::dispose",
|
||||
"ViewContact::deleteAllVOCs", "SfxViewFrame::ReleaseObjectShell_Impl",
|
||||
"SfxViewFrame::SwitchToViewShell_Impl", "OfaSmartTagOptionsTabPage::ClearListBox",
|
||||
"OfaSmartTagOptionsTabPage::FillItemSet", "doc_destroy", "lo_destroy",
|
||||
"callColumnFormatDialog"))
|
||||
return;
|
||||
// very dodgy
|
||||
if (name == "UCBStorage::OpenStorage_Impl")
|
||||
if (any_equal(name, "UCBStorage::OpenStorage_Impl", "SdTransferable::GetData"))
|
||||
return;
|
||||
// complicated ownership
|
||||
if (name == "ParseCMAP" || name == "OpenGLSalBitmap::CreateTexture" || name == "X11SalGraphicsImpl::drawAlphaBitmap"
|
||||
|| name == "SvEmbedTransferHelper::GetData" || name == "ORoadmap::dispose"
|
||||
|| name == "BrowseBox::SetMode" || name == "ExportDialog::GetFilterData")
|
||||
if (any_equal(name, "ParseCMAP", "OpenGLSalBitmap::CreateTexture", "X11SalGraphicsImpl::drawAlphaBitmap"
|
||||
"SvEmbedTransferHelper::GetData", "ORoadmap::dispose",
|
||||
"BrowseBox::SetMode", "ExportDialog::GetFilterData", "disposeComVariablesForBasic",
|
||||
"ImpEditEngine::ImpRemoveParagraph", "FactoryImpl::createAdapter",
|
||||
"SfxStateCache::SetVisibleState", "SfxBindings::QueryState",
|
||||
"ViewContact::deleteAllVOCs", "SvxMSDffManager::ProcessObj", "SvEmbedTransferHelper::GetData",
|
||||
"SvXMLExportPropertyMapper::Filter_", "SdXMLExport::ImpGetOrCreatePageMasterInfo",
|
||||
"SfxDocumentDescPage::FillItemSet", "SfxCustomPropertiesPage::FillItemSet",
|
||||
"SfxCmisPropertiesPage::FillItemSet", "SfxObjectShell::DoSaveCompleted",
|
||||
"SfxObjectShell::DoSave_Impl", "SfxObjectShell::PreDoSaveAs_Impl", "SfxObjectShell::Save_Impl",
|
||||
"SfxFrame::DoClose_Impl", "SfxBaseModel::load",
|
||||
"SdrTextObj::TakeTextRect", "SdrTableObj::TakeTextRect", "SdrObjCustomShape::TakeTextRect",
|
||||
"CellProperties::ItemSetChanged", "CellProperties::ItemChange",
|
||||
"TableLayouter::SetBorder", "TableLayouter::ClearBorderLayout",
|
||||
"ImpXPolygon::Resize", "SvxTextEditSourceImpl::GetBackgroundTextForwarder",
|
||||
"Svx3DSceneObject::setPropertyValueImpl", "lcl_RemoveTextEditOutlinerViews",
|
||||
"SdrObjEditView::SdrEndTextEdit", "SvxShape::_setPropertyValue",
|
||||
"AccessibleShape::Init", "AccessibleCell::Init",
|
||||
"SdrTableRtfExporter::WriteCell", "GalleryItem::_getPropertyValues",
|
||||
"VMLExport::StartShape", "DrawingML::WriteText",
|
||||
"MtfTools::DrawText", "FormulaTokenArray::RewriteMissing",
|
||||
"OSQLParseNode::negateSearchCondition", "OSQLParseNodesContainer::clearAndDelete",
|
||||
"SdFilter::GetLibrarySymbol", "SdPage::SetObjText",
|
||||
"SdDrawDocument::InsertBookmarkAsPage", "SdDrawDocument::InsertBookmarkAsObject",
|
||||
"SdDrawDocument::RemoveUnnecessaryMasterPages",
|
||||
"ScTable::CopyConditionalFormat", "ScTable::ValidQuery",
|
||||
"ScTable::SetOptimalHeight", "ScTable::SetOptimalHeightOnly", "ScCompiler::CompileString",
|
||||
"ScProgress::DeleteInterpretProgress", "ScInterpreter::ScBase",
|
||||
"UCBStorage::CopyStorageElement_Impl", "X11SalGraphicsImpl::drawAlphaBitmap",
|
||||
"MasterPagesSelector::ClearPageSet", "View::IsPresObjSelected",
|
||||
"SdDrawPagesAccess::remove", "SdMasterPagesAccess::remove", "View::InsertData",
|
||||
"RemoteServer::execute", "Implementation::ReleaseOutlinerView",
|
||||
"SwFormat::CopyAttrs", "FinitCore", "SwCursorShell::MoveFieldType", "SwExtraPainter::PaintExtra",
|
||||
"SwMarginPortion::AdjustRight", "SwPaintQueue::Repaint", "SwTOXMgr::UpdateOrInsertTOX",
|
||||
"SwBaseShell::Execute", "WW8Export::WriteSdrTextObj"))
|
||||
return;
|
||||
// complicated delete
|
||||
if (name == "X11SalObject::CreateObject")
|
||||
@@ -661,7 +721,7 @@ void UseUniquePtr::CheckLoopDelete(const FunctionDecl* functionDecl, const CXXDe
|
||||
if (fn == SRCDIR "/sw/source/core/bastyp/swcache.cxx")
|
||||
return;
|
||||
|
||||
CheckMemberDeleteExpr(functionDecl, deleteExpr, memberExpr, "rather manage with std::some_container<std::unique_ptr<T>>");
|
||||
CheckMemberDeleteExpr(functionDecl, deleteExpr, memberExpr, "rather manage this member with std::some_container<std::unique_ptr<T>>");
|
||||
}
|
||||
|
||||
if (varDecl)
|
||||
@@ -759,7 +819,6 @@ void UseUniquePtr::CheckLoopDelete(const FunctionDecl* functionDecl, const CXXDe
|
||||
if (fn == SRCDIR "/sw/qa/core/Test-BigPtrArray.cxx")
|
||||
return;
|
||||
|
||||
|
||||
report(
|
||||
DiagnosticsEngine::Warning,
|
||||
"loopdelete: rather manage this var with std::some_container<std::unique_ptr<T>>",
|
||||
@@ -842,6 +901,11 @@ void UseUniquePtr::CheckCXXForRangeStmt(const FunctionDecl* functionDecl, const
|
||||
// SfxPoolItem array
|
||||
if (fn == SRCDIR "/reportdesign/source/ui/report/ReportController.cxx")
|
||||
return;
|
||||
// complicated
|
||||
if (fn == SRCDIR "/svx/source/sdr/contact/viewcontact.cxx")
|
||||
return;
|
||||
if (fn == SRCDIR "/svx/source/sdr/contact/objectcontact.cxx")
|
||||
return;
|
||||
|
||||
report(
|
||||
DiagnosticsEngine::Warning,
|
||||
|
Reference in New Issue
Block a user