diff --git a/regression/cpp-linter/function-comment-header6/main.cpp b/regression/cpp-linter/function-comment-header6/main.cpp new file mode 100644 index 00000000000..fdaf7938525 --- /dev/null +++ b/regression/cpp-linter/function-comment-header6/main.cpp @@ -0,0 +1,24 @@ +/*******************************************************************\ + +Module: Lint Examples + +Author: Thomas Kiley, thomas@diffblue.com + +\*******************************************************************/ + +/*******************************************************************\ + +Function: operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static void operator()() +{ + do_something(); +} diff --git a/regression/cpp-linter/function-comment-header6/test.desc b/regression/cpp-linter/function-comment-header6/test.desc new file mode 100644 index 00000000000..12418d892f4 --- /dev/null +++ b/regression/cpp-linter/function-comment-header6/test.desc @@ -0,0 +1,7 @@ +CORE +main.cpp + +^Total errors found: 0$ +^EXIT=0$ +^SIGNAL=0$ +-- diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 7ad7e462729..39332ab3790 100644 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -3099,12 +3099,19 @@ def CheckForFunctionCommentHeaders(filename, raw_lines, error): starting_func = False # 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\w(\w|::)*)\(' + regexp = r'\w(\w|::|\s|\*|\&)* (\*|\&)?(?P(\w(\w|::)*))\('# + operator_regexp = r'\w(\w|::|\s|\*|\&)* (\*|\&)?(?P(|operator\(.*\)|operator.*))\(' + operator_match = Match(operator_regexp, line) match_result = Match(regexp, line) - if match_result: + function_name = "" + if operator_match: + function_name = operator_match.group('fnc_name') + elif match_result: + function_name = match_result.group('fnc_name') + + if operator_match or 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('fnc_name') if function_name == 'TEST' or function_name == 'TEST_F' or ( not Match(r'[A-Z_]+$', function_name)): starting_func = True @@ -3157,6 +3164,8 @@ def CheckForFunctionCommentHeader(filename, raw_lines, linenum, function_name, e """ + function_name = re.escape(function_name) + header_top_regex = r'^/\*{67}\\$' header_bottom_regex = r'^\\\*{67}/$' function_name_regex = r'Function: (\w+::)?' + function_name+'$'