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

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 09:51:13 PDT 2025


yronglin 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).

I try to implement the 2nd approach, generate kw_import as `__import__` in preprocessed output, does clang has any existing mechanism to detect whether it is currently compiling a preprocessed file? 

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


More information about the cfe-commits mailing list