Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: PRESUBMIT.py

Issue 653883002: Adding Presubmit error when OVERRIDE and FINAL is not used as C++11 standard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finetuned patch as per suggestions Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 6751f06d18b4676e92e14bba1c44d6b3379c4ed3..8b070908cd5bbaf2f9a7c4768d82a43f602ba160 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1259,6 +1259,25 @@ def _CheckNoDeprecatedCSS(input_api, output_api):
(fpath.LocalPath(), line_num, deprecated_value, value)))
return results
+def _CheckForOverrideAndFinalRules(input_api, output_api):
+ """Checks for override and final used as per C++11"""
+ override_pattern = "OVERRIDE"
+ final_pattern = "FINAL"
Mike West 2014/10/14 11:53:16 You don't need these local variables anymore, now
MRV 2014/10/14 12:24:24 Done.
+ problems = []
+ for f in input_api.AffectedFiles():
+ if (f.LocalPath().endswith(('.cc', '.mm', '.cpp', '.h'))):
+ for line_num, line in f.ChangedContents():
+ if (re.search(r"\bOVERRIDE\b", line) or
+ re.search(r"\bFINAL\b", line)):
+ problems.append(' %s:%d' % (f.LocalPath(), line_num))
+
+ if not problems:
+ return []
+ return [output_api.PresubmitError('Use C++11\'s |override| and'
+ ' |final| rather than OVERRIDE and FINAL. \n' +
+ '\n'.join(problems))]
+
+
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
@@ -1300,6 +1319,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckNoDeprecatedCSS(input_api, output_api))
results.extend(_CheckParseErrors(input_api, output_api))
results.extend(_CheckForIPCRules(input_api, output_api))
+ results.extend(_CheckForOverrideAndFinalRules(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698