[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 21 14:06:37 PDT 2025


hubert-reinterpretcast wrote:

> > There is a related problem that preprocessing the file first would (naturally) generate different behaviour for such a case.
> 
> Do you have any suggestion about this? @Bigcheese

The warning I suggested earlier is one approach (i.e., leave it as a problem for people who really have such code).

An alternative approach is to generate the plain `import` identifier, etc. as `__import_identifier__` (or similar) with a `#define __import_identifier__ import` line added in the preprocessed output. This will generally work without coordination with other producers or consumers.

A similar approach from the opposite direction is to generate `kw_import`, etc. as `__import__` (or similar) in preprocessed output and, when reading preprocessor output as input, treat `__import__` as `kw_import` and leave all instances of `import` as the identifier. This is likely to require coordination with other consumers (if not with other producers as well).

https://github.com/llvm/llvm-project/pull/107168


More information about the cfe-commits mailing list