Title: [106183] trunk/Tools
Revision
106183
Author
hara...@chromium.org
Date
2012-01-27 22:24:22 -0800 (Fri, 27 Jan 2012)

Log Message

The cpp parser of prepare-ChangeLog treats if(...) {} as a method
https://bugs.webkit.org/show_bug.cgi?id=77241

Reviewed by Ryosuke Niwa.

The cpp parser of prepare-ChangeLog is wrong, and an inner {} block
in a method in some namespace or class is treated as a method.
This patch fixes the bug.

    class C {
        void func()
        {
            if (1) {    // This should not be treated as a method.
            }
        }
    };

* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_cpp):
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp:
(Class108):
(Class108::func35):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (106182 => 106183)


--- trunk/Tools/ChangeLog	2012-01-28 04:45:29 UTC (rev 106182)
+++ trunk/Tools/ChangeLog	2012-01-28 06:24:22 UTC (rev 106183)
@@ -1,3 +1,29 @@
+2012-01-27  Kentaro Hara  <hara...@chromium.org>
+
+        The cpp parser of prepare-ChangeLog treats if(...) {} as a method
+        https://bugs.webkit.org/show_bug.cgi?id=77241
+
+        Reviewed by Ryosuke Niwa.
+
+        The cpp parser of prepare-ChangeLog is wrong, and an inner {} block
+        in a method in some namespace or class is treated as a method.
+        This patch fixes the bug.
+
+            class C {
+                void func()
+                {
+                    if (1) {    // This should not be treated as a method.
+                    }
+                }
+            };
+
+        * Scripts/prepare-ChangeLog:
+        (get_function_line_ranges_for_cpp):
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt:
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp:
+        (Class108):
+        (Class108::func35):
+
 2012-01-27  Enrica Casucci  <enr...@apple.com>
 
         Followup to http://trac.webkit.org/changeset/106171.

Modified: trunk/Tools/Scripts/prepare-ChangeLog (106182 => 106183)


--- trunk/Tools/Scripts/prepare-ChangeLog	2012-01-28 04:45:29 UTC (rev 106182)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2012-01-28 06:24:22 UTC (rev 106183)
@@ -778,25 +778,27 @@
             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 (!$in_braces) {
+                    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;
-                }
+                    if ($potential_namespace) {
+                        push @namespaces, $potential_namespace;
+                        $potential_namespace = "";
+                        $name = $namespaces[-1];
+                        $namespace_start = $. + 1;
+                        next;
+                    }
 
-                # Promote potential name to real function name at the
-                # start of the outer level set of braces (function body?).
-                if (!$in_braces and $potential_start) {
-                    $start = $potential_start;
-                    $name = $potential_name;
-                    if (@namespaces && $name && (length($name) < 2 || substr($name,1,1) ne "[")) {
-                        $name = join ('::', @namespaces, $name);
+                    # Promote potential name to real function name at the
+                    # start of the outer level set of braces (function body?).
+                    if ($potential_start) {
+                        $start = $potential_start;
+                        $name = $potential_name;
+                        if (@namespaces && $name && (length($name) < 2 || substr($name,1,1) ne "[")) {
+                            $name = join ('::', @namespaces, $name);
+                        }
                     }
                 }
 

Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt (106182 => 106183)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt	2012-01-28 04:45:29 UTC (rev 106182)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt	2012-01-28 06:24:22 UTC (rev 106183)
@@ -311,6 +311,21 @@
       '302',
       '303',
       'NameSpace5'
+    ],
+    [
+      '307',
+      '307',
+      'Class108'
+    ],
+    [
+      '308',
+      '320',
+      'Class108::func35'
+    ],
+    [
+      '321',
+      '321',
+      'Class108'
     ]
   ]
 }

Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp (106182 => 106183)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp	2012-01-28 04:45:29 UTC (rev 106182)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp	2012-01-28 06:24:22 UTC (rev 106183)
@@ -302,3 +302,21 @@
 int m;
 int n;
 };
+
+class Class108 {
+    int a;
+    void func35()
+    {
+        int b;
+        if (1) {
+            int c;
+            for (;;) {
+                int d;
+                int e;
+            }
+            int f;
+        }
+        int g;
+    }
+    int h;
+};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to