vcl:compilerplugin: new rule, no passing of vcl::Window by VclPtr

to prevent problems with accidentally deleting an object by doing this:
    Button *pButton = new Button(NULL);
	...
	pButton->callAMethodThatTakesARef(pButton);
Since we take a ref as we construct a temporary VclReference<> - but
this will dispose & delete the pButton as we return to the frame doing
the callAMethod

Change-Id: I60fc211b27fe7ff463aa58f1da106f430fc65529
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx
index 896cd3f..1f8e05b 100644
--- a/compilerplugins/clang/vclwidgets.cxx
+++ b/compilerplugins/clang/vclwidgets.cxx
@@ -37,8 +37,6 @@ public:

    bool VisitParmVarDecl(ParmVarDecl const * decl);

    bool VisitVarDecl( const VarDecl* var );

    bool VisitFunctionDecl( const FunctionDecl* var );
};

@@ -90,7 +88,7 @@ bool VCLWidgets::VisitCXXRecordDecl(const CXXRecordDecl * recordDecl) {
    }
    bool foundVclPtr = false;
    for(auto fieldDecl : recordDecl->fields()) {
        if (fieldDecl->getType().getAsString().find("VclPtr")==0) {
        if (fieldDecl->getType().getAsString().find("VclPtr") != std::string::npos) {
           foundVclPtr = true;
           break;
        }
@@ -153,52 +151,43 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) {
    return true;
}

bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl) {
bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl)
{
    if (ignoreLocation(pvDecl)) {
        return true;
    }
    // check if this parameter is derived from Window
    if (isPointerToWindowSubclass(pvDecl->getType())) {
    // ignore the stuff in the VclPtr template class
    const CXXMethodDecl *pMethodDecl = dyn_cast<CXXMethodDecl>(pvDecl->getDeclContext());
    if (pMethodDecl
        && pMethodDecl->getParent()->getQualifiedNameAsString().find("VclPtr") != std::string::npos) {
        return true;
    }
    if (pvDecl->getType().getAsString().find("VclPtr") != std::string::npos) {
        report(
            DiagnosticsEngine::Remark,
            "vcl::Window subclass passed as a pointer parameter, should be wrapped in VclPtr.",
            DiagnosticsEngine::Warning,
            "vcl::Window subclass passed as a VclPtr parameter, should be passed as a raw pointer.",
            pvDecl->getLocation())
          << pvDecl->getSourceRange();
    }
    return true;
}

bool VCLWidgets::VisitVarDecl( const VarDecl* varDecl )
{
    if (ignoreLocation(varDecl)) {
        return true;
    }
    if (!varDecl->isLocalVarDecl())
        return true;

    // check if this variables type is derived from Window
    if (isPointerToWindowSubclass(varDecl->getType())) {
        report(
            DiagnosticsEngine::Remark,
            "vcl::Window subclass declared as a pointer var, should be wrapped in VclPtr.",
            varDecl->getLocation())
          << varDecl->getSourceRange();
    }

    return true;
}

bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl )
{
    if (ignoreLocation(functionDecl)) {
        return true;
    }
    // ignore the stuff in the VclPtr template class
    const CXXMethodDecl *pMethodDecl = dyn_cast<CXXMethodDecl>(functionDecl);
    if (pMethodDecl
        && pMethodDecl->getParent()->getQualifiedNameAsString().find("VclPtr") != std::string::npos) {
        return true;
    }
    QualType t1 { compat::getReturnType(*functionDecl) };
    // check if this variables type is derived from Window
    if (isPointerToWindowSubclass(t1)) {
    if (t1.getAsString().find("VclPtr") != std::string::npos) {
        report(
            DiagnosticsEngine::Remark,
            "vcl::Window subclass declared as a return type from a method/function, should be wrapped in VclPtr.",
            DiagnosticsEngine::Warning,
            "VclPtr declared as a return type from a method/function, should be passed as a raw pointer.",
            functionDecl->getLocation())
          << functionDecl->getSourceRange();
    }
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index ab498f1..95afb6a 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -76,8 +76,8 @@ protected:

protected:
    friend class VclBuilder;
    void set_action_area(const VclPtr<VclButtonBox> &xBox);
    void set_content_area(const VclPtr<VclBox> &xBox);
    void set_action_area(VclButtonBox* pBox);
    void set_content_area(VclBox* pBox);

public:
    explicit        Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG );
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index 265a831..f32c932 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -237,7 +237,7 @@ public:
    virtual const Link& GetModifyHdl() const { return maModifyHdl; }
    virtual void        SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; }

    void                SetSubEdit( const VclPtr<Edit>& pEdit );
    void                SetSubEdit( Edit* pEdit );
    Edit*               GetSubEdit() const { return mpSubEdit; }

    boost::signals2::signal< void ( Edit* ) > autocompleteSignal;
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index e361ea9..5bab0de 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2706,10 +2706,10 @@ void Edit::ClearModifyFlag()
        mbModified = false;
}

void Edit::SetSubEdit( const VclPtr<Edit>& pEdit )
void Edit::SetSubEdit( Edit* pEdit )
{
    mpSubEdit.disposeAndClear();
    mpSubEdit = pEdit;
    mpSubEdit.set( pEdit );
    if ( mpSubEdit )
    {
        SetPointer( POINTER_ARROW );    // Nur das SubEdit hat den BEAM...
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 60aa876..b783499 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -509,14 +509,14 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle)
    ImplInit( pParent, nStyle );
}

void Dialog::set_action_area(const VclPtr<VclButtonBox> &xBox)
void Dialog::set_action_area(VclButtonBox* pBox)
{
    mpActionArea = xBox;
    mpActionArea.set(pBox);
}

void Dialog::set_content_area(const VclPtr<VclBox> &xBox)
void Dialog::set_content_area(VclBox* pBox)
{
    mpContentArea = xBox;
    mpContentArea.set(pBox);
}

void Dialog::settingOptimalLayoutSize(Window *pBox)