diff options
author | Noel Grandin <noel@peralex.com> | 2015-03-18 08:33:14 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 11:59:25 +0100 |
commit | 0556598b35eb6d81fdaff04520f14202660f0333 (patch) | |
tree | 2fb64309bbd8e519f25b1e55824bad5513754e91 /compilerplugins/clang | |
parent | 7aa921cb53eedd0a107fbe9f75365adcce4d37d9 (diff) |
vclwidget: check for calling delete on subclasses of vcl::Window
Change-Id: I7fb7cf919e3f46dd03a18b1cb95fa881915f9642
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
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<sal_Int32, OTableWindow *>") && !startsWith(pVarDecl->getType().getAsString(), "::std::multimap<sal_Int32, class OTableWindow *>") && !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<ImplicitCastExpr>(pCXXDeleteExpr->getArgument()); if (!pImplicitCastExpr) { return true; |