Lines Matching refs:macro

1 /* CPP Library - traditional lexical analysis and macro expansion.
24 /* The replacement text of a function-like macro is stored as a
43 /* Structure holding information about a function-like macro
50 /* An array of size the number of macro parameters + 1, containing
51 the offsets of the start of each macro argument in the output
56 /* The hashnode of the macro. */
59 /* The offset of the macro name in the output buffer. */
62 /* The line the macro name appeared on. */
69 /* Lexing state. It is mostly used to prevent macro expansion. */
116 /* Skip a C-style block comment in a macro as a result of -CC.
137 macro.
311 macro. */
313 maybe_start_funlike (cpp_reader *pfile, cpp_hashnode *node, const uchar *start, struct fun_macro *macro)
315 unsigned int n = node->value.macro->paramc + 1;
317 if (macro->buff)
318 _cpp_release_buff (pfile, macro->buff);
319 macro->buff = _cpp_get_buff (pfile, n * sizeof (size_t));
320 macro->args = (size_t *) BUFF_FRONT (macro->buff);
321 macro->node = node;
322 macro->offset = start - pfile->out.base;
323 macro->argc = 0;
328 save_argument (struct fun_macro *macro, size_t offset)
330 macro->argc++;
331 if (macro->argc <= macro->node->value.macro->paramc)
332 macro->args[macro->argc] = offset;
343 _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
395 /* If this is a macro's expansion, pop it. */
451 cur = copy_comment (pfile, cur, macro != 0);
468 if (!pfile->state.skipping && (quote == 0 || macro))
486 && node->value.macro->fun_like)
495 /* Remove the object-like macro's name from the
503 else if (macro && (node->flags & NODE_MACRO_ARG) != 0)
508 save_replacement_text (pfile, macro, node->value.arg_index);
559 cpp_macro *m = fmacro.node->value.macro;
573 /* Remove the macro's invocation from the
589 /* A '#' from a macro doesn't start a directive. */
675 "unterminated argument list invoking macro \"%s\"",
680 /* Push a context holding the replacement text of the macro NODE on
682 macro with no arguments. */
701 cpp_macro *macro = node->value.macro;
702 macro->used = 1;
703 text = macro->exp.text;
704 macro->traditional = 1;
705 len = macro->count;
711 /* Returns TRUE if traditional macro recursion is detected. */
725 20 deep since the first invocation of this macro must be
727 if (recursing && node->value.macro->fun_like)
735 if (context->macro == node && depth > 20)
745 "detected recursion whilst expanding macro \"%s\"",
752 object-like non-builtin macro. */
754 _cpp_replacement_text_len (const cpp_macro *macro)
758 if (macro->fun_like && (macro->paramc != 0))
763 for (exp = macro->exp.text;;)
770 len += NODE_LEN (macro->params[b->arg_index - 1]);
775 len = macro->count;
784 _cpp_copy_replacement_text (const cpp_macro *macro, uchar *dest)
786 if (macro->fun_like && (macro->paramc != 0))
790 for (exp = macro->exp.text;;)
799 param = macro->params[b->arg_index - 1];
807 memcpy (dest, macro->exp.text, macro->count);
808 dest += macro->count;
814 /* Push a context holding the replacement text of the macro NODE on
816 macro with no arguments. */
820 cpp_macro *macro = fmacro->node->value.macro;
822 if (macro->paramc == 0)
832 for (exp = macro->exp.text;;)
849 for (exp = macro->exp.text;;)
870 /* So we free buffer allocation when macro is left. */
875 /* Read and record the parameters, if any, of a function-like macro
882 scan_parameters (cpp_reader *pfile, cpp_macro *macro)
894 if (_cpp_save_parameter (pfile, macro, lex_identifier (pfile, cur)))
907 ok = (*cur == ')' && macro->paramc == 0);
912 cpp_error (pfile, CPP_DL_ERROR, "syntax error in macro parameter list");
920 the replacement text for the current macro, followed by argument
924 save_replacement_text (cpp_reader *pfile, cpp_macro *macro,
930 if (macro->paramc == 0)
937 macro->exp.text = exp;
938 macro->traditional = 1;
939 macro->count = len;
948 if (macro->count + blen > BUFF_ROOM (pfile->a_buff))
949 _cpp_extend_buff (pfile, &pfile->a_buff, macro->count + blen);
952 block = (struct block *) (exp + macro->count);
953 macro->exp.text = exp;
954 macro->traditional = 1;
964 macro->count += blen;
968 BUFF_FRONT (pfile->a_buff) += macro->count;
972 /* Analyze and save the replacement text of a macro. Returns true on
975 _cpp_create_trad_definition (cpp_reader *pfile, cpp_macro *macro)
982 has not been updated for the macro name for in-file defines. */
988 /* Is this a function-like macro? */
991 bool ok = scan_parameters (pfile, macro);
994 macro->params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
996 /* Setting macro to NULL indicates an error occurred, and
999 macro = NULL;
1002 BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->params[macro->paramc];
1003 macro->fun_like = 1;
1013 _cpp_scan_out_logical_line (pfile, macro);
1016 if (!macro)
1025 save_replacement_text (pfile, macro, 0);