Title: [88256] trunk/Tools
Revision
88256
Author
[email protected]
Date
2011-06-07 12:55:04 -0700 (Tue, 07 Jun 2011)

Log Message

2011-06-07  Dmitry Lomov  <[email protected]>

        Reviewed by David Levin.

        https://bugs.webkit.org/show_bug.cgi?id=62215
        Allow comparisons with 0 in LIKELY and UNLIKELY macros.

        * Scripts/webkitpy/style/checkers/cpp.py:
        * Scripts/webkitpy/style/checkers/cpp_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (88255 => 88256)


--- trunk/Tools/ChangeLog	2011-06-07 19:21:24 UTC (rev 88255)
+++ trunk/Tools/ChangeLog	2011-06-07 19:55:04 UTC (rev 88256)
@@ -1,3 +1,13 @@
+2011-06-07  Dmitry Lomov  <[email protected]>
+
+        Reviewed by David Levin.
+
+        https://bugs.webkit.org/show_bug.cgi?id=62215
+        Allow comparisons with 0 in LIKELY and UNLIKELY macros.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+
 2011-06-07  Nico Weber  <[email protected]>
 
         Reviewed by Dimitri Glazkov.

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (88255 => 88256)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-06-07 19:21:24 UTC (rev 88255)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-06-07 19:55:04 UTC (rev 88256)
@@ -2341,8 +2341,9 @@
 
     # Include NULL here so that users don't have to convert NULL to 0 first and then get this error.
     if search(r'[=!]=\s*(NULL|0|true|false)\W', line) or search(r'\W(NULL|0|true|false)\s*[=!]=', line):
-        error(line_number, 'readability/comparison_to_zero', 5,
-              'Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.')
+        if not search('LIKELY', line) and not search('UNLIKELY', line):
+            error(line_number, 'readability/comparison_to_zero', 5,
+                  'Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.')
 
 
 def check_for_null(clean_lines, line_number, file_state, error):

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (88255 => 88256)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-06-07 19:21:24 UTC (rev 88255)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-06-07 19:55:04 UTC (rev 88256)
@@ -4137,7 +4137,20 @@
         self.assert_lint(
             'if (othertrue == fontType)',
             '')
+        self.assert_lint(
+            'if (LIKELY(foo == 0))',
+            '')
+        self.assert_lint(
+            'if (UNLIKELY(foo == 0))',
+            '')
+        self.assert_lint(
+            'if (LIKELY(foo == NULL))',
+            'Use 0 instead of NULL.  [readability/null] [5]')
+        self.assert_lint(
+            'if (UNLIKELY(foo == NULL))',
+            'Use 0 instead of NULL.  [readability/null] [5]')
 
+
     def test_using_std(self):
         self.assert_lint(
             'using std::min;',
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to