diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-12-13 16:52:41 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-12-14 09:34:01 +0000 |
commit | c826ddfc2c213ae61918793eefe0c6593ce9bb17 (patch) | |
tree | 8bdc80a87fefdc35e2a6a45ad340a7a3e35f0386 /compilerplugins | |
parent | 876de03290ce0e9393134d722e5b15025e32a341 (diff) |
Check that VclPtr is only instantiated with appropriate types
...deriving from VclReferenceBase. Complicated by the fact that the argument
type may be incomplete at the time of template instantiation. So this approach
may be less precise than the change to loplugin:vclwidgets from
cbf5b21f2a65bbb342295200f6ad93a00f90733e "Catch some misuses of VclPtr
construction" when the argument type becomes complete later in the comilation
unit. However, this approach would also catch the two misuses in UnoControls
found by cbf5b21f2a65bbb342295200f6ad93a00f90733e, so go with this approach for
now and revert the change to loplugin:vclwdigets.
Change-Id: I7888f23d2b9e2db81ae2ce4bf4c8277912317685
Reviewed-on: https://gerrit.libreoffice.org/31966
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index e90e40fe6e39..8a5ac72b97d2 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -838,25 +838,6 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr ) "Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create", constructExpr->getExprLoc()); } - } else if (auto d = dyn_cast<ClassTemplateSpecializationDecl>(recordDecl)) { - if (d->getTemplateArgs().size() == 1) { - auto check = loplugin::DeclCheck(recordDecl); - if ((check.Class("ScopedVclPtr").GlobalNamespace() - || check.Class("ScopedVclPtrInstance").GlobalNamespace() - || check.Class("VclPtr").GlobalNamespace() - || check.Class("VclPtrInstance").GlobalNamespace())) - { - auto t = d->getTemplateArgs()[0].getAsType(); - if (!containsVclReferenceBaseSubclass(t)) { - report( - DiagnosticsEngine::Warning, - ("constructing an instance of %0 where the argument" - " type %1 is not derived from VclReferenceBase"), - constructExpr->getExprLoc()) - << recordDecl << t << constructExpr->getSourceRange(); - } - } - } } return true; } |