Given an node, return function name being called Throws NotFunctionCallException Case 1: casting function pointer is not function call Example: tmp.sa_handler = (void (*)(int)) handler; Case 2: function call from struct variable Example: tty->write(tty)
(call_node)
| 45 | |
| 46 | |
| 47 | def handle_call(call_node): |
| 48 | """Given an <call> node, return function name being called |
| 49 | |
| 50 | Throws NotFunctionCallException |
| 51 | |
| 52 | Case 1: casting function pointer is not function call |
| 53 | Example: tmp.sa_handler = (void (*)(int)) handler; |
| 54 | |
| 55 | Case 2: function call from struct variable |
| 56 | Example: tty->write(tty) |
| 57 | |
| 58 | """ |
| 59 | name_node = call_node.find('srcml:name', ns) |
| 60 | if name_node is None: |
| 61 | # Case 1 |
| 62 | raise NotFunctionCallError() |
| 63 | callee_name = name_node.text |
| 64 | if callee_name is None: |
| 65 | # Case 2 |
| 66 | callee_name = name_node[-1].text |
| 67 | return callee_name |
| 68 | |
| 69 | |
| 70 | def build_call_graph_c(roots, G=None): |
no test coverage detected