bool FinalProtected::VisitCXXMethodDecl(CXXMethodDecl const * cxxMethodDecl)
{ if (ignoreLocation(cxxMethodDecl)) { returntrue;
} if (cxxMethodDecl->getAccess() != AS_protected) { returntrue;
} if (!cxxMethodDecl->getParent()->hasAttr<FinalAttr>()) { returntrue;
}
cxxMethodDecl = cxxMethodDecl->getCanonicalDecl();
report(DiagnosticsEngine::Warning, "final class should not have protected members - convert them to private",
cxxMethodDecl->getBeginLoc())
<< cxxMethodDecl->getSourceRange(); returntrue;
}
bool FinalProtected::VisitFieldDecl(FieldDecl const * fieldDecl)
{ if (ignoreLocation(fieldDecl)) { returntrue;
} if (fieldDecl->getAccess() != AS_protected) { returntrue;
} if (!fieldDecl->getParent()->hasAttr<FinalAttr>()) { returntrue;
}
fieldDecl = fieldDecl->getCanonicalDecl();
report(DiagnosticsEngine::Warning, "final class should not have protected members - convert them to private",
fieldDecl->getBeginLoc())
<< fieldDecl->getSourceRange(); 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.