https://github.com/Bigcheese requested changes to this pull request.
Generally when we get the definition of a macro we loop over the tokens, for example: ```c++ SmallString<128> SpellingBuffer; bool First = true; for (const auto &T : MI.tokens()) { if (!First && T.hasLeadingSpace()) Value << ' '; Value << PP.getSpelling(T, SpellingBuffer); First = false; } ``` This handles all of the lexing requirements and should have the same output as your loop here. `MacroPPCallbacks::writeMacroDefinition` is a good example here. We do a similar thing in `DeclarationFragmentsBuilder::getFragmentsForMacro`, `PrintMacroDefinition` (PrintPreprocessedOutput.cpp), and `CodeCompletionResult::CreateCodeCompletionStringForMacro`. At this point we should just have common code that does this. Code completion is a bit special as it's only printing part of it, but I'd like to see macro decl/def printing happen in a single place. https://github.com/llvm/llvm-project/pull/85745 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits