(self, data)
| 3440 | self.reportError(token, 17, 1) |
| 3441 | |
| 3442 | def misra_17_2(self, data): |
| 3443 | # find recursions.. |
| 3444 | def find_recursive_call(search_for_function, direct_call, calls_map, visited=None): |
| 3445 | if visited is None: |
| 3446 | visited = set() |
| 3447 | if direct_call == search_for_function: |
| 3448 | return True |
| 3449 | for indirect_call in calls_map.get(direct_call, []): |
| 3450 | if indirect_call == search_for_function: |
| 3451 | return True |
| 3452 | if indirect_call in visited: |
| 3453 | # This has already been handled |
| 3454 | continue |
| 3455 | visited.add(indirect_call) |
| 3456 | if find_recursive_call(search_for_function, indirect_call, calls_map, visited): |
| 3457 | return True |
| 3458 | return False |
| 3459 | |
| 3460 | # List functions called in each function |
| 3461 | function_calls = {} |
| 3462 | for scope in data.scopes: |
| 3463 | if scope.type != 'Function': |
| 3464 | continue |
| 3465 | calls = [] |
| 3466 | tok = scope.bodyStart |
| 3467 | while tok != scope.bodyEnd: |
| 3468 | tok = tok.next |
| 3469 | if not isFunctionCall(tok, data.standards.c): |
| 3470 | continue |
| 3471 | f = tok.astOperand1.function |
| 3472 | if f is not None and f not in calls: |
| 3473 | calls.append(f) |
| 3474 | function_calls[scope.function] = calls |
| 3475 | |
| 3476 | # Report warnings for all recursions.. |
| 3477 | for func in function_calls: |
| 3478 | for call in function_calls[func]: |
| 3479 | if not find_recursive_call(func, call, function_calls): |
| 3480 | # Function call is not recursive |
| 3481 | continue |
| 3482 | # Warn about all functions calls.. |
| 3483 | for scope in data.scopes: |
| 3484 | if scope.type != 'Function' or scope.function != func: |
| 3485 | continue |
| 3486 | tok = scope.bodyStart |
| 3487 | while tok != scope.bodyEnd: |
| 3488 | if tok.function and tok.function == call: |
| 3489 | self.reportError(tok, 17, 2) |
| 3490 | tok = tok.next |
| 3491 | |
| 3492 | def misra_17_3(self, cfg): |
| 3493 | # Check for Clang warnings related to implicit function declarations |
nothing calls this directly
no test coverage detected