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

Function CheckInvalidIncrement

tools/cpplint.py:2984–3008  ·  view source on GitHub ↗

Checks for invalid increment *count++. For example following function: void increment_counter(int* count) { *count++; } is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++ or *count += 1. Args: filena

(filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

2982
2983
2984def CheckInvalidIncrement(filename, clean_lines, linenum, error):
2985 """Checks for invalid increment *count++.
2986
2987 For example following function:
2988 void increment_counter(int* count) {
2989 *count++;
2990 }
2991 is invalid, because it effectively does count++, moving pointer, and should
2992 be replaced with ++*count, (*count)++ or *count += 1.
2993
2994 Args:
2995 filename: The name of the current file.
2996 clean_lines: A CleansedLines instance containing the file.
2997 linenum: The number of the line to check.
2998 error: The function to call with any errors found.
2999 """
3000 line = clean_lines.elided[linenum]
3001 if _RE_PATTERN_INVALID_INCREMENT.match(line):
3002 error(
3003 filename,
3004 linenum,
3005 "runtime/invalid_increment",
3006 5,
3007 "Changing pointer instead of value (or unused value of operator*).",
3008 )
3009
3010
3011def IsMacroDefinition(clean_lines, linenum):

Callers 1

ProcessLineFunction · 0.85

Calls 2

matchMethod · 0.65
errorFunction · 0.50

Tested by

no test coverage detected