A replacement list referring to a configured definition is not a raw test * declaration. Surface it as unsupported instead of certifying only the * handwritten subset. The macro being defined is deliberately skipped. */
| 6171 | * declaration. Surface it as unsupported instead of certifying only the |
| 6172 | * handwritten subset. The macro being defined is deliberately skipped. */ |
| 6173 | static void tdx_directive(CBMExtractCtx *ctx, size_t begin, size_t end, uint32_t line) { |
| 6174 | const char *s = ctx->source + begin; |
| 6175 | end -= begin; |
| 6176 | /* Joining physical directive lines only detects opaque generated tests; |
| 6177 | * the joined bytes never become declaration or graph source evidence. */ |
| 6178 | bool spliced = false; |
| 6179 | for (size_t i = 0; i < end; i++) |
| 6180 | if (tdx_splice(s, end, i)) { |
| 6181 | spliced = true; |
| 6182 | break; |
| 6183 | } |
| 6184 | if (spliced) { |
| 6185 | CBMArena *scratch = ctx->scratch ? ctx->scratch : ctx->arena; |
| 6186 | char *joined = cbm_arena_alloc(scratch, end + 1); |
| 6187 | if (!joined) { |
| 6188 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_OOM, -1, line); |
| 6189 | return; |
| 6190 | } |
| 6191 | size_t used = 0; |
| 6192 | for (size_t i = 0; i < end;) { |
| 6193 | if (tdx_splice(s, end, i)) |
| 6194 | i += s[i + 1] == '\r' ? 3 : 2; |
| 6195 | else |
| 6196 | joined[used++] = s[i++]; |
| 6197 | } |
| 6198 | joined[used] = '\0'; |
| 6199 | s = joined; |
| 6200 | end = used; |
| 6201 | } |
| 6202 | size_t at = 1; |
| 6203 | if (!tdx_trivia(s, end, &at)) { |
| 6204 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, -1, line); |
| 6205 | return; |
| 6206 | } |
| 6207 | size_t word = at; |
| 6208 | while (at < end && tdx_ident((unsigned char)s[at])) |
| 6209 | at++; |
| 6210 | if (!tdx_equal("define", s + word, at - word)) |
| 6211 | return; |
| 6212 | if (!tdx_trivia(s, end, &at) || at == end || !tdx_ident_first((unsigned char)s[at])) { |
| 6213 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, -1, line); |
| 6214 | return; |
| 6215 | } |
| 6216 | while (at < end && tdx_ident((unsigned char)s[at])) |
| 6217 | at++; |
| 6218 | /* A function-like macro's formal parameters are not its replacement. */ |
| 6219 | if (at < end && s[at] == '(') { |
| 6220 | while (at < end && s[at] != ')') |
| 6221 | at++; |
| 6222 | if (at == end) { |
| 6223 | tdx_issue(ctx->result, CBM_TEST_EXTRACT_UNSUPPORTED_FORM, -1, line); |
| 6224 | return; |
| 6225 | } |
| 6226 | at++; |
| 6227 | } |
| 6228 | while (at < end) { |
| 6229 | if (tdx_splice(s, end, at)) { |
| 6230 | at += s[at + 1] == '\r' ? 3 : 2; |
no test coverage detected