MCPcopy Create free account
hub / github.com/alibaba/GraphScope / CheckInvalidIncrement

Function CheckInvalidIncrement

analytical_engine/misc/cpplint.py:2663–2682  ·  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

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

Callers 1

ProcessLineFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected