Title: [181669] trunk/Tools
Revision
181669
Author
[email protected]
Date
2015-03-17 15:57:40 -0700 (Tue, 17 Mar 2015)

Log Message

check-webkit-style should allow "bool a : 1"
https://bugs.webkit.org/show_bug.cgi?id=142794

Reviewed by Brent Fulgham.

We should allow member bitfields of the form:

bool m_var : 1;

It seems that Visual Studio 8 was the last compiler that
wasn't happy about not using unsigned here. We already have
about 500 cases (in WebCore) where people were ignoring this rule.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_language): Allow "bool".
* Scripts/webkitpy/style/checkers/cpp_unittest.py: Add tests.
(CppStyleTest.test_enum_bitfields):
(CppStyleTest.test_plain_integral_bitfields):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (181668 => 181669)


--- trunk/Tools/ChangeLog	2015-03-17 22:48:07 UTC (rev 181668)
+++ trunk/Tools/ChangeLog	2015-03-17 22:57:40 UTC (rev 181669)
@@ -1,3 +1,24 @@
+2015-03-17  Dean Jackson  <[email protected]>
+
+        check-webkit-style should allow "bool a : 1"
+        https://bugs.webkit.org/show_bug.cgi?id=142794
+
+        Reviewed by Brent Fulgham.
+
+        We should allow member bitfields of the form:
+
+        bool m_var : 1;
+
+        It seems that Visual Studio 8 was the last compiler that
+        wasn't happy about not using unsigned here. We already have
+        about 500 cases (in WebCore) where people were ignoring this rule.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_language): Allow "bool".
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Add tests.
+        (CppStyleTest.test_enum_bitfields):
+        (CppStyleTest.test_plain_integral_bitfields):
+
 2015-03-17  Benjamin Poulain  <[email protected]>
 
         Compile character ranges targeting the same state as range check in the bytecode

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2015-03-17 22:48:07 UTC (rev 181668)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2015-03-17 22:57:40 UTC (rev 181669)
@@ -3273,7 +3273,7 @@
     matched = re.match(r'\s*((const|mutable)\s+)?([a-zA-Z_][a-zA-Z0-9_]*)\s+[a-zA-Z_][a-zA-Z0-9_]*\s*:\s*\d+\s*;', line)
     if matched:
         # Make sure the type is an enum and not an integral type
-        if not match(r'char|(short(\s+int)?)|int|long(\s+(long|int))|(signed|unsigned)(\s+int)?', matched.group(3)):
+        if not match(r'bool|char|(short(\s+int)?)|int|long(\s+(long|int))|(signed|unsigned)(\s+int)?', matched.group(3)):
             error(line_number, 'runtime/enum_bitfields', 5,
                   'Please declare enum bitfields as unsigned integral types.')
 

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2015-03-17 22:48:07 UTC (rev 181668)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2015-03-17 22:57:40 UTC (rev 181669)
@@ -2552,6 +2552,7 @@
         self.assert_lint('AnEnum a : 30;', errmsg)
         self.assert_lint('mutable AnEnum a : 14;', errmsg)
         self.assert_lint('const AnEnum a : 6;', errmsg)
+        self.assert_lint('bool a : 1;', '')
 
     # Integral bitfields must be declared with either signed or unsigned keyword.
     def test_plain_integral_bitfields(self):
@@ -2562,8 +2563,8 @@
         self.assert_lint('const char a : 6;', errmsg)
         self.assert_lint('long int a : 30;', errmsg)
         self.assert_lint('int a = 1 ? 0 : 30;', '')
+        self.assert_lint('bool a : 1;', '')
 
-
 class CleansedLinesTest(unittest.TestCase):
     def test_init(self):
         lines = ['Line 1',
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to