| 5977 | const TDXRule *rule); |
| 5978 | |
| 5979 | static bool tdx_resolve(CBMExtractCtx *ctx, TSNode node, TSNode name_node, const char *macro, |
| 5980 | const char **name, TDXRule *rule) { |
| 5981 | *name = NULL; |
| 5982 | uint32_t line = ts_node_start_point(name_node).row + 1; |
| 5983 | if (!tdx_match(ctx, macro, strlen(macro), line, rule)) |
| 5984 | return false; |
| 5985 | if (ctx->result->test_declarations_status == CBM_TEST_EXTRACT_OOM) |
| 5986 | return true; |
| 5987 | if (!tdx_observe(ctx, name_node, node, NULL, rule) || !rule->valid) |
| 5988 | return true; |
| 5989 | uint32_t end = ts_node_end_byte(name_node); |
| 5990 | size_t id_at = 0, id_length = 0, after = 0; |
| 5991 | if (!ctx->source || ctx->source_len < 0 || end > (uint32_t)ctx->source_len) { |
| 5992 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, rule->declaration, line); |
| 5993 | return true; |
| 5994 | } |
| 5995 | if (!tdx_argument(ctx, end, rule->argument, &id_at, &id_length, &after, rule, line)) |
| 5996 | return true; |
| 5997 | TSNode candidate_name, body; |
| 5998 | if (!cbm_test_definition_candidate(node, ctx->language, &candidate_name, &body) || |
| 5999 | !ts_node_eq(candidate_name, name_node)) { |
| 6000 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, rule->declaration, line); |
| 6001 | return true; |
| 6002 | } |
| 6003 | if (!tdx_trivia(ctx->source, (size_t)ctx->source_len, &after) || |
| 6004 | after >= (size_t)ctx->source_len || ctx->source[after] != '{' || ts_node_is_null(body) || |
| 6005 | ts_node_has_error(body) || ts_node_is_missing(body) || ts_node_start_byte(body) != after || |
| 6006 | ts_node_end_byte(body) <= after || ts_node_end_byte(body) > (uint32_t)ctx->source_len || |
| 6007 | ctx->source[ts_node_end_byte(body) - 1] != '}') { |
| 6008 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, rule->declaration, line); |
| 6009 | return true; |
| 6010 | } |
| 6011 | *name = cbm_arena_sprintf(ctx->arena, "%s_%.*s", macro, (int)id_length, ctx->source + id_at); |
| 6012 | if (!*name) |
| 6013 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_OOM, rule->declaration, line); |
| 6014 | return true; |
| 6015 | } |
| 6016 | |
| 6017 | /* NULL qn records a recognized attempt, not a graph definition. A later |
| 6018 | * successful extraction fills its QN; the audit must not invent a second, |
no test coverage detected