1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 public loplugin::FilteringPlugin
<DeadClass
>
18 explicit DeadClass(InstantiationData
const & data
): FilteringPlugin(data
) {}
22 bool VisitCXXRecordDecl(CXXRecordDecl
const *);
25 void DeadClass::run() {
26 if (compiler
.getLangOpts().CPlusPlus
) {
27 TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl());
31 bool DeadClass::VisitCXXRecordDecl(CXXRecordDecl
const * decl
) {
32 if (ignoreLocation(decl
) || !decl
->isThisDeclarationADefinition())
34 if (decl
->needsImplicitDefaultConstructor())
36 if (decl
->getDescribedClassTemplate())
38 if (isa
<ClassTemplateSpecializationDecl
>(decl
))
42 for (auto i
= decl
->ctor_begin(); i
!= decl
->ctor_end(); ++i
) {
43 if (!i
->isUserProvided())
45 if (i
->isCopyOrMoveConstructor())
50 if (otherCnt
== 0 && copyMoveCnt
> 0)
53 DiagnosticsEngine::Warning
,
54 "class has only copy/move constructors, must be dead",
56 << decl
->getSourceRange();
57 for (auto i
= decl
->ctor_begin(); i
!= decl
->ctor_end(); ++i
) {
65 loplugin::Plugin::Registration
<DeadClass
> X("deadclass");
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */