@@ -3198,6 +3198,13 @@ namespace simplecpp {
31983198 result.takeTokens (operand);
31993199 }
32003200
3201+ /* * A new token from the replacement list of macro, Token::macro is the macro name */
3202+ Token *newToken (const TokenString &str, const Macro ¯o, bool whitespaceahead) const {
3203+ auto *tok = new Token (str, loc, whitespaceahead);
3204+ tok->macro = macro.name ();
3205+ return tok;
3206+ }
3207+
32013208 /* *
32023209 * The tokens that a token in the replacement list is replaced by: a parameter by its
32033210 * argument, # and a parameter by a string literal, and other tokens by a copy.
@@ -3212,8 +3219,7 @@ namespace simplecpp {
32123219 // # is an operator in a function-like macro when it is followed by a parameter
32133220 const unsigned int hashArg = (tok->op == ' #' ) ? getParameter (macro, next) : ~0U ;
32143221 if (hashArg < call.arguments .size ()) {
3215- operand.push_back (new Token (stringify (call.arguments [hashArg], loc, macro.name (), outputList), loc, next->whitespaceahead ));
3216- operand.back ()->macro = macro.name ();
3222+ operand.push_back (newToken (stringify (call.arguments [hashArg], loc, macro.name (), outputList), macro, next->whitespaceahead ));
32173223 tok = next;
32183224 return ;
32193225 }
@@ -3224,8 +3230,7 @@ namespace simplecpp {
32243230 operand.push_back (new Token (*argtok));
32253231 return ;
32263232 }
3227- operand.push_back (new Token (tok->str (), loc, tok->whitespaceahead ));
3228- operand.back ()->macro = macro.name ();
3233+ operand.push_back (newToken (tok->str (), macro, tok->whitespaceahead ));
32293234 }
32303235
32313236 /* *
0 commit comments