From 0556598b35eb6d81fdaff04520f14202660f0333 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 18 Mar 2015 08:33:14 +0200 Subject: vclwidget: check for calling delete on subclasses of vcl::Window Change-Id: I7fb7cf919e3f46dd03a18b1cb95fa881915f9642 --- compilerplugins/clang/vclwidgets.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 13217f93ddf6..8ec329353086 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -230,6 +230,7 @@ bool VCLWidgets::VisitVarDecl(const VarDecl * pVarDecl) { && !startsWith(pVarDecl->getType().getAsString(), "::std::multimap") && !startsWith(pVarDecl->getType().getAsString(), "::std::multimap") && !startsWith(pVarDecl->getType().getAsString(), "::dbp::OMultiInstanceAutoRegistration< ::dbp::OUnoAutoPilot<") + && !startsWith(pVarDecl->getType().getAsString(), "SwSidebarWin_iterator") && containsWindowSubclass(pVarDecl->getType())) { report( @@ -399,6 +400,9 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl ) } } // check dispose method to make sure we are actually disposing all of the VclPtr fields + /* + Now that we are in the debugging phase this is no longer useful, since we have to break this rule on + occassion to make the destruction process work cleanly. if (pMethodDecl && pMethodDecl->isInstance() && pMethodDecl->getBody() && pMethodDecl->param_size()==0 && pMethodDecl->getNameAsString() == "dispose" @@ -458,6 +462,7 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl ) } } } + */ return true; } @@ -466,6 +471,14 @@ bool VCLWidgets::VisitCXXDeleteExpr(const CXXDeleteExpr *pCXXDeleteExpr) if (ignoreLocation(pCXXDeleteExpr)) { return true; } + const CXXRecordDecl *pPointee = pCXXDeleteExpr->getArgument()->getType()->getPointeeCXXRecordDecl(); + if (pPointee && isDerivedFromWindow(pPointee)) { + report( + DiagnosticsEngine::Warning, + "calling delete on instance of vcl::Window subclass, must rather call disposeAndClear()", + pCXXDeleteExpr->getLocStart()) + << pCXXDeleteExpr->getSourceRange(); + } const ImplicitCastExpr* pImplicitCastExpr = dyn_cast(pCXXDeleteExpr->getArgument()); if (!pImplicitCastExpr) { return true; -- cgit v1.2.3