MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / CheckInvalidIncrement

Function CheckInvalidIncrement

steps/cpplint.py:2674–2693  ·  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

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

Callers 1

ProcessLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected