MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / CheckInvalidIncrement

Function CheckInvalidIncrement

src/tests/coding/cpplint.py:2660–2679  ·  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: filename: The name of

(filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

2658
2659
2660def CheckInvalidIncrement(filename, clean_lines, linenum, error):
2661 """Checks for invalid increment *count++.
2662
2663 For example following function:
2664 void increment_counter(int* count) {
2665 *count++;
2666 }
2667 is invalid, because it effectively does count++, moving pointer, and should
2668 be replaced with ++*count, (*count)++ or *count += 1.
2669
2670 Args:
2671 filename: The name of the current file.
2672 clean_lines: A CleansedLines instance containing the file.
2673 linenum: The number of the line to check.
2674 error: The function to call with any errors found.
2675 """
2676 line = clean_lines.elided[linenum]
2677 if _RE_PATTERN_INVALID_INCREMENT.match(line):
2678 error(filename, linenum, 'runtime/invalid_increment', 5,
2679 'Changing pointer instead of value (or unused value of operator*).')
2680
2681
2682def IsMacroDefinition(clean_lines, linenum):

Callers 1

ProcessLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected