Skip to content

Commit 3a67fb6

Browse files
committed
Check for uses of __CPROVER_ in the linter
This should help avoid future code introducing literal uses of __CPROVER_ back into the code base.
1 parent 0ce0ac2 commit 3a67fb6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

scripts/cpplint.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,6 +4653,23 @@ def CheckAssert(filename, clean_lines, linenum, error):
46534653

46544654

46554655

4656+
def Check__CPROVER_(filename, clean_lines, linenum, error):
4657+
"""Check for uses of __CPROVER_.
4658+
4659+
Args:
4660+
filename: The name of the current file.
4661+
clean_lines: A CleansedLines instance containing the file.
4662+
linenum: The number of the line to check.
4663+
error: The function to call with any errors found.
4664+
"""
4665+
line = clean_lines.lines[linenum]
4666+
match = Match(r'.*__CPROVER_.*', line)
4667+
if match:
4668+
error(filename, linenum, 'build/deprecated', 4,
4669+
'use CPROVER_PREFIX instead of __CPROVER_')
4670+
4671+
4672+
46564673
def GetLineWidth(line):
46574674
"""Determines the width of the line in column positions.
46584675
@@ -4880,6 +4897,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
48804897
#CheckCheck(filename, clean_lines, linenum, error)
48814898
CheckAltTokens(filename, clean_lines, linenum, error)
48824899
CheckAssert(filename, clean_lines, linenum, error)
4900+
Check__CPROVER_(filename, clean_lines, linenum, error)
48834901
classinfo = nesting_state.InnermostClass()
48844902
if classinfo:
48854903
CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error)

src/util/cprover_prefix.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ Author: Daniel Kroening, [email protected]
1010
#ifndef CPROVER_UTIL_CPROVER_PREFIX_H
1111
#define CPROVER_UTIL_CPROVER_PREFIX_H
1212

13+
// NOLINTNEXTLINE(build/deprecated)
1314
#define CPROVER_PREFIX "__CPROVER_"
15+
// NOLINTNEXTLINE(build/deprecated)
1416
#define CPROVER_FKT_PREFIX "__CPROVER_fkt_"
17+
// NOLINTNEXTLINE(build/deprecated)
1518
#define CPROVER_MACRO_PREFIX "__CPROVER_macro_"
1619

1720
#endif // CPROVER_UTIL_CPROVER_PREFIX_H

0 commit comments

Comments
 (0)