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

Unified Diff: cc/PRESUBMIT.py

Issue 23591027: Allow NOLINT to skip the std::abs PRESUBMIT check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review feedback Created 7 years, 3 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 | cc/output/shader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/PRESUBMIT.py
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
index bcf71ef0d52800f862be518a40f0bce2be1d7709..9e84e3f6609980d496523ae2652e541ec9569189 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -74,11 +74,17 @@ def CheckStdAbs(input_api, output_api,
using_std_abs_files.append(f.LocalPath())
if re.search(r"\bfabsf?\(", contents):
found_fabs_files.append(f.LocalPath());
- # The following regular expression in words says:
- # "if there is no 'std::' behind an 'abs(' or 'absf(',
- # or if there is no 'std::' behind a 'fabs(' or 'fabsf(',
- # then it's a match."
- if re.search(r"((?<!std::)(\babsf?\()|(?<!std::)(\bfabsf?\())", contents):
+
+ no_std_prefix = r"(?<!std::)"
+ # Matches occurrences of abs/absf/fabs/fabsf without a "std::" prefix.
+ abs_without_prefix = r"%s(\babsf?\()" % no_std_prefix
+ fabs_without_prefix = r"%s(\bfabsf?\()" % no_std_prefix
+ # Skips matching any lines that have "// NOLINT".
+ no_nolint = r"(?![^\n]*//\s+NOLINT)"
+
+ expression = re.compile("(%s|%s)%s" %
+ (abs_without_prefix, fabs_without_prefix, no_nolint))
+ if expression.search(contents):
missing_std_prefix_files.append(f.LocalPath())
result = []
« no previous file with comments | « no previous file | cc/output/shader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698