MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / countSideEffectsRecursive

Function countSideEffectsRecursive

addons/misra.py:1018–1034  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

1016
1017
1018def countSideEffectsRecursive(expr):
1019 if not expr or expr.str == ';':
1020 return 0
1021 if expr.str == '=' and expr.astOperand1 and expr.astOperand1.str == '[':
1022 prev = expr.astOperand1.previous
1023 if prev and (prev.str == '{' or prev.str == '{'):
1024 return countSideEffectsRecursive(expr.astOperand2)
1025 if expr.str == '=' and expr.astOperand1 and expr.astOperand1.str == '.':
1026 e = expr.astOperand1
1027 while e and e.str == '.' and e.astOperand2:
1028 e = e.astOperand1
1029 if e and e.str == '.':
1030 return 0
1031 if expr.isAssignmentOp or expr.str in {'++', '--'}:
1032 return 1
1033 # Todo: Check function calls
1034 return countSideEffectsRecursive(expr.astOperand1) + countSideEffectsRecursive(expr.astOperand2)
1035
1036
1037def isBoolExpression(expr):

Callers 4

misra_13_5Method · 0.85
misra_13_6Method · 0.85
misra_14_2Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected