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

Unified Diff: cc/PRESUBMIT.py

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 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/animation/animation_unittest.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 6c08441f405eea1d402681b81e62660a17457b28..f381684bfbc991e110a1087f2e9b750cb255e530 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -146,6 +146,40 @@ def CheckTodos(input_api, output_api):
items=errors)]
return []
+def CheckScopedPtr(input_api, output_api,
+ white_list=CC_SOURCE_FILES, black_list=None):
+ black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
+ source_file_filter = lambda x: input_api.FilterSourceFile(x,
+ white_list,
+ black_list)
+ errors = []
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ for line_number, line in f.ChangedContents():
+ # Disallow:
+ # return scoped_ptr<T>(foo);
+ # bar = scoped_ptr<T>(foo);
+ # But allow:
+ # return scoped_ptr<T[]>(foo);
+ # bar = scoped_ptr<T[]>(foo);
+ if re.search(r'(=|\breturn)\s*scoped_ptr<.*?(?<!])>\([^)]+\)', line):
+ errors.append(output_api.PresubmitError(
+ ('%s:%d uses explicit scoped_ptr constructor. ' +
+ 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number)))
+ # Disallow:
+ # return scoped_ptr<T>();
+ # bar = scoped_ptr<T>();
+ if re.search(r'(=|\breturn)\s*scoped_ptr<.*?>\(\)', line):
+ errors.append(output_api.PresubmitError(
+ '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
+ (f.LocalPath(), line_number)))
+ # Disallow:
+ # foo.PassAs<T>();
+ if re.search(r'\bPassAs<.*?>\(\)', line):
+ errors.append(output_api.PresubmitError(
+ '%s:%d uses PassAs<T>(). Use Pass() instead.' %
+ (f.LocalPath(), line_number)))
+ return errors
+
def FindUnquotedQuote(contents, pos):
match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:])
return -1 if not match else match.start("quote") + pos
@@ -286,6 +320,7 @@ def CheckChangeOnUpload(input_api, output_api):
results += CheckPassByValue(input_api, output_api)
results += CheckChangeLintsClean(input_api, output_api)
results += CheckTodos(input_api, output_api)
+ results += CheckScopedPtr(input_api, output_api)
results += CheckNamespace(input_api, output_api)
results += CheckForUseOfWrongClock(input_api, output_api)
results += FindUselessIfdefs(input_api, output_api)
« no previous file with comments | « no previous file | cc/animation/animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698