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

Function findCounterTokens

addons/misra.py:962–980  ·  view source on GitHub ↗
(cond)

Source from the content-addressed store, hash-verified

960
961
962def findCounterTokens(cond):
963 if not cond:
964 return []
965 if cond.str in ['&&', '||']:
966 c = findCounterTokens(cond.astOperand1)
967 c.extend(findCounterTokens(cond.astOperand2))
968 return c
969 ret = []
970 if ((cond.isArithmeticalOp and cond.astOperand1 and cond.astOperand2) or
971 (cond.isComparisonOp and cond.astOperand1 and cond.astOperand2)):
972 if cond.astOperand1.isName:
973 ret.append(cond.astOperand1)
974 if cond.astOperand2.isName:
975 ret.append(cond.astOperand2)
976 if cond.astOperand1.isOp:
977 ret.extend(findCounterTokens(cond.astOperand1))
978 if cond.astOperand2.isOp:
979 ret.extend(findCounterTokens(cond.astOperand2))
980 return ret
981
982
983def isFloatCounterInWhileLoop(whileToken):

Callers 2

misra_14_1Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected