[C++20][Modules] Implement include translation.
This addresses [cpp.include]/7 (when encountering #include header-name) If the header identified by the header-name denotes an importable header, it is implementation-defined whether the #include preprocessing directive is instead replaced by an import directive. In this implementation, include translation is performed _only_ for headers in the Global Module fragment, so: ``` module; #include "will-be-translated.h" // IFF the header unit is available. export module M; #include "will-not-be-translated.h" // even if the header unit is available ``` The reasoning is that, in general, includes in the module purview would not be validly translatable (they would have to immediately follow the module decl and without any other intervening decls). Otherwise that would violate the rules on contiguous import directives. This would be quite complex to track in the preprocessor, and for relatively little gain (the user can 'import "will-not-be-translated.h";' instead.) TODO: This is one area where it becomes increasingly difficult to disambiguate clang modules in C++ from C++ standard modules. That needs to be addressed in both the driver and the FE. Differential Revision: https://reviews.llvm.org/D128981
Loading
Please sign in to comment