| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for cc. | 5 """Top-level presubmit script for cc. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 def CheckScopedPtr(input_api, output_api, | 155 def CheckScopedPtr(input_api, output_api, |
| 156 white_list=CC_SOURCE_FILES, black_list=None): | 156 white_list=CC_SOURCE_FILES, black_list=None): |
| 157 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) | 157 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) |
| 158 source_file_filter = lambda x: input_api.FilterSourceFile(x, | 158 source_file_filter = lambda x: input_api.FilterSourceFile(x, |
| 159 white_list, | 159 white_list, |
| 160 black_list) | 160 black_list) |
| 161 errors = [] | 161 errors = [] |
| 162 for f in input_api.AffectedSourceFiles(source_file_filter): | 162 for f in input_api.AffectedSourceFiles(source_file_filter): |
| 163 for line_number, line in f.ChangedContents(): | 163 for line_number, line in f.ChangedContents(): |
| 164 # Disallow: | 164 # Disallow: |
| 165 # return scoped_ptr<T>(foo); | 165 # return std::unique_ptr<T>(foo); |
| 166 # bar = scoped_ptr<T>(foo); | 166 # bar = std::unique_ptr<T>(foo); |
| 167 # But allow: | 167 # But allow: |
| 168 # return scoped_ptr<T[]>(foo); | 168 # return std::unique_ptr<T[]>(foo); |
| 169 # bar = scoped_ptr<T[]>(foo); | 169 # bar = std::unique_ptr<T[]>(foo); |
| 170 if re.search(r'(=|\breturn)\s*scoped_ptr<.*?(?<!])>\([^)]+\)', line): | 170 if re.search(r'(=|\breturn)\s*std::unique_ptr<.*?(?<!])>\([^)]+\)', line): |
| 171 errors.append(output_api.PresubmitError( | 171 errors.append(output_api.PresubmitError( |
| 172 ('%s:%d uses explicit scoped_ptr constructor. ' + | 172 ('%s:%d uses explicit scoped_ptr constructor. ' + |
| 173 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number))) | 173 'Use base::WrapUnique() instead.') % (f.LocalPath(), line_number))) |
| 174 # Disallow: | 174 # Disallow: |
| 175 # scoped_ptr<T>() | 175 # std::unique_ptr<T>() |
| 176 if re.search(r'\bscoped_ptr<.*?>\(\)', line): | 176 if re.search(r'\bstd::unique_ptr<.*?>\(\)', line): |
| 177 errors.append(output_api.PresubmitError( | 177 errors.append(output_api.PresubmitError( |
| 178 '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % | 178 '%s:%d uses std::unique_ptr<T>(). Use nullptr instead.' % |
| 179 (f.LocalPath(), line_number))) | 179 (f.LocalPath(), line_number))) |
| 180 return errors | 180 return errors |
| 181 | 181 |
| 182 def FindUnquotedQuote(contents, pos): | 182 def FindUnquotedQuote(contents, pos): |
| 183 match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:]) | 183 match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:]) |
| 184 return -1 if not match else match.start("quote") + pos | 184 return -1 if not match else match.start("quote") + pos |
| 185 | 185 |
| 186 def FindUselessIfdefs(input_api, output_api): | 186 def FindUselessIfdefs(input_api, output_api): |
| 187 errors = [] | 187 errors = [] |
| 188 source_file_filter = lambda x: x | 188 source_file_filter = lambda x: x |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 results = [] | 344 results = [] |
| 345 new_description = description | 345 new_description = description |
| 346 new_description += '\nCQ_INCLUDE_TRYBOTS=%s' % ';'.join(bots) | 346 new_description += '\nCQ_INCLUDE_TRYBOTS=%s' % ';'.join(bots) |
| 347 results.append(output_api.PresubmitNotifyResult( | 347 results.append(output_api.PresubmitNotifyResult( |
| 348 'Automatically added Blink trybots to run Blink tests on CQ.')) | 348 'Automatically added Blink trybots to run Blink tests on CQ.')) |
| 349 | 349 |
| 350 if new_description != description: | 350 if new_description != description: |
| 351 rietveld_obj.update_description(issue, new_description) | 351 rietveld_obj.update_description(issue, new_description) |
| 352 | 352 |
| 353 return results | 353 return results |
| OLD | NEW |