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

Unified Diff: PRESUBMIT.py

Issue 10704150: Add presubmit check for #pragma once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 aaf6544260c0ae6a01f42962b3f13d33ad133ffc..cf207823cc0f7f415f008f4c5563d35ff9248504 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -354,6 +354,25 @@ def _CheckNoBannedFunctions(input_api, output_api):
return result
+def _CheckNoPragmaOnce(input_api, output_api):
+ """Make sure that banned functions are not used."""
+ files = []
+ pattern = input_api.re.compile(r'^#pragma\s+once',
+ input_api.re.MULTILINE)
+ for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
+ if not f.LocalPath().endswith('.h'):
+ continue
+ contents = input_api.ReadFile(f)
+ if pattern.search(contents):
+ files.append(f)
+
+ if files:
+ return [output_api.PresubmitError(
+ 'Do not use #pragma once in header files.\n' +
awong 2012/07/11 05:41:06 I don't think you need this plus to concat these s
dcheng 2012/07/11 05:44:19 Oops, you're right. I copied this from the iostrea
+ 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
+ files)]
+ return []
+
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
@@ -368,6 +387,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckNoNewWStrings(input_api, output_api))
results.extend(_CheckNoDEPSGIT(input_api, output_api))
results.extend(_CheckNoBannedFunctions(input_api, output_api))
+ results.extend(_CheckNoPragmaOnce(input_api, output_api))
return results
« 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