diff --git a/CODING_STANDARD.md b/CODING_STANDARD.md index c218cdf859b..002f5ad0dfc 100644 --- a/CODING_STANDARD.md +++ b/CODING_STANDARD.md @@ -156,7 +156,7 @@ Formatting is enforced using clang-format. For more information about this, see - Make references `const` whenever possible - Make member functions `const` whenever possible - Do not hide base class functions -- You are encouraged to use `override` +- When overriding a virtual function, use `override` (without `virtual`) - Single argument constructors must be `explicit` - Avoid implicit conversions - Avoid `friend` declarations diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 242a320ff0d..b29a75205e4 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -6148,21 +6148,21 @@ def CheckRedundantVirtual(filename, clean_lines, linenum, error): if end_col < 0: return # Couldn't find end of parameter list, give up -# # Look for "override" or "final" after the parameter list -# # (possibly on the next few lines). -# for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): -# line = clean_lines.elided[i][end_col:] -# match = Search(r'\b(override|final)\b', line) -# if match: -# error(filename, linenum, 'readability/inheritance', 4, -# ('"virtual" is redundant since function is ' -# 'already declared as "%s"' % match.group(1))) -# -# # Set end_col to check whole lines after we are done with the -# # first line. -# end_col = 0 -# if Search(r'[^\w]\s*$', line): -# break + # Look for "override" or "final" after the parameter list + # (possibly on the next few lines). + for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): + line = clean_lines.elided[i][end_col:] + match = Search(r'\b(override|final)\b', line) + if match: + error(filename, linenum, 'readability/inheritance', 4, + ('"virtual" is redundant since function is ' + 'already declared as "%s"' % match.group(1))) + + # Set end_col to check whole lines after we are done with the + # first line. + end_col = 0 + if Search(r'[^\w]\s*$', line): + break