A function DEFINITION's parameter list: empty, `(void)`, or every parameter * named (variadic `...` allowed). A function-like macro invocation that only * looks like a declarator — `TEST_BEGIN(test_name)`, whose one "parameter" is * an untyped identifier read as a type — fails this, so its macro name is never * mistaken for the defined function's name. */
| 1008 | * an untyped identifier read as a type — fails this, so its macro name is never |
| 1009 | * mistaken for the defined function's name. */ |
| 1010 | static bool c_params_name_every_parameter(TSNode params) { |
| 1011 | enum { MAX_PARAMS_CHECKED = 64 }; /* indexed child access: keep it small */ |
| 1012 | uint32_t nc = ts_node_named_child_count(params); |
| 1013 | if (nc > MAX_PARAMS_CHECKED) { |
| 1014 | return false; |
| 1015 | } |
| 1016 | for (uint32_t i = 0; i < nc; i++) { |
| 1017 | TSNode p = ts_node_named_child(params, i); |
| 1018 | const char *pk = ts_node_type(p); |
| 1019 | if (strcmp(pk, "comment") == 0 || strcmp(pk, "variadic_parameter") == 0) { |
| 1020 | continue; |
| 1021 | } |
| 1022 | if (!ts_node_is_null(ts_node_child_by_field_name(p, TS_FIELD("declarator")))) { |
| 1023 | continue; |
| 1024 | } |
| 1025 | /* `(void)`: the one parameter is an unnamed primitive type. */ |
| 1026 | TSNode type = ts_node_child_by_field_name(p, TS_FIELD("type")); |
| 1027 | if (nc != 1 || ts_node_is_null(type) || strcmp(ts_node_type(type), "primitive_type") != 0) { |
| 1028 | return false; |
| 1029 | } |
| 1030 | } |
| 1031 | return true; |
| 1032 | } |
| 1033 | |
| 1034 | TSNode cbm_c_recovered_func_name(TSNode func_declarator) { |
| 1035 | TSNode null_node = {0}; |
no outgoing calls
no test coverage detected