MCPcopy Index your code
hub / github.com/cpplint/cpplint / CheckInvalidIncrement

Function CheckInvalidIncrement

cpplint.py:2924–2948  ·  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

2922
2923
2924def CheckInvalidIncrement(filename, clean_lines, linenum, error):
2925 """Checks for invalid increment *count++.
2926
2927 For example following function:
2928 void increment_counter(int* count) {
2929 *count++;
2930 }
2931 is invalid, because it effectively does count++, moving pointer, and should
2932 be replaced with ++*count, (*count)++ or *count += 1.
2933
2934 Args:
2935 filename: The name of the current file.
2936 clean_lines: A CleansedLines instance containing the file.
2937 linenum: The number of the line to check.
2938 error: The function to call with any errors found.
2939 """
2940 line = clean_lines.elided[linenum]
2941 if _RE_PATTERN_INVALID_INCREMENT.match(line):
2942 error(
2943 filename,
2944 linenum,
2945 "runtime/invalid_increment",
2946 5,
2947 "Changing pointer instead of value (or unused value of operator*).",
2948 )
2949
2950
2951def IsMacroDefinition(clean_lines, linenum):

Callers 1

ProcessLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected