MCPcopy Index your code
hub / github.com/nodejs/node / CheckForNonStandardConstructs

Function CheckForNonStandardConstructs

tools/cpplint.py:3720–3943  ·  view source on GitHub ↗

r"""Logs an error if we see certain non-ANSI constructs ignored by gcc-2. Complain about several constructs which gcc-2 accepts, but which are not standard C++. Warning about these in lint is one way to ease the transition to new compilers. - put storage class first (e.g. "static c

(filename, clean_lines, linenum, nesting_state, error)

Source from the content-addressed store, hash-verified

3718
3719
3720def CheckForNonStandardConstructs(filename, clean_lines, linenum, nesting_state, error):
3721 r"""Logs an error if we see certain non-ANSI constructs ignored by gcc-2.
3722
3723 Complain about several constructs which gcc-2 accepts, but which are
3724 not standard C++. Warning about these in lint is one way to ease the
3725 transition to new compilers.
3726 - put storage class first (e.g. "static const" instead of "const static").
3727 - "%lld" instead of %qd" in printf-type functions.
3728 - "%1$d" is non-standard in printf-type functions.
3729 - "\%" is an undefined character escape sequence.
3730 - text after #endif is not allowed.
3731 - invalid inner-style forward declaration.
3732 - >? and <? operators, and their >?= and <?= cousins.
3733
3734 Additionally, check for constructor/destructor style violations and reference
3735 members, as it is very convenient to do so while checking for
3736 gcc-2 compliance.
3737
3738 Args:
3739 filename: The name of the current file.
3740 clean_lines: A CleansedLines instance containing the file.
3741 linenum: The number of the line to check.
3742 nesting_state: A NestingState instance which maintains information about
3743 the current stack of nested blocks being parsed.
3744 error: A callable to which errors are reported, which takes 4 arguments:
3745 filename, line number, error level, and message
3746 """
3747
3748 # Remove comments from the line, but leave in strings for now.
3749 line = clean_lines.lines[linenum]
3750
3751 if re.search(r'printf\s*\(.*".*%[-+ ]?\d*q', line):
3752 error(
3753 filename,
3754 linenum,
3755 "runtime/printf_format",
3756 3,
3757 "%q in format strings is deprecated. Use %ll instead.",
3758 )
3759
3760 if re.search(r'printf\s*\(.*".*%\d+\$', line):
3761 error(
3762 filename,
3763 linenum,
3764 "runtime/printf_format",
3765 2,
3766 "%N$ formats are unconventional. Try rewriting to avoid them.",
3767 )
3768
3769 # Remove escaped backslashes before looking for undefined escapes.
3770 line = line.replace("\\\\", "")
3771
3772 if re.search(r'("|\').*\\(%|\[|\(|{)&#x27;, line):
3773 error(
3774 filename,
3775 linenum,
3776 "build/printf_format",
3777 3,

Callers 1

ProcessLineFunction · 0.85

Calls 7

InnermostClassMethod · 0.80
matchMethod · 0.65
errorFunction · 0.50
searchMethod · 0.45
splitMethod · 0.45
escapeMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…