[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 17 12:23:12 UTC 2019
compilerplugins/clang/test/vclwidgets.cxx | 14 ++++++++++++--
compilerplugins/clang/vclwidgets.cxx | 5 +++++
2 files changed, 17 insertions(+), 2 deletions(-)
New commits:
commit 7a736cd3b7d3bc504dfc2ebea0cb55101d572610
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Dec 17 09:38:24 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Dec 17 13:22:04 2019 +0100
Avoid false positive lopluign:vclwidgets warning
...about calling delete for a std::atomic<T*>. It ultimately turned out that I
didn't need such a std::atomic<T*> variable after all, but it can't hurt to have
this fix for loplugin:vclwidgets anyway.
Change-Id: I2ca058e9c39efa6c5386e6a320bed4bf8ab5f5d5
Reviewed-on: https://gerrit.libreoffice.org/85266
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/test/vclwidgets.cxx b/compilerplugins/clang/test/vclwidgets.cxx
index c470f991a667..f08faaefecd9 100644
--- a/compilerplugins/clang/test/vclwidgets.cxx
+++ b/compilerplugins/clang/test/vclwidgets.cxx
@@ -9,6 +9,8 @@
#include <sal/config.h>
+#include <atomic>
+
#include <vcl/vclptr.hxx>
#include <vcl/vclreferencebase.hxx>
@@ -82,7 +84,15 @@ void bar3()
p = get<Widget>();
}
-
-
+void bar4() {
+ VclPtr<Widget> p1;
+ //TODO: one error should be enough here?
+ // expected-error at +2 {{calling delete on instance of VclReferenceBase subclass, must rather call disposeAndClear() [loplugin:vclwidgets]}}
+ // expected-error at +1 {{calling delete on instance of VclPtr, must rather call disposeAndClear() [loplugin:vclwidgets]}}
+ delete p1;
+ std::atomic<int *> p2;
+ // No false positive here:
+ delete p2;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 46933a5087c5..bd8e83fc8897 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -690,6 +690,11 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr)
if (pImplicitCastExpr->getCastKind() != CK_UserDefinedConversion) {
return true;
}
+ if (!loplugin::TypeCheck(pImplicitCastExpr->getSubExprAsWritten()->getType()).Class("VclPtr")
+ .GlobalNamespace())
+ {
+ return true;
+ }
report(
DiagnosticsEngine::Warning,
"calling delete on instance of VclPtr, must rather call disposeAndClear()",
More information about the Libreoffice-commits
mailing list