[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 23 15:19:17 PDT 2022


rsmith added a comment.

In D125773#3525127 <https://reviews.llvm.org/D125773#3525127>, @ilya-biryukov wrote:

> It looks like this particular change actually breaks standard compatibility as we also use the same parsing action and don't build a module separately on `import`.
>
>   [module.import]p5
>   A module-import-declaration that specifies a header-name H imports a synthesized header unit, which is a
>   translation unit formed by applying phases 1 to 7 of translation (5.2) to the source file or header nominated
>   by H, which shall not contain a module-declaration.

For the record, the intention is that (with local submodule visibility enabled) we behave "as if" we preprocessed separately, even if we do so using the same parsing action: we store various parts of the preprocessor state (most notably, the defined macros map) per-module, so that when we switch modules, we get the same preprocessing behavior as if we'd started from a clean slate. Fundamentally, Clang's model is that a single `ASTContext` and a single preprocessing action can cover multiple translation units, and that includes the possibility that a single preprocessor or `Sema` object can process multiple translation units, and we make this work by tracking which macros and declarations and similar should be visible where, based on which modules are currently imported. This is intended to be a conforming strategy for implementing C++20 header units.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125773/new/

https://reviews.llvm.org/D125773



More information about the cfe-commits mailing list