Changeset 106315 in webkit
- Timestamp:
- Jan 30, 2012 6:40:24 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r106302 r106315 1 2012-01-30 Kentaro Hara <haraken@chromium.org> 2 3 REGRESSION(r105797): prepare-ChangeLog for a .cpp file can 4 output an empty method name (i.e. "()") 5 https://bugs.webkit.org/show_bug.cgi?id=77336 6 7 Reviewed by Darin Adler. 8 9 r105797 tried to detect a change outside methods, but it causes a bug that 10 prepare-ChangeLog can output an empty method name, like this: 11 12 * foo/bar/baz.cpp: 13 (method1): 14 (): 15 (method2): 16 17 This is because the cpp parser in prepare-ChangeLog cannot distinguish 18 '{' as the beginning of a method with '{' as the beginning of an array definition 19 at the top level. 20 21 int a[] = { 1, 2, 3 }; // This '{' is the beginning of an array definition. 22 23 void func() { // This '{' is the beginning of a method. 24 ...; 25 } 26 27 This patch fixes prepare-ChangeLog so that it skips an array definition at the top level. 28 29 * Scripts/prepare-ChangeLog: 30 (get_function_line_ranges_for_cpp): Modified as described above. 31 (generateFunctionLists): As a hack, modified so that prepare-ChangeLog does not output 32 an empty method name. Ideally this should not happen but may happen, since the 33 parsers are not perfect. 34 * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added test cases. 35 (NameSpace7): 36 (NameSpace8): 37 (Class109): 38 * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt: 39 1 40 2012-01-30 Ojan Vafai <ojan@chromium.org> 2 41 -
trunk/Tools/Scripts/prepare-ChangeLog
r106183 r106315 271 271 my @function_range = @$function_range_ref; 272 272 273 # FIXME: This is a hack. If the function name is empty, skip it. 274 # The cpp, python, javascript, perl, css and java parsers 275 # are not perfectly implemented and sometimes function names cannot be retrieved 276 # correctly. As you can see in get_function_line_ranges_XXXX(), those parsers 277 # are not intended to implement real parsers but intended to just retrieve function names 278 # for most practical syntaxes. 279 next unless $function_range[2]; 280 273 281 # Advance to successive change ranges. 274 282 for (;; @change_range = @{shift @change_ranges}) { … … 619 627 my $in_parentheses = 0; 620 628 my $in_braces = 0; 629 my $in_toplevel_array_brace = 0; 621 630 my $brace_start = 0; 622 631 my $brace_end = 0; 623 632 my $namespace_start = -1; 624 633 my $skip_til_brace_or_semicolon = 0; 634 my $equal_observed = 0; 625 635 626 636 my $word = ""; … … 750 760 751 761 # Find function, interface and method names. 752 while (m&((?:[[:word:]]+::)*operator(?:[ \t]*\(\)|[^()]*)|[[:word:]:~]+|[(){}:;])|\@(?:implementation|interface|protocol)\s+(\w+)[^{]*&g) { 762 while (m&((?:[[:word:]]+::)*operator(?:[ \t]*\(\)|[^()]*)|[[:word:]:~]+|[(){}:;=])|\@(?:implementation|interface|protocol)\s+(\w+)[^{]*&g) { 763 # Skip an array definition at the top level. 764 # e.g. static int arr[] = { 1, 2, 3 }; 765 if ($1) { 766 if ($1 eq "=" and !$in_parentheses and !$in_braces) { 767 $equal_observed = 1; 768 } elsif ($1 eq "{" and $equal_observed) { 769 # This '{' is the beginning of an array definition, not the beginning of a method. 770 $in_toplevel_array_brace = 1; 771 $in_braces++; 772 $equal_observed = 0; 773 next; 774 } elsif ($1 !~ /[ \t]/) { 775 $equal_observed = 0; 776 } 777 } 778 753 779 # interface name 754 780 if ($2) { … … 834 860 # This could be a function body. 835 861 if (!$in_braces and $name) { 862 # This is the end of an array definition at the top level, not the end of a method. 863 if ($in_toplevel_array_brace) { 864 $in_toplevel_array_brace = 0; 865 next; 866 } 867 836 868 push @ranges, [ $start, $., $name ]; 837 869 if (@namespaces) { -
trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt
r106183 r106315 327 327 '321', 328 328 'Class108' 329 ], 330 [ 331 '340', 332 '354', 333 'NameSpace7' 334 ], 335 [ 336 '356', 337 '369', 338 'NameSpace8' 339 ], 340 [ 341 '371', 342 '371', 343 'NameSpace7' 344 ], 345 [ 346 '373', 347 '386', 348 'Class109' 349 ], 350 [ 351 '388', 352 '388', 353 'NameSpace7' 329 354 ] 330 355 ] -
trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp
r106183 r106315 321 321 int h; 322 322 }; 323 324 int a[] = { }; 325 int a[] = { 326 }; 327 int a[] = { 1, 2, 3 }; 328 int a[] = { 329 1, 330 2, 331 3 332 }; 333 int a[3] = { 1, 2, 3 }; 334 int a[][3] = { {1, 2, 3}, {4, 5, 6} }; 335 int a[2][3] = { {1, 2, 3}, {4, 5, 6} }; 336 extern int a[]; 337 char a[4] = "test"; 338 339 namespace NameSpace7 { 340 int a[] = { }; 341 int a[] = { 342 }; 343 int a[] = { 1, 2, 3 }; 344 int a[] = { 345 1, 346 2, 347 3 348 }; 349 int a[3] = { 1, 2, 3 }; 350 int a[][3] = { {1, 2, 3}, {4, 5, 6} }; 351 int a[2][3] = { {1, 2, 3}, {4, 5, 6} }; 352 extern int a[]; 353 char a[4] = "test"; 354 355 namespace NameSpace8 { 356 int a[] = { }; 357 int a[] = { 358 }; 359 int a[] = { 1, 2, 3 }; 360 int a[] = { 361 1, 362 2, 363 3 364 }; 365 int a[3] = { 1, 2, 3 }; 366 int a[][3] = { {1, 2, 3}, {4, 5, 6} }; 367 int a[2][3] = { {1, 2, 3}, {4, 5, 6} }; 368 extern int a[]; 369 char a[4] = "test"; 370 }; 371 372 class Class109 { 373 int a[] = { }; 374 int a[] = { 375 }; 376 int a[] = { 1, 2, 3 }; 377 int a[] = { 378 1, 379 2, 380 3 381 }; 382 int a[3] = { 1, 2, 3 }; 383 int a[][3] = { {1, 2, 3}, {4, 5, 6} }; 384 int a[2][3] = { {1, 2, 3}, {4, 5, 6} }; 385 extern int a[]; 386 char a[4] = "test"; 387 }; 388 389 };
Note: See TracChangeset
for help on using the changeset viewer.