Changeset 105797 in webkit


Ignore:
Timestamp:
Jan 24, 2012 1:27:16 PM (12 years ago)
Author:
haraken@chromium.org
Message:

The cpp parser of prepare-ChangeLog cannot detect a change in classes and namespaces
https://bugs.webkit.org/show_bug.cgi?id=75531

Reviewed by David Kilzer.

Previously, the cpp parser of prepare-ChangeLog could not detect a change
outside methods. Consider the following cpp file.

namespace N {
int a; this change does not appear on ChangeLog.
class C {

int b; this change does not appear on ChangeLog.
void f()
{

int c; this change appears on ChangeLog.

}
int d; this change does not appear on ChangeLog.

};
int e; this change does not appear on ChangeLog.
};

The previous prepare-ChangeLog outputs just methods in which a change is found:

(N::C::f):

This patch fixes prepare-ChangeLog so that it outputs namespaces, classes
and methods in which a change is found:

(N):
(N::C):
(N::C::f):

  • Scripts/prepare-ChangeLog:

(get_function_line_ranges_for_cpp): Modified as described above.

  • Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added test cases.

(Class104):
(Class105):
(Class106):
(Class106::func32):
(Class106::func33):
(NameSpace3):
(NameSpace4):
(NameSpace5):
(NameSpace6):
(Class107):
(NameSpace5::NameSpace6::Class107::func34):

  • Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt:
Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r105796 r105797  
     12012-01-24  Kentaro Hara  <haraken@chromium.org>
     2
     3        The cpp parser of prepare-ChangeLog cannot detect a change in classes and namespaces
     4        https://bugs.webkit.org/show_bug.cgi?id=75531
     5
     6        Reviewed by David Kilzer.
     7
     8        Previously, the cpp parser of prepare-ChangeLog could not detect a change
     9        outside methods. Consider the following cpp file.
     10
     11            namespace N {
     12            int a;     // this change does not appear on ChangeLog.
     13            class C {
     14                int b;     // this change does not appear on ChangeLog.
     15                void f()
     16                {
     17                    int c;     // this change appears on ChangeLog.
     18                }
     19                int d;     // this change does not appear on ChangeLog.
     20            };
     21            int e;     // this change does not appear on ChangeLog.
     22            };
     23
     24        The previous prepare-ChangeLog outputs just methods in which a change is found:
     25            (N::C::f):
     26
     27        This patch fixes prepare-ChangeLog so that it outputs namespaces, classes
     28        and methods in which a change is found:
     29            (N):
     30            (N::C):
     31            (N::C::f):
     32
     33        * Scripts/prepare-ChangeLog:
     34        (get_function_line_ranges_for_cpp): Modified as described above.
     35
     36        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added test cases.
     37        (Class104):
     38        (Class105):
     39        (Class106):
     40        (Class106::func32):
     41        (Class106::func33):
     42        (NameSpace3):
     43        (NameSpace4):
     44        (NameSpace5):
     45        (NameSpace6):
     46        (Class107):
     47        (NameSpace5::NameSpace6::Class107::func34):
     48        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt:
     49
    1502012-01-24  Kentaro Hara  <haraken@chromium.org>
    251
  • trunk/Tools/Scripts/prepare-ChangeLog

    r105796 r105797  
    621621    my $brace_start = 0;
    622622    my $brace_end = 0;
     623    my $namespace_start = -1;
    623624    my $skip_til_brace_or_semicolon = 0;
    624625
     
    696697                  my $selector = method_decl_to_selector ($potential_method_spec);
    697698                  $potential_name = "${potential_method_char}\[${interface_name} ${selector}\]";
    698                  
     699
    699700                  $potential_method_spec = "";
    700701                  $potential_method_char = "";
    701702                  $in_method_declaration = 0;
    702  
     703
    703704                  $_ = $original;
    704705                  s/^[^;{]*//;
     
    712713        }
    713714
    714        
     715
    715716        # start of method declaration
    716717        if ((my $method_char, my $method_spec) = m&^([-+])([^0-9;][^;]*);?$&) {
     
    732733              my $selector = method_decl_to_selector ($potential_method_spec);
    733734              $potential_name = "${potential_method_char}\[${interface_name} ${selector}\]";
    734              
     735
    735736              $potential_method_spec = "";
    736737              $potential_method_char = "";
     
    778779                $skip_til_brace_or_semicolon = 0;
    779780
     781                if ($namespace_start >= 0 and $namespace_start < $potential_start) {
     782                    push @ranges, [ $namespace_start . "", $potential_start - 1, $name ];
     783                }
     784
    780785                if ($potential_namespace) {
    781786                    push @namespaces, $potential_namespace;
    782787                    $potential_namespace = "";
     788                    $name = $namespaces[-1];
     789                    $namespace_start = $. + 1;
    783790                    next;
    784791                }
     
    804811            if ($1 eq "}") {
    805812                if (!$in_braces && @namespaces) {
     813                    if ($namespace_start >= 0 and $namespace_start < $.) {
     814                        push @ranges, [ $namespace_start . "", $. - 1, $name ];
     815                    }
     816
    806817                    pop @namespaces;
     818                    if (@namespaces) {
     819                        $name = $namespaces[-1];
     820                        $namespace_start = $. + 1;
     821                    } else {
     822                        $name = "";
     823                        $namespace_start = -1;
     824                    }
    807825                    next;
    808826                }
     
    815833                if (!$in_braces and $name) {
    816834                    push @ranges, [ $start, $., $name ];
    817                     $name = "";
     835                    if (@namespaces) {
     836                        $name = $namespaces[-1];
     837                        $namespace_start = $. + 1;
     838                    } else {
     839                        $name = "";
     840                        $namespace_start = -1;
     841                    }
    818842                }
    819843
  • trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt

    r103669 r105797  
    136136  ],
    137137  [
     138    '158',
     139    '159',
     140    'Class1'
     141  ],
     142  [
    138143    '162',
    139144    '164',
     
    176181  ],
    177182  [
     183    '204',
     184    '205',
     185    'Struct1'
     186  ],
     187  [
    178188    '208',
    179189    '210',
     
    186196  ],
    187197  [
     198    '219',
     199    '219',
     200    'NameSpace1'
     201  ],
     202  [
    188203    '220',
    189204    '222',
     
    191206  ],
    192207  [
     208    '223',
     209    '223',
     210    'NameSpace1'
     211  ],
     212  [
     213    '228',
     214    '228',
     215    'NameSpace2'
     216  ],
     217  [
    193218    '229',
    194219    '231',
    195220    'NameSpace1::NameSpace2::func31'
     221  ],
     222  [
     223    '232',
     224    '232',
     225    'NameSpace2'
     226  ],
     227  [
     228    '237',
     229    '240',
     230    'Class104'
     231  ],
     232  [
     233    '244',
     234    '249',
     235    'Class105'
     236  ],
     237  [
     238    '253',
     239    '254',
     240    'Class106'
     241  ],
     242  [
     243    '255',
     244    '259',
     245    'Class106::func32'
     246  ],
     247  [
     248    '260',
     249    '261',
     250    'Class106'
     251  ],
     252  [
     253    '262',
     254    '266',
     255    'Class106::func33'
     256  ],
     257  [
     258    '267',
     259    '268',
     260    'Class106'
     261  ],
     262  [
     263    '272',
     264    '273',
     265    'NameSpace3'
     266  ],
     267  [
     268    '275',
     269    '276',
     270    'NameSpace4'
     271  ],
     272  [
     273    '278',
     274    '279',
     275    'NameSpace3'
     276  ],
     277  [
     278    '283',
     279    '284',
     280    'NameSpace5'
     281  ],
     282  [
     283    '286',
     284    '287',
     285    'NameSpace6'
     286  ],
     287  [
     288    '289',
     289    '290',
     290    'Class107'
     291  ],
     292  [
     293    '291',
     294    '295',
     295    'NameSpace5::NameSpace6::Class107::func34'
     296  ],
     297  [
     298    '296',
     299    '297',
     300    'Class107'
     301  ],
     302  [
     303    '299',
     304    '300',
     305    'NameSpace6'
     306  ],
     307  [
     308    '302',
     309    '303',
     310    'NameSpace5'
    196311  ]
    197312]
  • trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp

    r103669 r105797  
    233233}
    234234}
     235
     236class Class104 {
     237    int a;
     238    int b;
     239    int c;
     240    int d;
     241};
     242
     243class Class105 {
     244public:
     245    int a;
     246    int b;
     247private:
     248    int c;
     249    int d;
     250};
     251
     252class Class106 {
     253    int a;
     254    int b;
     255    void func32()
     256    {
     257        int c;
     258        int d;
     259    }
     260    int e;
     261    int f;
     262    void func33()
     263    {
     264        int g;
     265        int h;
     266    }
     267    int i;
     268    int j;
     269};
     270
     271namespace NameSpace3 {
     272int a;
     273int b;
     274namespace NameSpace4 {
     275int c;
     276int d;
     277};
     278int e;
     279int f;
     280};
     281
     282namespace NameSpace5 {
     283int a;
     284int b;
     285namespace NameSpace6 {
     286int c;
     287int d;
     288class Class107 {
     289    int e;
     290    int f;
     291    void func34()
     292    {
     293        int g;
     294        int h;
     295    }
     296    int i;
     297    int j;
     298};
     299int k;
     300int ll;
     301};
     302int m;
     303int n;
     304};
Note: See TracChangeset for help on using the changeset viewer.