[Libreoffice-commits] core.git: compilerplugins/clang

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 18 06:51:34 UTC 2019


 compilerplugins/clang/test/useuniqueptr.cxx |   12 +--
 compilerplugins/clang/useuniqueptr.cxx      |   94 +++++++++++++++++++++++-----
 2 files changed, 85 insertions(+), 21 deletions(-)

New commits:
commit 924da47e0343a5698547c8c82c13afbb012ff9c8
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 17 16:48:23 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 18 07:51:04 2019 +0100

    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 at collabora.co.uk>

diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx
index 74f8ae10a0bb..3d4f62d5dfa8 100644
--- a/compilerplugins/clang/test/useuniqueptr.cxx
+++ b/compilerplugins/clang/test/useuniqueptr.cxx
@@ -53,7 +53,7 @@ class Class4 {
     ~Class4()
     {
         for (int i = 0; i < 10; ++i)
-            delete m_pbar[i]; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete m_pbar[i]; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 class Class5 {
@@ -89,7 +89,7 @@ class Class7 {
     ~Class7()
     {
         for (int i = 0; i < 10; ++i)
-            delete m_pbar[i]; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete m_pbar[i]; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 class Class8 {
@@ -162,7 +162,7 @@ class Foo12 {
     {
         int i = 0;
         while (i < 10)
-            delete m_pbar[i++]; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete m_pbar[i++]; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 #define DELETEZ( p )    ( delete p,p = NULL )
@@ -224,7 +224,7 @@ class Foo18 {
     ~Foo18()
     {
         for (auto aIter = m_pbar1.begin(); aIter != m_pbar1.end(); ++aIter)
-            delete *aIter; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete *aIter; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 
@@ -272,7 +272,7 @@ class Foo23
     ~Foo23()
     {
         for(auto it = map.begin(); it != map.end(); ++it)
-            delete it->second; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete it->second; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 
@@ -283,7 +283,7 @@ class Foo24
     ~Foo24()
     {
         for ( HTMLAttrs::const_iterator it = m_aSetAttrTab.begin(); it != m_aSetAttrTab.end(); ++it )
-            delete *it; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
+            delete *it; // expected-error {{rather manage this member with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
     }
 };
 
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index 02e7696ee725..6a006e9a7a2c 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -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,


More information about the Libreoffice-commits mailing list