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

Function is_composite_expr

addons/misra.py:585–603  ·  view source on GitHub ↗

MISRA C 2012, section 8.10.3

(expr, composite_operator=False)

Source from the content-addressed store, hash-verified

583
584
585def is_composite_expr(expr, composite_operator=False):
586 """MISRA C 2012, section 8.10.3"""
587 if expr is None:
588 return False
589
590 if not composite_operator:
591 if expr.str == '?' and simpleMatch(expr.astOperand2, ':'):
592 colon = expr.astOperand2
593 return is_composite_expr(colon.astOperand1,True) or is_composite_expr(colon.astOperand2, True)
594 if (expr.str in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~')):
595 return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True)
596 return False
597
598 # non constant expression?
599 if expr.isNumber:
600 return False
601 if expr.astOperand1 or expr.astOperand2:
602 return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True)
603 return True
604
605
606def getEssentialTypeCategory(expr):

Callers 2

misra_10_6Method · 0.85
misra_10_7Method · 0.85

Calls 1

simpleMatchFunction · 0.70

Tested by

no test coverage detected