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

Unified Diff: PRESUBMIT.py

Issue 1411553003: PRESUBMIT: Bark about DISALLOW_* macros without #include "base/macros.h" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | PRESUBMIT_test.py » ('j') | 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 900e7c9ba418374119751ad8996bd01bcc15d673..4b26a4315f0df12cb252b54e68fdc6c7586d7a14 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1517,6 +1517,29 @@ def _CheckSingletonInHeaders(input_api, output_api):
return []
+def _CheckBaseMacrosInHeaders(input_api, output_api):
+ """Check for base/macros.h if DISALLOW_* macro is used."""
+
+ disallows = ['DISALLOW_%s' % s for s in ('ASSIGN', 'COPY', 'EVIL')]
M-A Ruel 2015/10/16 21:09:25 I'd call this an early generalisation; disallows
Dan Beam 2015/10/16 21:24:15 Done. (those 2 characters thank you!)
+ macros = '#include "base/macros.h"'
+ basictypes = '#include "base/basictypes.h"'
+
+ files = []
+ for f in input_api.AffectedSourceFiles(None):
+ if not f.LocalPath().endswith('.h'):
+ continue
+ for line_num, line in f.ChangedContents():
+ if any(d in line for d in disallows):
+ contents = input_api.ReadFile(f)
+ if not (macros in contents or basictypes in contents):
+ files.append(f)
+ break
+
+ msg = ('The following files appear to be using DISALLOW_* macros.\n'
+ 'Please #include "base/macros.h" in them.')
+ return [output_api.PresubmitError(msg, files)] if files else []
+
+
_DEPRECATED_CSS = [
# Values
( "-webkit-box", "flex" ),
@@ -1646,6 +1669,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckForCopyrightedCode(input_api, output_api))
results.extend(_CheckForWindowsLineEndings(input_api, output_api))
results.extend(_CheckSingletonInHeaders(input_api, output_api))
+ results.extend(_CheckBaseMacrosInHeaders(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 | PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698