Refine the CPPLINT script to not report a __CPROVER_ misuse false positive

Change r'.*__CPROVER_.*' with r'.*"([^"\\]|\\.)*__CPROVER_([^"\\]|\\.)*".*'
so that only occurrences of __CPROVER_ in strings are caught. Note that
this check will still erroneously complain for the following
 "foo" __CPROVER_func() "bar"
This commit is contained in:
Konstantinos Kallas 2019-07-26 12:34:02 +01:00
parent 5d2e8b9ffb
commit dbbd70384b
1 changed files with 2 additions and 2 deletions

4
scripts/cpplint.py vendored
View File

@ -4605,7 +4605,7 @@ def CheckAssert(filename, clean_lines, linenum, error):
def Check__CPROVER_(filename, clean_lines, linenum, error): def Check__CPROVER_(filename, clean_lines, linenum, error):
"""Check for uses of __CPROVER_. """Check for uses of __CPROVER_ in strings.
Args: Args:
filename: The name of the current file. filename: The name of the current file.
@ -4614,7 +4614,7 @@ def Check__CPROVER_(filename, clean_lines, linenum, error):
error: The function to call with any errors found. error: The function to call with any errors found.
""" """
line = clean_lines.lines[linenum] line = clean_lines.lines[linenum]
match = Match(r'.*__CPROVER_.*', line) match = Match(r'.*"([^"\\]|\\.)*__CPROVER_([^"\\]|\\.)*".*', line)
if match: if match:
error(filename, linenum, 'build/deprecated', 4, error(filename, linenum, 'build/deprecated', 4,
'use CPROVER_PREFIX instead of __CPROVER_') 'use CPROVER_PREFIX instead of __CPROVER_')