Index: ui/PRESUBMIT.py |
diff --git a/ui/PRESUBMIT.py b/ui/PRESUBMIT.py |
index 0123fc6db2e075efb67b09ea1292598e58efadeb..08d84114ddd58b0a54b730659cc6915490d152a8 100644 |
--- a/ui/PRESUBMIT.py |
+++ b/ui/PRESUBMIT.py |
@@ -9,9 +9,10 @@ for more details about the presubmit API built into depot_tools. |
""" |
INCLUDE_CPP_FILES_ONLY = ( |
- r'.*\.(cc|h|mm)$', |
+ r'.*\.(cc|h|mm)$', |
Marc-Antoine Ruel (Google)
2015/02/13 02:31:48
I like +2. :)
I'd recommend not touching it just
tfarina
2015/02/13 02:37:05
That was format-webkitpy --chromium. Ick :(
I als
|
) |
+ |
def CheckScopedPtr(input_api, output_api, |
white_list=INCLUDE_CPP_FILES_ONLY, black_list=None): |
black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) |
@@ -22,11 +23,22 @@ def CheckScopedPtr(input_api, output_api, |
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 input_api.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: |
# scoped_ptr<T>() |
- if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line): |
+ if re.search(r'\bscoped_ptr<.*?>\(\)', line): |
errors.append(output_api.PresubmitError( |
- '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % |
- (f.LocalPath(), line_number))) |
+ '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % |
+ (f.LocalPath(), line_number))) |
return errors |