Kaydet (Commit) bf34b812 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Meeks

New VclPtr clang plugin to catch potential problems.

Change-Id: I2571c4384e4c2dbe411e171325e10d57a0afe5a0
Reviewed-on: https://gerrit.libreoffice.org/16235Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 93da9ecd
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment