[clang] [C++20][Modules] Quote header unit name in preprocessor output (-E) (PR #112883)
Dmitry Polukhin via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 14:18:31 PDT 2024
================
@@ -952,13 +952,15 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
continue;
} else if (Tok.is(tok::annot_header_unit)) {
// This is a header-name that has been (effectively) converted into a
- // module-name.
+ // module-name, print them inside quote.
// FIXME: The module name could contain non-identifier module name
- // components. We don't have a good way to round-trip those.
+ // components and OS specific file paths components. We don't have a good
+ // way to round-trip those.
Module *M = reinterpret_cast<Module *>(Tok.getAnnotationValue());
std::string Name = M->getFullModuleName();
- Callbacks->OS->write(Name.data(), Name.size());
- Callbacks->HandleNewlinesInToken(Name.data(), Name.size());
+ *Callbacks->OS << '"';
----------------
dmpolukhin wrote:
It is a good question but I don't see easy way to propagate `isAngled` from `Preprocessor::HandleHeaderIncludeOrImport` to tokens that will be printed here. This information cannot be putted to `Module` because it is not a characteristic of the module but information how it was spelled (even pointer to `Module*` is passed as `void*` token annotation value). Spelling file path in quotes at least won't break C++ parsing of the output as it happens now. TODO here already covers that information about spelled header unit should be preserved. But if you think it is required fix now, I'll create a new structure that will contain Module*, isAngled and spelled header-unit name to resolve TODO completely - it will require more changes.
https://github.com/llvm/llvm-project/pull/112883
More information about the cfe-commits
mailing list