Log 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:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (105796 => 105797)
--- trunk/Tools/ChangeLog 2012-01-24 21:24:32 UTC (rev 105796)
+++ trunk/Tools/ChangeLog 2012-01-24 21:27:16 UTC (rev 105797)
@@ -1,5 +1,54 @@
2012-01-24 Kentaro Hara <hara...@chromium.org>
+ 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:
+
+2012-01-24 Kentaro Hara <hara...@chromium.org>
+
prepare-ChangeLog outputs warnings for top-level { ... } blocks
https://bugs.webkit.org/show_bug.cgi?id=75943
Modified: trunk/Tools/Scripts/prepare-ChangeLog (105796 => 105797)
--- trunk/Tools/Scripts/prepare-ChangeLog 2012-01-24 21:24:32 UTC (rev 105796)
+++ trunk/Tools/Scripts/prepare-ChangeLog 2012-01-24 21:27:16 UTC (rev 105797)
@@ -620,6 +620,7 @@
my $in_braces = 0;
my $brace_start = 0;
my $brace_end = 0;
+ my $namespace_start = -1;
my $skip_til_brace_or_semicolon = 0;
my $word = "";
@@ -695,11 +696,11 @@
} elsif (/{/) {
my $selector = method_decl_to_selector ($potential_method_spec);
$potential_name = "${potential_method_char}\[${interface_name} ${selector}\]";
-
+
$potential_method_spec = "";
$potential_method_char = "";
$in_method_declaration = 0;
-
+
$_ = $original;
s/^[^;{]*//;
} elsif (/\@end/) {
@@ -711,7 +712,7 @@
}
}
-
+
# start of method declaration
if ((my $method_char, my $method_spec) = m&^([-+])([^0-9;][^;]*);?$&) {
my $original = $_;
@@ -731,7 +732,7 @@
if (/\{/) {
my $selector = method_decl_to_selector ($potential_method_spec);
$potential_name = "${potential_method_char}\[${interface_name} ${selector}\]";
-
+
$potential_method_spec = "";
$potential_method_char = "";
$in_method_declaration = 0;
@@ -777,9 +778,15 @@
if ($1 eq "{") {
$skip_til_brace_or_semicolon = 0;
+ if ($namespace_start >= 0 and $namespace_start < $potential_start) {
+ push @ranges, [ $namespace_start . "", $potential_start - 1, $name ];
+ }
+
if ($potential_namespace) {
push @namespaces, $potential_namespace;
$potential_namespace = "";
+ $name = $namespaces[-1];
+ $namespace_start = $. + 1;
next;
}
@@ -803,7 +810,18 @@
# Close brace.
if ($1 eq "}") {
if (!$in_braces && @namespaces) {
+ if ($namespace_start >= 0 and $namespace_start < $.) {
+ push @ranges, [ $namespace_start . "", $. - 1, $name ];
+ }
+
pop @namespaces;
+ if (@namespaces) {
+ $name = $namespaces[-1];
+ $namespace_start = $. + 1;
+ } else {
+ $name = "";
+ $namespace_start = -1;
+ }
next;
}
@@ -814,7 +832,13 @@
# This could be a function body.
if (!$in_braces and $name) {
push @ranges, [ $start, $., $name ];
- $name = "";
+ if (@namespaces) {
+ $name = $namespaces[-1];
+ $namespace_start = $. + 1;
+ } else {
+ $name = "";
+ $namespace_start = -1;
+ }
}
$potential_start = 0;
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt (105796 => 105797)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt 2012-01-24 21:24:32 UTC (rev 105796)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt 2012-01-24 21:27:16 UTC (rev 105797)
@@ -135,6 +135,11 @@
'Class2::func25'
],
[
+ '158',
+ '159',
+ 'Class1'
+ ],
+ [
'162',
'164',
'Class1::func26'
@@ -175,6 +180,11 @@
'Class103::Class103'
],
[
+ '204',
+ '205',
+ 'Struct1'
+ ],
+ [
'208',
'210',
'Struct1::func29'
@@ -185,13 +195,118 @@
'Struct2::func30'
],
[
+ '219',
+ '219',
+ 'NameSpace1'
+ ],
+ [
'220',
'222',
'NameSpace1::func30'
],
[
+ '223',
+ '223',
+ 'NameSpace1'
+ ],
+ [
+ '228',
+ '228',
+ 'NameSpace2'
+ ],
+ [
'229',
'231',
'NameSpace1::NameSpace2::func31'
+ ],
+ [
+ '232',
+ '232',
+ 'NameSpace2'
+ ],
+ [
+ '237',
+ '240',
+ 'Class104'
+ ],
+ [
+ '244',
+ '249',
+ 'Class105'
+ ],
+ [
+ '253',
+ '254',
+ 'Class106'
+ ],
+ [
+ '255',
+ '259',
+ 'Class106::func32'
+ ],
+ [
+ '260',
+ '261',
+ 'Class106'
+ ],
+ [
+ '262',
+ '266',
+ 'Class106::func33'
+ ],
+ [
+ '267',
+ '268',
+ 'Class106'
+ ],
+ [
+ '272',
+ '273',
+ 'NameSpace3'
+ ],
+ [
+ '275',
+ '276',
+ 'NameSpace4'
+ ],
+ [
+ '278',
+ '279',
+ 'NameSpace3'
+ ],
+ [
+ '283',
+ '284',
+ 'NameSpace5'
+ ],
+ [
+ '286',
+ '287',
+ 'NameSpace6'
+ ],
+ [
+ '289',
+ '290',
+ 'Class107'
+ ],
+ [
+ '291',
+ '295',
+ 'NameSpace5::NameSpace6::Class107::func34'
+ ],
+ [
+ '296',
+ '297',
+ 'Class107'
+ ],
+ [
+ '299',
+ '300',
+ 'NameSpace6'
+ ],
+ [
+ '302',
+ '303',
+ 'NameSpace5'
]
]
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp (105796 => 105797)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp 2012-01-24 21:24:32 UTC (rev 105796)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp 2012-01-24 21:27:16 UTC (rev 105797)
@@ -232,3 +232,73 @@
}
}
+
+class Class104 {
+ int a;
+ int b;
+ int c;
+ int d;
+};
+
+class Class105 {
+public:
+ int a;
+ int b;
+private:
+ int c;
+ int d;
+};
+
+class Class106 {
+ int a;
+ int b;
+ void func32()
+ {
+ int c;
+ int d;
+ }
+ int e;
+ int f;
+ void func33()
+ {
+ int g;
+ int h;
+ }
+ int i;
+ int j;
+};
+
+namespace NameSpace3 {
+int a;
+int b;
+namespace NameSpace4 {
+int c;
+int d;
+};
+int e;
+int f;
+};
+
+namespace NameSpace5 {
+int a;
+int b;
+namespace NameSpace6 {
+int c;
+int d;
+class Class107 {
+ int e;
+ int f;
+ void func34()
+ {
+ int g;
+ int h;
+ }
+ int i;
+ int j;
+};
+int k;
+int ll;
+};
+int m;
+int n;
+};
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes