Title: [87771] trunk
Revision
87771
Author
[email protected]
Date
2011-05-31 19:40:27 -0700 (Tue, 31 May 2011)

Log Message

2011-05-31  Yong Li  <[email protected]>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=54807
        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
        rule we should have in order to make our code independent from compilers and compiler flags.

        No new test added because this change is not known to fix any issue.

        * bytecode/StructureStubInfo.h:
2011-05-31  Yong Li  <[email protected]>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=54807
        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
        rule we should have in order to make our code independent from compilers and compiler flags.

        No new test added because this change is not known to fix any issue.

        * css/CSSPrimitiveValue.h:
        * css/CSSProperty.h:
        * rendering/InlineBox.h:
        * rendering/RenderBlock.h:
2011-05-31  Yong Li  <[email protected]>

        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=54807
        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
        rule we should have in order to make our code independent from compilers and compiler flags.

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (87770 => 87771)


--- trunk/Source/_javascript_Core/ChangeLog	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-06-01 02:40:27 UTC (rev 87771)
@@ -1,3 +1,20 @@
+2011-05-31  Yong Li  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=54807
+        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
+        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
+        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
+        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
+        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
+        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
+        rule we should have in order to make our code independent from compilers and compiler flags.
+
+        No new test added because this change is not known to fix any issue.
+
+        * bytecode/StructureStubInfo.h:
+
 2011-05-30  Hojong Han  <[email protected]>
 
         Reviewed by Geoffrey Garen.

Modified: trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h (87770 => 87771)


--- trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h	2011-06-01 02:40:27 UTC (rev 87771)
@@ -127,8 +127,8 @@
             seen = true;
         }
 
-        int accessType : 31;
-        int seen : 1;
+        signed accessType : 31;
+        unsigned seen : 1;
 
         union {
             struct {

Modified: trunk/Source/WebCore/ChangeLog (87770 => 87771)


--- trunk/Source/WebCore/ChangeLog	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/WebCore/ChangeLog	2011-06-01 02:40:27 UTC (rev 87771)
@@ -1,3 +1,23 @@
+2011-05-31  Yong Li  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=54807
+        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
+        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
+        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
+        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
+        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
+        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
+        rule we should have in order to make our code independent from compilers and compiler flags.
+
+        No new test added because this change is not known to fix any issue.
+
+        * css/CSSPrimitiveValue.h:
+        * css/CSSProperty.h:
+        * rendering/InlineBox.h:
+        * rendering/RenderBlock.h:
+
 2011-05-31  Hironori Bono  <[email protected]>
 
         Reviewed by Eric Seidel.

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (87770 => 87771)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-06-01 02:40:27 UTC (rev 87771)
@@ -225,7 +225,7 @@
 
     virtual unsigned short cssValueType() const;
 
-    int m_type : 31;
+    signed m_type : 31;
     mutable unsigned m_hasCachedCSSText : 1;
     union {
         int ident;

Modified: trunk/Source/WebCore/css/CSSProperty.h (87770 => 87771)


--- trunk/Source/WebCore/css/CSSProperty.h	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/WebCore/css/CSSProperty.h	2011-06-01 02:40:27 UTC (rev 87771)
@@ -66,8 +66,8 @@
     friend bool operator==(const CSSProperty&, const CSSProperty&);
 
     // Make sure the following fits in 4 bytes. Really.
-    int m_id : 15;
-    int m_shorthandID : 15; // If this property was set as part of a shorthand, gives the shorthand.
+    signed m_id : 15;
+    signed m_shorthandID : 15; // If this property was set as part of a shorthand, gives the shorthand.
     bool m_important : 1;
     bool m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
 

Modified: trunk/Source/WebCore/rendering/InlineBox.h (87770 => 87771)


--- trunk/Source/WebCore/rendering/InlineBox.h	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2011-06-01 02:40:27 UTC (rev 87771)
@@ -365,7 +365,7 @@
     mutable bool m_determinedIfPrevOnLineExists : 1;
     mutable bool m_nextOnLineExists : 1;
     mutable bool m_prevOnLineExists : 1;
-    int m_expansion : 11; // for justified text
+    signed m_expansion : 11; // for justified text
 
 #ifndef NDEBUG
 private:

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (87770 => 87771)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2011-06-01 02:40:27 UTC (rev 87771)
@@ -828,7 +828,7 @@
     RenderObjectChildList m_children;
     RenderLineBoxList m_lineBoxes;   // All of the root line boxes created for this block flow.  For example, <div>Hello<br>world.</div> will have two total lines for the <div>.
 
-    mutable int m_lineHeight : 31;
+    mutable signed m_lineHeight : 31;
     bool m_beingDestroyed : 1;
 
     // RenderRubyBase objects need to be able to split and merge, moving their children around

Modified: trunk/Tools/ChangeLog (87770 => 87771)


--- trunk/Tools/ChangeLog	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Tools/ChangeLog	2011-06-01 02:40:27 UTC (rev 87771)
@@ -1,3 +1,18 @@
+2011-05-31  Yong Li  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=54807
+        We have been assuming plain bitfields (like "int a : 31") are always signed integers.
+        However some compilers can treat them as unsigned. For example, RVCT 4.0 states plain
+        bitfields (declared without either signed or unsigned qualifiers) are treats as unsigned.
+        http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348c/Babjddhe.html
+        Although we can use "--signed-bitfields" flag to make RVCT 4.0 behave as most other compilers,
+        always using "signed"/"unsigned" qualifier to declare integral type bitfields is still a good
+        rule we should have in order to make our code independent from compilers and compiler flags.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+
 2011-05-31  Hironori Bono  <[email protected]>
 
         Reviewed by Eric Seidel.

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2011-06-01 02:40:27 UTC (rev 87771)
@@ -2919,6 +2919,14 @@
               'http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces'
               ' for more information.')
 
+    # Check for plain bitfields declared without either "singed" or "unsigned".
+    # Most compilers treat such bitfields as signed, but there are still compilers like
+    # RVCT 4.0 that use unsigned by default.
+    matched = re.match(r'\s*((const|mutable)\s+)?(char|(short(\s+int)?)|int|long(\s+(long|int))?)\s+.+\s*:\s*\d+\s*;', line)
+    if matched:
+        error(line_number, 'runtime/bitfields', 5,
+              'Please declare integral type bitfields with either signed or unsigned.')
+
     check_identifier_name_in_declaration(filename, line_number, line, file_state, error)
 
 
@@ -3452,6 +3460,7 @@
         'readability/utf8',
         'readability/webkit_api',
         'runtime/arrays',
+        'runtime/bitfields',
         'runtime/casting',
         'runtime/explicit',
         'runtime/init',

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-06-01 02:25:47 UTC (rev 87770)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2011-06-01 02:40:27 UTC (rev 87771)
@@ -2373,7 +2373,15 @@
                          'Changing pointer instead of value (or unused value of '
                          'operator*).  [runtime/invalid_increment] [5]')
 
+    # Integral bitfields must be declared with either signed or unsigned keyword.
+    def test_plain_integral_bitfields(self):
+        errmsg = ('Please declare integral type bitfields with either signed or unsigned.  [runtime/bitfields] [5]')
 
+        self.assert_lint('int a : 30;', errmsg)
+        self.assert_lint('mutable short a : 14;', errmsg)
+        self.assert_lint('const char a : 6;', errmsg)
+        self.assert_lint('long int a : 30;', errmsg)
+
 class CleansedLinesTest(unittest.TestCase):
     def test_init(self):
         lines = ['Line 1',
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to