[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)
Ian Anderson via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 11 17:00:49 PDT 2024
ian-twilightcoder wrote:
> To clarify a little bit
>
> > [...] The "already included" state is global across all modules (which is necessary so that non-modular headers don't get compiled into multiple translation units and cause redeclaration errors).
>
> The necessity isn't actually true. The same definition in multiple modules shouldn't confuse clang as long as these definitions are identical. But this is a side issue.
Sometimes it does confuse clang, at least I saw problems with a `typedef enum` when I made an include-once header `textual`.
> To re-iterate what this change is about:
>
> 1. `#import` implies a file is a single-include
> 2. Textual header in a module map implies a file is a multi-include (aka re-entrant)
> 3. When we have both `#import` and the header marked as textual, `#import` "wins", i.e. the file is single-include
> 4. You want to make that when we have both `#import` and a textual header, textual should "win", i.e. the file should be multi-include
>
> Is it correct?
That's correct. `#import` is an external source - often it comes from the users of the header and not the author, and the users might not be consistent with each other. `textual` comes from the author and a much stronger indicator of intent.
https://github.com/llvm/llvm-project/pull/83660
More information about the cfe-commits
mailing list