void DeadClass::run() { if (compiler.getLangOpts().CPlusPlus) {
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
}
bool DeadClass::VisitCXXRecordDecl(CXXRecordDecl const * decl) { if (ignoreLocation(decl) || !decl->isThisDeclarationADefinition()) returntrue; if (decl->needsImplicitDefaultConstructor()) returntrue; if (decl->getDescribedClassTemplate()) returntrue; if (isa<ClassTemplateSpecializationDecl>(decl)) returntrue; int otherCnt = 0; int copyMoveCnt = 0; for (auto i = decl->ctor_begin(); i != decl->ctor_end(); ++i) { if (!i->isUserProvided()) continue; if (i->isCopyOrMoveConstructor())
copyMoveCnt++; else
otherCnt++;
} if (otherCnt == 0 && copyMoveCnt > 0)
{
report(
DiagnosticsEngine::Warning, "class has only copy/move constructors, must be dead",
decl->getLocStart())
<< decl->getSourceRange(); for (auto i = decl->ctor_begin(); i != decl->ctor_end(); ++i) { if (i->isDeleted()) continue;
}
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.