This patch adds -Wsuggest-override, which allows for more aggressive enforcement of modern C++ best practices, as well as better compatibility with gcc, which has had its own -Wsuggest-override since version 5.1.
Clang already has -Winconsistent-missing-override, which only warns in the case where there is at least one function already marked override in a class. This warning strengthens that warning by suggesting the override keyword regardless of whether it is already present anywhere.
The text between suggest-override and inconsistent-missing-override is now shared, using TextSubstitution for the entire diagnostic text.
These linebreaks are super unfortunate. Could they be improved by doing it like this?
auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) { unsigned DiagID = isa<CXXDestructorDecl>(MD) ? DiagDtor : DiagFn; Diag(MD->getLocation(), DiagID) << MD->getDeclName(); const CXXMethodDecl *OMD = *MD->begin_overridden_methods(); Diag(OMD->getLocation(), diag::note_overridden_virtual_function); }; if (Inconsistent) EmitDiag(diag::warn_inconsistent_destructor_marked_not_override_overriding, diag::warn_inconsistent_function_marked_not_override_overriding); else EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding diag::warn_suggest_function_marked_not_override_overriding);