@@ -3446,99 +3446,6 @@ def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error):
3446
3446
' OR use pair directly OR if appropriate, construct a pair directly' )
3447
3447
3448
3448
3449
- def CheckRedundantVirtual (filename , clean_lines , linenum , error ):
3450
- """Check if line contains a redundant "virtual" function-specifier.
3451
-
3452
- Args:
3453
- filename: The name of the current file.
3454
- clean_lines: A CleansedLines instance containing the file.
3455
- linenum: The number of the line to check.
3456
- error: The function to call with any errors found.
3457
- """
3458
- # Look for "virtual" on current line.
3459
- line = clean_lines .elided [linenum ]
3460
- virtual = Match (r'^(.*)(\bvirtual\b)(.*)$' , line )
3461
- if not virtual : return
3462
-
3463
- # Ignore "virtual" keywords that are near access-specifiers. These
3464
- # are only used in class base-specifier and do not apply to member
3465
- # functions.
3466
- if (Search (r'\b(public|protected|private)\s+$' , virtual .group (1 )) or
3467
- Match (r'^\s+(public|protected|private)\b' , virtual .group (3 ))):
3468
- return
3469
-
3470
- # Ignore the "virtual" keyword from virtual base classes. Usually
3471
- # there is a column on the same line in these cases (virtual base
3472
- # classes are rare in google3 because multiple inheritance is rare).
3473
- if Match (r'^.*[^:]:[^:].*$' , line ): return
3474
-
3475
- # Look for the next opening parenthesis. This is the start of the
3476
- # parameter list (possibly on the next line shortly after virtual).
3477
- # TODO(unknown): doesn't work if there are virtual functions with
3478
- # decltype() or other things that use parentheses, but csearch suggests
3479
- # that this is rare.
3480
- end_col = - 1
3481
- end_line = - 1
3482
- start_col = len (virtual .group (2 ))
3483
- for start_line in range (linenum , min (linenum + 3 , clean_lines .NumLines ())):
3484
- line = clean_lines .elided [start_line ][start_col :]
3485
- parameter_list = Match (r'^([^(]*)\(' , line )
3486
- if parameter_list :
3487
- # Match parentheses to find the end of the parameter list
3488
- (_ , end_line , end_col ) = CloseExpression (
3489
- clean_lines , start_line , start_col + len (parameter_list .group (1 )))
3490
- break
3491
- start_col = 0
3492
-
3493
- if end_col < 0 :
3494
- return # Couldn't find end of parameter list, give up
3495
-
3496
- # Look for "override" or "final" after the parameter list
3497
- # (possibly on the next few lines).
3498
- for i in range (end_line , min (end_line + 3 , clean_lines .NumLines ())):
3499
- line = clean_lines .elided [i ][end_col :]
3500
- match = Search (r'\b(override|final)\b' , line )
3501
- if match :
3502
- error (filename , linenum , 'readability/inheritance' , 4 ,
3503
- ('"virtual" is redundant since function is '
3504
- 'already declared as "%s"' % match .group (1 )))
3505
-
3506
- # Set end_col to check whole lines after we are done with the
3507
- # first line.
3508
- end_col = 0
3509
- if Search (r'[^\w]\s*$' , line ):
3510
- break
3511
-
3512
-
3513
- def CheckRedundantOverrideOrFinal (filename , clean_lines , linenum , error ):
3514
- """Check if line contains a redundant "override" or "final" virt-specifier.
3515
-
3516
- Args:
3517
- filename: The name of the current file.
3518
- clean_lines: A CleansedLines instance containing the file.
3519
- linenum: The number of the line to check.
3520
- error: The function to call with any errors found.
3521
- """
3522
- # Look for closing parenthesis nearby. We need one to confirm where
3523
- # the declarator ends and where the virt-specifier starts to avoid
3524
- # false positives.
3525
- line = clean_lines .elided [linenum ]
3526
- declarator_end = line .rfind (')' )
3527
- if declarator_end >= 0 :
3528
- fragment = line [declarator_end :]
3529
- else :
3530
- if linenum > 1 and clean_lines .elided [linenum - 1 ].rfind (')' ) >= 0 :
3531
- fragment = line
3532
- else :
3533
- return
3534
-
3535
- # Check that at most one of "override" or "final" is present, not both
3536
- if Search (r'\boverride\b' , fragment ) and Search (r'\bfinal\b' , fragment ):
3537
- error (filename , linenum , 'readability/inheritance' , 4 ,
3538
- ('"override" is redundant since function is '
3539
- 'already declared as "final"' ))
3540
-
3541
-
3542
3449
# Returns true if we are at a new block, and it is directly
3543
3450
# inside of a namespace.
3544
3451
def IsBlockInNameSpace (nesting_state , is_forward_declaration ):
@@ -3590,8 +3497,6 @@ def ProcessLine(filename, is_header, clean_lines, line,
3590
3497
nesting_state , error )
3591
3498
CheckInvalidIncrement (filename , clean_lines , line , error )
3592
3499
CheckMakePairUsesDeduction (filename , clean_lines , line , error )
3593
- CheckRedundantVirtual (filename , clean_lines , line , error )
3594
- CheckRedundantOverrideOrFinal (filename , clean_lines , line , error )
3595
3500
3596
3501
3597
3502
def ProcessFileData (filename , is_header , lines , error ):
0 commit comments