Changeset 167010 in webkit


Ignore:
Timestamp:
Apr 9, 2014 2:48:26 AM (10 years ago)
Author:
Csaba Osztrogonác
Message:

Stylechecker: False positive on inline asm code.
https://bugs.webkit.org/show_bug.cgi?id=130570

Patch by Gergo Balogh <gbalogh.u-szeged@partner.samsung.com> on 2014-04-09
Reviewed by Csaba Osztrogonác.

Disable stylechecking in asm blocks.

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

(process_line):
(_InlineASMState):
(_InlineASMState.init):
(_InlineASMState.process_line):
(_InlineASMState.isInside):
(_process_lines):

  • Scripts/webkitpy/style/checkers/cpp_unittest.py:

(WebKitStyleTest.test_member_initialization_list):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r167008 r167010  
     12014-04-09  Gergo Balogh  <gbalogh.u-szeged@partner.samsung.com>
     2
     3        Stylechecker: False positive on inline asm code.
     4        https://bugs.webkit.org/show_bug.cgi?id=130570
     5
     6        Reviewed by Csaba Osztrogonác.
     7
     8        Disable stylechecking in asm blocks.
     9
     10        * Scripts/webkitpy/style/checkers/cpp.py:
     11        (process_line):
     12        (_InlineASMState):
     13        (_InlineASMState.__init__):
     14        (_InlineASMState.process_line):
     15        (_InlineASMState.isInside):
     16        (_process_lines):
     17        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     18        (WebKitStyleTest.test_member_initialization_list):
     19
    1202014-04-09  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r166758 r167010  
    36213621def process_line(filename, file_extension,
    36223622                 clean_lines, line, include_state, function_state,
    3623                  class_state, file_state, enum_state, error):
     3623                 class_state, file_state, enum_state, asm_state, error):
    36243624    """Processes a single line in the file.
    36253625
     
    36383638      enum_state: A _EnumState instance which maintains an enum declaration
    36393639                  state.
     3640      asm_state: The state of inline ASM code.
    36403641      error: A callable to which errors are reported, which takes arguments:
    36413642             line number, error level, and message
     
    36483649        return
    36493650    if match(r'\s*\b__asm\b', raw_lines[line]):  # Ignore asm lines as they format differently.
     3651        return
     3652    asm_state.process_line(raw_lines[line])
     3653    if asm_state.is_in_asm():  # Ignore further checks because asm blocks formatted differently.
    36503654        return
    36513655    check_function_definition(filename, file_extension, clean_lines, line, function_state, error)
     
    36613665
    36623666
     3667class _InlineASMState(object):
     3668    """Stores the state for the inline asm codes."""
     3669    def __init__(self):
     3670        self._is_in_asm = False
     3671
     3672    def process_line(self, line):
     3673        if match(r'\s*asm\s+(volatile)?\(', line):
     3674            self._is_in_asm = True
     3675        elif search(r'\);$', line) and self._is_in_asm:  # Can not do more without a proper parser (or lexer).
     3676            self._is_in_asm = False
     3677
     3678    def is_in_asm(self):
     3679        return self._is_in_asm
     3680
     3681
    36633682def _process_lines(filename, file_extension, lines, error, min_confidence):
    36643683    """Performs lint checks and reports any errors to the given error function.
     
    36873706    file_state = _FileState(clean_lines, file_extension)
    36883707    enum_state = _EnumState()
     3708    asm_state = _InlineASMState()
    36893709    for line in xrange(clean_lines.num_lines()):
    36903710        process_line(filename, file_extension, clean_lines, line,
    36913711                     include_state, function_state, class_state, file_state,
    3692                      enum_state, error)
     3712                     enum_state, asm_state, error)
    36933713    class_state.check_finished(error)
    36943714
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r166758 r167010  
    50265026         'Missing space after ,  [whitespace/comma] [3]'])
    50275027
    5028         fine_example = (
     5028        self.assert_multi_line_lint((
    50295029            'MyClass::MyClass(Document* doc)\n'
    50305030            '    : MySuperClass()\n'
     
    50345034            '#endif\n'
    50355035            '    , m_myMember(0)\n'
    5036             '{ }')
    5037         self.assert_multi_line_lint(fine_example, '')
     5036            '{ }'), '')
     5037
     5038        self.assert_multi_line_lint((
     5039            'asm volatile('
     5040            '    "lock; cmpxchgl %3, %2"\n'
     5041            '    "sete %1"\n'
     5042            '    : "+a"(expected), "=q"(result), "+m"(*location)\n'
     5043            '    : "r"(newValue)\n'
     5044            '    : "memory"\n'
     5045            ');'), '')
    50385046
    50395047        self.assert_multi_line_lint('''\
Note: See TracChangeset for help on using the changeset viewer.