/src/libreoffice/include/o3tl/deleter.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #ifndef INCLUDED_O3TL_DELETER_HXX |
11 | | #define INCLUDED_O3TL_DELETER_HXX |
12 | | |
13 | | #include <sal/config.h> |
14 | | |
15 | | #include <cstdlib> |
16 | | |
17 | | #if defined(__COVERITY__) && __COVERITY_MAJOR__ <= 2024 |
18 | | #define suppress_fun_call_w_exception(expr) \ |
19 | | do \ |
20 | | { \ |
21 | | try \ |
22 | | { \ |
23 | | expr; \ |
24 | | } \ |
25 | | catch (...) \ |
26 | | { \ |
27 | | std::terminate(); \ |
28 | | } \ |
29 | | } while (false) |
30 | | #else |
31 | | #define suppress_fun_call_w_exception(expr) \ |
32 | 1.02G | do \ |
33 | 1.02G | { \ |
34 | 1.02G | expr; \ |
35 | 1.02G | } while (false) |
36 | | #endif |
37 | | |
38 | | namespace o3tl |
39 | | { |
40 | | /** To markup std::unique_ptr that coverity warns might throw exceptions |
41 | | which won't throw in practice, or where std::terminate is |
42 | | an acceptable response if they do |
43 | | */ |
44 | | template <typename T> struct default_delete |
45 | | { |
46 | 217M | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); }Unexecuted instantiation: o3tl::default_delete<vcl::PaintBufferGuard>::operator()(vcl::PaintBufferGuard*) Unexecuted instantiation: o3tl::default_delete<DragDropInfo>::operator()(DragDropInfo*) Unexecuted instantiation: o3tl::default_delete<vcl::Cursor>::operator()(vcl::Cursor*) Unexecuted instantiation: o3tl::default_delete<TextDDInfo>::operator()(TextDDInfo*) Unexecuted instantiation: o3tl::default_delete<ImplDockingWindowWrapper>::operator()(ImplDockingWindowWrapper*) Unexecuted instantiation: o3tl::default_delete<SvxIconChoiceCtrl_Impl>::operator()(SvxIconChoiceCtrl_Impl*) o3tl::default_delete<ScColorScaleEntry>::operator()(ScColorScaleEntry*) Line | Count | Source | 46 | 564 | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<ScDocument>::operator()(ScDocument*) o3tl::default_delete<ScTable>::operator()(ScTable*) Line | Count | Source | 46 | 254k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<ScViewCfg>::operator()(ScViewCfg*) Unexecuted instantiation: o3tl::default_delete<ScDocCfg>::operator()(ScDocCfg*) Unexecuted instantiation: o3tl::default_delete<ScAppCfg>::operator()(ScAppCfg*) o3tl::default_delete<ScDocShellModificator>::operator()(ScDocShellModificator*) Line | Count | Source | 46 | 37.5k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<sc::DataStream>::operator()(sc::DataStream*) Unexecuted instantiation: o3tl::default_delete<ScPrintFunc>::operator()(ScPrintFunc*) Unexecuted instantiation: o3tl::default_delete<ScNoteOverlay>::operator()(ScNoteOverlay*) Unexecuted instantiation: o3tl::default_delete<ClearableClipRegion>::operator()(ClearableClipRegion*) Unexecuted instantiation: o3tl::default_delete<ScInputHandler>::operator()(ScInputHandler*) o3tl::default_delete<ScColumn>::operator()(ScColumn*) Line | Count | Source | 46 | 217M | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<formula::FormulaDlg_Impl>::operator()(formula::FormulaDlg_Impl*) textlayoutdevice.cxx:o3tl::default_delete<drawinglayer::primitive2d::(anonymous namespace)::ImpTimedRefDev>::operator()(drawinglayer::primitive2d::(anonymous namespace)::ImpTimedRefDev*) Line | Count | Source | 46 | 5 | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<svt::TemplateFolderCacheImpl>::operator()(svt::TemplateFolderCacheImpl*) Unexecuted instantiation: o3tl::default_delete<FmPropBrw>::operator()(FmPropBrw*) Unexecuted instantiation: o3tl::default_delete<EmbeddedFontsManager>::operator()(EmbeddedFontsManager*) Unexecuted instantiation: o3tl::default_delete<svt::PopupWindowControllerImpl>::operator()(svt::PopupWindowControllerImpl*) o3tl::default_delete<OWriteStream_Impl>::operator()(OWriteStream_Impl*) Line | Count | Source | 46 | 152k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SmEditWindow>::operator()(SmEditWindow*) o3tl::default_delete<SwList>::operator()(SwList*) Line | Count | Source | 46 | 296k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwAsyncRetrieveInputStreamThreadConsumer>::operator()(SwAsyncRetrieveInputStreamThreadConsumer*) o3tl::default_delete<SwFlyNotify>::operator()(SwFlyNotify*) Line | Count | Source | 46 | 1.99k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwSaveClip>::operator()(SwSaveClip*) inftxt.cxx:o3tl::default_delete<(anonymous namespace)::SwTransparentTextGuard>::operator()((anonymous namespace)::SwTransparentTextGuard*) Line | Count | Source | 46 | 11 | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
o3tl::default_delete<SwRedlineItr>::operator()(SwRedlineItr*) Line | Count | Source | 46 | 227 | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwUndoSaveSection>::operator()(SwUndoSaveSection*) Unexecuted instantiation: o3tl::default_delete<SwReader>::operator()(SwReader*) o3tl::default_delete<PurgeGuard>::operator()(PurgeGuard*) Line | Count | Source | 46 | 28.5k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwMasterUsrPref>::operator()(SwMasterUsrPref*) Unexecuted instantiation: o3tl::default_delete<SwModuleOptions>::operator()(SwModuleOptions*) o3tl::default_delete<SwDLL>::operator()(SwDLL*) Line | Count | Source | 46 | 9 | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwDocFac>::operator()(SwDocFac*) Unexecuted instantiation: swdtflvr.cxx:o3tl::default_delete<(anonymous namespace)::SwTrnsfrActionAndUndo>::operator()((anonymous namespace)::SwTrnsfrActionAndUndo*) Unexecuted instantiation: o3tl::default_delete<SwShadowCursor>::operator()(SwShadowCursor*) o3tl::default_delete<UnoActionContext>::operator()(UnoActionContext*) Line | Count | Source | 46 | 27.9k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
o3tl::default_delete<writerfilter::dmapper::DomainMapper_Impl>::operator()(writerfilter::dmapper::DomainMapper_Impl*) Line | Count | Source | 46 | 6.26k | void operator()(T* p) noexcept { suppress_fun_call_w_exception(delete p); } |
Unexecuted instantiation: o3tl::default_delete<SwPauseThreadStarting>::operator()(SwPauseThreadStarting*) Unexecuted instantiation: o3tl::default_delete<sd::ViewShellManager::Implementation>::operator()(sd::ViewShellManager::Implementation*) Unexecuted instantiation: o3tl::default_delete<sd::ViewShell::Implementation>::operator()(sd::ViewShell::Implementation*) Unexecuted instantiation: viewshel.cxx:o3tl::default_delete<sd::(anonymous namespace)::KeepSlideSorterInSyncWithPageChanges>::operator()(sd::(anonymous namespace)::KeepSlideSorterInSyncWithPageChanges*) Unexecuted instantiation: o3tl::default_delete<sd::OutlineViewModelChangeGuard>::operator()(sd::OutlineViewModelChangeGuard*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::controller::InsertionIndicatorHandler::ForceShowContext>::operator()(sd::slidesorter::controller::InsertionIndicatorHandler::ForceShowContext*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::view::SlideSorterView::DrawLock>::operator()(sd::slidesorter::view::SlideSorterView::DrawLock*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::controller::SelectionObserver::Context>::operator()(sd::slidesorter::controller::SelectionObserver::Context*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::controller::SlideSorterController::ModelChangeLock>::operator()(sd::slidesorter::controller::SlideSorterController::ModelChangeLock*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::controller::DragAndDropContext>::operator()(sd::slidesorter::controller::DragAndDropContext*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::SlideSorter>::operator()(sd::slidesorter::SlideSorter*) Unexecuted instantiation: o3tl::default_delete<sd::slidesorter::view::ToolTip>::operator()(sd::slidesorter::view::ToolTip*) Unexecuted instantiation: o3tl::default_delete<sd::SdGlobalResourceContainer>::operator()(sd::SdGlobalResourceContainer*) Unexecuted instantiation: o3tl::default_delete<sd::ViewShellManager::UpdateLock>::operator()(sd::ViewShellManager::UpdateLock*) Unexecuted instantiation: o3tl::default_delete<sd::ToolBarManager::UpdateLock>::operator()(sd::ToolBarManager::UpdateLock*) Unexecuted instantiation: o3tl::default_delete<sd::GraphicViewShell>::operator()(sd::GraphicViewShell*) |
47 | | }; |
48 | | |
49 | | struct free_delete |
50 | | { |
51 | 736k | void operator()(void* p) { std::free(p); } |
52 | | }; |
53 | | |
54 | | template <typename uniqueptr> void reset_preserve_ptr_during(uniqueptr& ptr) |
55 | 3.87M | { |
56 | | // HACK: for the case where the dtor of the obj held by ptr will trigger |
57 | | // functions which expect ptr to still be set during the dtor. |
58 | | // e.g. SdrObject::GetBroadcaster() is called during the destructor |
59 | | // in SdrEdgeObj::Notify(). So delete first, then clear the pointer |
60 | 3.87M | delete ptr.get(); |
61 | | // coverity[leaked_storage] - not a leak, deleted on line above |
62 | 3.87M | (void)ptr.release(); |
63 | 3.87M | } void o3tl::reset_preserve_ptr_during<std::__1::unique_ptr<SdrObjPlusData, std::__1::default_delete<SdrObjPlusData> > >(std::__1::unique_ptr<SdrObjPlusData, std::__1::default_delete<SdrObjPlusData> >&) Line | Count | Source | 55 | 2.23M | { | 56 | | // HACK: for the case where the dtor of the obj held by ptr will trigger | 57 | | // functions which expect ptr to still be set during the dtor. | 58 | | // e.g. SdrObject::GetBroadcaster() is called during the destructor | 59 | | // in SdrEdgeObj::Notify(). So delete first, then clear the pointer | 60 | 2.23M | delete ptr.get(); | 61 | | // coverity[leaked_storage] - not a leak, deleted on line above | 62 | 2.23M | (void)ptr.release(); | 63 | 2.23M | } |
void o3tl::reset_preserve_ptr_during<std::__1::unique_ptr<SfxBroadcaster, std::__1::default_delete<SfxBroadcaster> > >(std::__1::unique_ptr<SfxBroadcaster, std::__1::default_delete<SfxBroadcaster> >&) Line | Count | Source | 55 | 1.63M | { | 56 | | // HACK: for the case where the dtor of the obj held by ptr will trigger | 57 | | // functions which expect ptr to still be set during the dtor. | 58 | | // e.g. SdrObject::GetBroadcaster() is called during the destructor | 59 | | // in SdrEdgeObj::Notify(). So delete first, then clear the pointer | 60 | 1.63M | delete ptr.get(); | 61 | | // coverity[leaked_storage] - not a leak, deleted on line above | 62 | 1.63M | (void)ptr.release(); | 63 | 1.63M | } |
|
64 | | } |
65 | | |
66 | | #endif |
67 | | |
68 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |