third_party/blink/tools/blinkpy/style/checkers/cpp.py
def check_redundant_virtual(clean_lines, linenum, error):
    """Checks if line contains a redundant "virtual" function-specifier.

    Args:
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      error: The function to call with any errors found.
    """

    # Look for "virtual" on current line.
    line = clean_lines.elided[linenum]
    virtual = match(r'^(.*)(\bvirtual\b)(.*)$', line)
    if not virtual:
        return

    # Ignore "virtual" keywords that are near access-specifiers.  These
    # are only used in class base-specifier and do not apply to member
    # functions.
    if (search(r'\b(public|protected|private)\s+$', virtual.group(1))
            or match(r'^\s+(public|protected|private)\b', virtual.group(3))):
        return

    # Ignore the "virtual" keyword from virtual base classes.  Usually
    # there is a column on the same line in these cases (virtual base
    # classes are rare in google3 because multiple inheritance is rare).
    if match(r'^.*[^:]:[^:].*$', line):
        return

    # Look for the next opening parenthesis.  This is the start of the
    # parameter list (possibly on the next line shortly after virtual).
    # TODO(unknown): doesn't work if there are virtual functions with
    # decltype() or other things that use parentheses, but csearch suggests
    # that this is rare.
    end_position = Position(-1, -1)
    start_col = len(virtual.group(2))
    for start_line in xrange(linenum, min(linenum + 3,
                                          clean_lines.num_lines())):
        line = clean_lines.elided[start_line][start_col:]
        parameter_list = match(r'^([^(]*)\(', line)
        if parameter_list:
            # Match parentheses to find the end of the parameter list
            end_position = close_expression(
                clean_lines.elided,
                Position(start_line, start_col + len(parameter_list.group(1))))
            break
        start_col = 0

    if end_position.column < 0:
        return  # Couldn't find end of parameter list, give up

    # Look for "override" or "final" after the parameter list
    # (possibly on the next few lines).
    for i in xrange(end_position.row,
                    min(end_position.row + 3, clean_lines.num_lines())):
        line = clean_lines.elided[i][end_position.column:]
        override_or_final = search(r'\b(override|final)\b', line)
        if override_or_final:
            error(linenum, 'readability/inheritance', 4,
                  ('"virtual" is redundant since function is '
                   'already declared as "%s"' % override_or_final.group(1)))

        if search(r'[^\w]\s*$', line):
            break
Checks if line contains a redundant "virtual" function-specifier.

    Args:
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      error: The function to call with any errors found.
    
Checks if line contains a redundant "virtual" function-specifier.
Checks if line contains a redundant " virtual " function - specifier .
def check_redundant_virtual(clean_lines, linenum, error):
    line = clean_lines.elided[linenum]
    virtual = match(r'^(.*)(\bvirtual\b)(.*)$', line)
    if not virtual:
        return
    if (search(r'\b(public|protected|private)\s+$', virtual.group(1))
            or match(r'^\s+(public|protected|private)\b', virtual.group(3))):
        return
    if match(r'^.*[^:]:[^:].*$', line):
        return
    end_position = Position(-1, -1)
    start_col = len(virtual.group(2))
    for start_line in xrange(linenum, min(linenum + 3,
                                          clean_lines.num_lines())):
        line = clean_lines.elided[start_line][start_col:]
        parameter_list = match(r'^([^(]*)\(', line)
        if parameter_list:
            end_position = close_expression(
                clean_lines.elided,
                Position(start_line, start_col + len(parameter_list.group(1))))
            break
        start_col = 0
    if end_position.column < 0:
        return  
    for i in xrange(end_position.row,
                    min(end_position.row + 3, clean_lines.num_lines())):
        line = clean_lines.elided[i][end_position.column:]
        override_or_final = search(r'\b(override|final)\b', line)
        if override_or_final:
            error(linenum, 'readability/inheritance', 4,
                  ('"virtual" is redundant since function is '
                   'already declared as "%s"' % override_or_final.group(1)))
        if search(r'[^\w]\s*$', line):
            break
def check_redundant_virtual ( clean_lines , linenum , error ) : line = clean_lines . elided [ linenum ] virtual = match ( r'^(.*)(\bvirtual\b)(.*)$' , line ) if not virtual : return if ( search ( r'\b(public|protected|private)\s+$' , virtual . group ( 1 ) ) or match ( r'^\s+(public|protected|private)\b' , virtual . group ( 3 ) ) ) : return if match ( r'^.*[^:]:[^:].*$' , line ) : return end_position = Position ( - 1 , - 1 ) start_col = len ( virtual . group ( 2 ) ) for start_line in xrange ( linenum , min ( linenum + 3 , clean_lines . num_lines ( ) ) ) : line = clean_lines . elided [ start_line ] [ start_col : ] parameter_list = match ( r'^([^(]*)\(' , line ) if parameter_list : end_position = close_expression ( clean_lines . elided , Position ( start_line , start_col + len ( parameter_list . group ( 1 ) ) ) ) break start_col = 0 if end_position . column < 0 : return for i in xrange ( end_position . row , min ( end_position . row + 3 , clean_lines . num_lines ( ) ) ) : line = clean_lines . elided [ i ] [ end_position . column : ] override_or_final = search ( r'\b(override|final)\b' , line ) if override_or_final : error ( linenum , 'readability/inheritance' , 4 , ( '"virtual" is redundant since function is ' 'already declared as "%s"' % override_or_final . group ( 1 ) ) ) if search ( r'[^\w]\s*$' , line ) : break
Checks if line contains a redundant "virtual" function-specifier.
Checks if line contains a redundant " virtual " function - specifier .
"""Checks if line contains a redundant "virtual" function-specifier.

    Args:
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      error: The function to call with any errors found.
    """ # Look for "virtual" on current line. # Ignore "virtual" keywords that are near access-specifiers.  These # are only used in class base-specifier and do not apply to member # functions. # Ignore the "virtual" keyword from virtual base classes.  Usually # there is a column on the same line in these cases (virtual base # classes are rare in google3 because multiple inheritance is rare). # Look for the next opening parenthesis.  This is the start of the # parameter list (possibly on the next line shortly after virtual). # TODO(unknown): doesn't work if there are virtual functions with # decltype() or other things that use parentheses, but csearch suggests # that this is rare. # Match parentheses to find the end of the parameter list # Couldn't find end of parameter list, give up # Look for "override" or "final" after the parameter list # (possibly on the next few lines).
clean_lines
A CleansedLines instance containing the file.
A CleansedLines instance containing the file .
linenum
The number of the line to check.
The number of the line to check .
error
The function to call with any errors found.
The function to call with any errors found .