diff options
author | Noel Grandin <noel@peralex.com> | 2015-06-08 10:09:34 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-06-12 16:22:52 +0000 |
commit | bf34b812a75add89a912df36761ec9dd77a479b0 (patch) | |
tree | 877d002c5c0fd75981a57fcf05ba2b071cf57307 /compilerplugins | |
parent | 93da9ecd9de9a1d0ae3aafaded815ee179fb0f30 (diff) |
New VclPtr clang plugin to catch potential problems.
Change-Id: I2571c4384e4c2dbe411e171325e10d57a0afe5a0
Reviewed-on: https://gerrit.libreoffice.org/16235
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index fd79241a7dcd..7487fbf3c36f 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -46,6 +46,7 @@ public: bool VisitCallExpr(const CallExpr *); bool VisitDeclRefExpr(const DeclRefExpr* pDeclRefExpr); + bool VisitCXXConstructExpr( const CXXConstructExpr* expr ); private: bool isDisposeCallingSuperclassDispose(const CXXMethodDecl* pMethodDecl); bool mbCheckingMemcpy = false; @@ -581,6 +582,24 @@ bool VCLWidgets::VisitDeclRefExpr(const DeclRefExpr* pDeclRefExpr) return true; } +bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr ) +{ + if (ignoreLocation(constructExpr)) { + return true; + } + if (constructExpr->getConstructionKind() != CXXConstructExpr::CK_Complete) { + return true; + } + const CXXConstructorDecl* pConstructorDecl = constructExpr->getConstructor(); + const CXXRecordDecl* recordDecl = pConstructorDecl->getParent(); + if (isDerivedFromWindow(recordDecl)) { + report( + DiagnosticsEngine::Warning, + "Calling constructor of a Window-derived type directly. All such creation should go via VclPtr<>::Create", + constructExpr->getExprLoc()); + } + return true; +} loplugin::Plugin::Registration< VCLWidgets > X("vclwidgets"); |