Don't include * or & in function name
When checking for function comments we don't want to include the * or & in the name. Instead we allow after the space of the return type an optional * or & before accepting the function name.
This commit is contained in:
parent
fa53b71ba5
commit
7638907c04
|
@ -0,0 +1,24 @@
|
|||
/*******************************************************************\
|
||||
|
||||
Module: Lint Examples
|
||||
|
||||
Author: Thomas Kiley, thomas@diffblue.com
|
||||
|
||||
\*******************************************************************/
|
||||
|
||||
/*******************************************************************\
|
||||
|
||||
Function: fun
|
||||
|
||||
Inputs:
|
||||
|
||||
Outputs:
|
||||
|
||||
Purpose:
|
||||
|
||||
\*******************************************************************/
|
||||
|
||||
static int *fun()
|
||||
{
|
||||
do_something();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
CORE
|
||||
main.cpp
|
||||
|
||||
^Total errors found: 0$
|
||||
^EXIT=0$
|
||||
^SIGNAL=0$
|
||||
--
|
|
@ -3097,12 +3097,14 @@ def CheckForFunctionCommentHeaders(filename, raw_lines, error):
|
|||
for line in raw_lines:
|
||||
joined_line = ''
|
||||
starting_func = False
|
||||
regexp = r'(\w(\w|::|\*|\&|\s)*)\(' # decls * & space::name( ...
|
||||
# Look for declaration function_name( but allowing for *, & being attached to the function name
|
||||
# but not being considered part of it
|
||||
regexp = r'\w(\w|::|\s|\*|\&)* (\*|\&)?(?P<fnc_name>\w(\w|::)*)\('
|
||||
match_result = Match(regexp, line)
|
||||
if match_result:
|
||||
# If the name is all caps and underscores, figure it's a macro and
|
||||
# ignore it, unless it's TEST or TEST_F.
|
||||
function_name = match_result.group(1).split()[-1]
|
||||
function_name = match_result.group('fnc_name')
|
||||
if function_name == 'TEST' or function_name == 'TEST_F' or (
|
||||
not Match(r'[A-Z_]+$', function_name)):
|
||||
starting_func = True
|
||||
|
|
Loading…
Reference in New Issue