[PATCH] D128981: [C++20][Modules] Implement include translation.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 03:55:22 PDT 2022

iains created this revision.
Herald added a project: All.
iains requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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:

   #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.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128981.441658.patch
Type: text/x-patch
Size: 16255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220701/a8d7e5ce/attachment-0001.bin>

More information about the cfe-commits mailing list