compilerplugins/clang/refcounting.cxx | 3 +++ compilerplugins/clang/test/refcounting.cxx | 15 +++++++++++++++ 2 files changed, 18 insertions(+)
New commits: commit b0f1672a5db0379b0e5f424038fc38f5d699eceb Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Mon Feb 22 14:35:31 2021 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Feb 22 16:43:46 2021 +0100 Avoid loplugin:refounting in uninstantiated template code ...causing e.g. false positive > In file included from shell/source/win32/spsupp/COMOpenDocuments_x64.cxx:11: > In file included from shell/source/win32/spsupp/COMOpenDocuments.cxx:16: > In file included from shell/inc/spsupp\COMOpenDocuments.hpp:21: > shell/inc/spsupp/COMRefCounted.hpp(35,13): error: cppu::OWeakObject subclass 'COMRefCounted<Interfaces...>' being deleted via delete, should be managed via rtl::Reference [loplugin:refcounting] > delete this; > ^~~~~~~~~~~ with clang-cl on Windows. (Ideally, this would be made up for with setting this plugins' shouldVisitTemplateInstantiations() to true, see the TODO added in compilerplugins/clang/test/refcounting.cxx, but that would cause lots of other findings, so is left out for now.) Change-Id: Ia52b13498a0c7169b37ecf4882ce84c3cc1d2cc4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111339 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx index fa026877680b..f15e423aebd2 100644 --- a/compilerplugins/clang/refcounting.cxx +++ b/compilerplugins/clang/refcounting.cxx @@ -211,6 +211,9 @@ bool containsOWeakObjectSubclass(const QualType& qType) { bool containsOWeakObjectSubclass(const clang::Type* pType0) { if (!pType0) return false; + if (pType0->isDependentType()) { + return false; + } const clang::Type* pType = pType0->getUnqualifiedDesugaredType(); if (!pType) return false; diff --git a/compilerplugins/clang/test/refcounting.cxx b/compilerplugins/clang/test/refcounting.cxx index 69825e6fc47b..8a1f277829cc 100644 --- a/compilerplugins/clang/test/refcounting.cxx +++ b/compilerplugins/clang/test/refcounting.cxx @@ -57,4 +57,19 @@ void test2(UnoObject* pUnoObject) delete pUnoObject; } +template <typename T> struct Dependent : T +{ + void f() { delete this; } + //TODO: missing expected error@+1 {{cppu::OWeakObject subclass 'Dependent<UnoObject>' being deleted via delete, should be managed via rtl::Reference [loplugin:refcounting]}} + void g() { delete this; } +}; +struct Dummy +{ +}; +void dummy(Dependent<Dummy>* p1, Dependent<UnoObject>* p2) +{ + p1->f(); + p2->g(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits