Skip to content
Permalink
Browse files
2011-05-31 Yong Li <yoli@rim.com>
        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  <yoli@rim.com>

        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  <yoli@rim.com>

        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:

Canonical link: https://commits.webkit.org/77249@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87771 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed Jun 1, 2011
1 parent 193613d commit 4601b90b18e969c16b7bc94af5c2ff77daea993f
@@ -1,3 +1,20 @@
2011-05-31 Yong Li <yoli@rim.com>

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 <hojong.han@samsung.com>

Reviewed by Geoffrey Garen.
@@ -127,8 +127,8 @@ namespace JSC {
seen = true;
}

int accessType : 31;
int seen : 1;
signed accessType : 31;
unsigned seen : 1;

union {
struct {
@@ -1,3 +1,23 @@
2011-05-31 Yong Li <yoli@rim.com>

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 <hbono@chromium.org>

Reviewed by Eric Seidel.
@@ -225,7 +225,7 @@ class CSSPrimitiveValue : public CSSValue {

virtual unsigned short cssValueType() const;

int m_type : 31;
signed m_type : 31;
mutable unsigned m_hasCachedCSSText : 1;
union {
int ident;
@@ -66,8 +66,8 @@ class CSSProperty {
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.

@@ -365,7 +365,7 @@ class InlineBox {
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:
@@ -828,7 +828,7 @@ class RenderBlock : public RenderBox {
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
@@ -1,3 +1,18 @@
2011-05-31 Yong Li <yoli@rim.com>

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 <hbono@chromium.org>

Reviewed by Eric Seidel.
@@ -2919,6 +2919,14 @@ def check_language(filename, clean_lines, line_number, file_extension, include_s
'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 @@ class CppChecker(object):
'readability/utf8',
'readability/webkit_api',
'runtime/arrays',
'runtime/bitfields',
'runtime/casting',
'runtime/explicit',
'runtime/init',
@@ -2373,6 +2373,14 @@ def test_invalid_increment(self):
'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):

0 comments on commit 4601b90

Please sign in to comment.