Changeset 204723 in webkit
- Timestamp:
- Aug 22, 2016 9:40:49 AM (8 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r204701 r204723 1 2016-08-22 Jonathan Bedard <jbedard@apple.com> 2 3 check-webkit-style does not work with Lambda functions in C++ 4 https://bugs.webkit.org/show_bug.cgi?id=160910 5 6 Reviewed by Darin Adler. 7 8 This change eliminates false positives on correctly styled lambda functions and includes a few basic checks on capture list. 9 10 * Scripts/webkitpy/style/checkers/cpp.py: 11 (regex_for_lambda_functions): Added function which checks if a string is the start of a lambda function. 12 (check_for_non_standard_constructs): Added lambda function check. 13 (check_spacing_for_function_call): Added lambda function check. 14 (check_braces): Added lambda function check. 15 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 16 (CppStyleTest.test_lambda_functions): Added test function for lambda function style checks. 17 1 18 2016-08-21 Alex Christensen <achristensen@webkit.org> 2 19 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r202362 r204723 1282 1282 1283 1283 1284 def regex_for_lambda_functions(line, line_number, error): 1285 result = search(r'\s\[.*?\]\s', line) 1286 if result: 1287 group = result.group() 1288 1289 targ_error = None 1290 1291 if search(r'(\[\s|\s\]|\s,)', group): 1292 targ_error = [line_number, 'whitespace/brackets', 4, 1293 'Extra space in capture list.'] 1294 1295 if targ_error and regex_for_lambda_functions.__last_error != targ_error: 1296 error(targ_error[0], targ_error[1], targ_error[2], targ_error[3]) 1297 regex_for_lambda_functions.__last_error = targ_error 1298 return True 1299 return False 1300 1301 regex_for_lambda_functions.__last_error = None 1302 1303 1284 1304 def check_for_non_standard_constructs(clean_lines, line_number, 1285 1305 class_state, error): … … 1470 1490 if ( # Ignore control structures. 1471 1491 not search(r'\b(if|for|while|switch|return|new|delete)\b', function_call) 1492 # Ignore lambda functions 1493 and not regex_for_lambda_functions(function_call, line_number, error) 1472 1494 # Ignore pointers/references to functions. 1473 1495 and not search(r' \([^)]+\)\([^)]*(\)|,$)', function_call) … … 2432 2454 previous_line = get_previous_non_blank_line(clean_lines, line_number)[0] 2433 2455 if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override)\s*)?(->\s*\S+)?\s*$', previous_line) 2434 or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line)) 2456 or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line) 2457 or regex_for_lambda_functions(previous_line, line_number, error)) 2435 2458 and previous_line.find('#') < 0 2436 2459 and previous_line.find('- (') != 0 … … 2441 2464 and line.count('(') == line.count(')') 2442 2465 and not search(r'(\s*(if|for|while|switch|NS_ENUM|@synchronized)|} @catch)\b', line) 2466 and not regex_for_lambda_functions(line, line_number, error) 2443 2467 and line.find("](") < 0 2444 2468 and not match(r'\s+[A-Z_][A-Z_0-9]+\b', line)): -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r202362 r204723 1882 1882 self.assert_lint('int main(int argc, char* agrv [])', 'Extra space before [. [whitespace/brackets] [5]') 1883 1883 self.assert_lint(' str [strLength] = \'\\0\';', 'Extra space before [. [whitespace/brackets] [5]') 1884 1885 def test_lambda_functions(self): 1886 self.assert_lint(' [&] (Type argument) {', '') 1887 self.assert_lint(' [] {', '') 1888 self.assert_lint(' [ =] (Type argument) {', 'Extra space in capture list. [whitespace/brackets] [4]') 1889 self.assert_lint(' [var, var_ref&] {', '') 1890 self.assert_lint(' [var , var_ref&] {', 'Extra space in capture list. [whitespace/brackets] [4]') 1891 self.assert_lint(' [var,var_ref&] {', 'Missing space after , [whitespace/comma] [3]') 1884 1892 1885 1893 def test_spacing_around_else(self):
Note: See TracChangeset
for help on using the changeset viewer.