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>
This commit is contained in:
committed by
Michael Meeks
parent
93da9ecd9d
commit
bf34b812a7
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user