Home | History | Annotate | Download | only in preprocessor

Lines Matching defs:macro

86 	for (auto macro : mExpander->mMacrosToReenable)
90 assert(macro->name.substr() != "");
91 macro->disabled = false;
129 // Defined operator is parsed here since it may be generated by macro expansion.
130 // Defined operator produced by macro expansion has undefined behavior according to C++
177 std::shared_ptr<Macro> macro = iter->second;
178 if (macro->disabled)
186 // otherwise there could be a #undef of the macro before the next token.
187 macro->expansionCount++;
188 if ((macro->type == Macro::kTypeFunc) && !isNextTokenLeftParen())
190 // If the token immediately after the macro name is not a '(',
191 // this macro should not be expanded.
192 macro->expansionCount--;
196 pushMacro(macro, *token);
209 // First pop all empty macro contexts.
252 bool MacroExpander::pushMacro(std::shared_ptr<Macro> macro, const Token &identifier)
254 assert(!macro->disabled);
257 assert(identifier.text == macro->name);
260 if (!expandMacro(*macro, identifier, &replacements))
263 // Macro is disabled for expansion until it is popped off the stack.
264 macro->disabled = true;
267 context->macro = macro;
282 assert(context->macro->disabled);
283 assert(context->macro->expansionCount > 0);
286 mMacrosToReenable.push_back(context->macro);
290 context->macro->disabled = false;
292 context->macro->expansionCount--;
297 bool MacroExpander::expandMacro(const Macro &macro,
303 // In the case of an object-like macro, the replacement list gets its location
304 // from the identifier, but in the case of a function-like macro, the replacement
305 // list gets its location from the closing parenthesis of the macro invocation.
308 if (macro.type == Macro::kTypeObj)
310 replacements->assign(macro.replacements.begin(), macro.replacements.end());
312 if (macro.predefined)
319 if (macro.name == kLine)
323 else if (macro.name == kFile)
331 assert(macro.type == Macro::kTypeFunc);
333 args.reserve(macro.parameters.size());
334 if (!collectMacroArgs(macro, identifier, &args, &replacementLocation))
337 replaceMacroParams(macro, args, replacements);
355 bool MacroExpander::collectMacroArgs(const Macro &macro,
419 const Macro::Parameters &params = macro.parameters;
428 Diagnostics::ID id = args->size() < macro.parameters.size() ?
437 // inserted into the macro body.
467 void MacroExpander::replaceMacroParams(const Macro &macro,
471 for (std::size_t i = 0; i < macro.replacements.size(); ++i)
481 const Token &repl = macro.replacements[i];
489 // There is no need to search for macro params every time.
491 Macro::Parameters::const_iterator iter =
492 std::find(macro.parameters.begin(), macro.parameters.end(), repl.text);
493 if (iter == macro.parameters.end())
499 std::size_t iArg = std::distance(macro.parameters.begin(), iter);
508 // macro replacement token.
513 MacroExpander::MacroContext::MacroContext() : macro(0), index(0)