This is an archive of the discontinued LLVM Phabricator instance.

[C++20][Modules][2/8] Add enumerations for partition modules and stream them.
ClosedPublic

Authored by iains on Nov 29 2021, 8:16 AM.

Details

Summary

This is an initial enabling patch for module partition support.
We add enumerations for partition interfaces/implementations.
This means that the module kind enumeration now occupies three
bits, so the AST streamer is adjusted for this. Adding one bit there
seems preferable to trying to overload the meanings of existing
kinds (and we will also want to add a C++20 header unit case later).

Diff Detail

Event Timeline

iains created this revision.Nov 29 2021, 8:16 AM
iains updated this revision to Diff 404447.Jan 31 2022, 2:13 AM

Rebased, moved an unreleated change to a later patch.

iains retitled this revision from [modules] Add enumerations for partition modules and stream them. to [C++20][Modules] Add enumerations for partition modules and stream them..Jan 31 2022, 2:21 AM
iains edited the summary of this revision. (Show Details)
iains updated this revision to Diff 405587.Feb 3 2022, 5:00 AM

Rebased onto D118893

iains updated this revision to Diff 408758.Feb 15 2022, 1:20 AM

Rebased onto other modules work

iains updated this revision to Diff 408804.Feb 15 2022, 3:54 AM

address formatting issues.

not sure why these showed up now and not in previous rebases...

iains published this revision for review.Feb 15 2022, 8:28 AM

this is the second in an 8 patch series to implement basic C++20 module partition support - here we add module types for partitions (and work on header units will add an additional enumeration in a subsequent series).

Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2022, 8:28 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
urnathan added inline comments.Feb 15 2022, 10:49 AM
clang/include/clang/Basic/Module.h
109

I think it's confusing to continue to refer to modules-ts modules at this point. Is that really necessary?
The specific confusion here is that does 'ModuleInterfaceUnit' mean one of two different things depending on compilation mode, or is it a single thing with two different names?

517–518

???

520

isModulePartition?

iains added inline comments.Feb 15 2022, 12:28 PM
clang/include/clang/Basic/Module.h
109

In this case, I re-used the enumeration since the modules-ts / c++20 modules are disambiguated by the -fmodules-ts flag.

So, yes, the enum value does have two uses depending on compilation mode. I can amend the comment to try and make this clear, would that help?

I have been trying not to regress anything for modules-ts (and certainly for clang modules) - if someone makes a decision to retire modules-ts then there is probably a bunch of simplification that could be made.

With the extra bit to represent the enumeration, we have more space so we *could* have different names for the modules-ts/C++20 interfaces (although I suspect that will just make more code at the use sites, and would prefer not to go down that route).

517–518

thanks, will remove this.

520

works for me, will do.

urnathan added inline comments.Feb 15 2022, 12:37 PM
clang/include/clang/Basic/Module.h
109

IMHO 'modules-ts' is not a useful thing distinct from 'c++20 modules'. The semantics of the TS itself were unclear or broken in places, and only resolved once things got into the std (via 1103/Atom). I think the semantics of '-fmodules-ts' should be the module-specific semantics of C++20 as applied to whatever version of the std being selected (and I'd be fine making it Buyer-Beware for anything before C++20 anyway).

But, if you don't want to bite that bullet right now, a clarifying note would be helpful.

iains updated this revision to Diff 409187.Feb 16 2022, 2:45 AM

address review comments

iains retitled this revision from [C++20][Modules] Add enumerations for partition modules and stream them. to [C++20][Modules][2/8] Add enumerations for partition modules and stream them..Feb 16 2022, 2:47 AM
iains marked 4 inline comments as done.
iains added inline comments.
clang/include/clang/Basic/Module.h
109

I think we can just go with C++20 and as you suggest treat the TS as a dialect.

This revision is now accepted and ready to land.Feb 16 2022, 3:53 AM
iains updated this revision to Diff 409548.Feb 17 2022, 2:05 AM
iains marked an inline comment as done.

rebased onto changes in parent patches.

please remind me when this is committed that I'll need to adjust D118352 -- at the moment that's searching for ':' to determine partitionness

iains updated this revision to Diff 410305.Feb 21 2022, 7:45 AM

rebased

This revision was landed with ongoing or failed builds.Feb 22 2022, 2:08 AM
This revision was automatically updated to reflect the committed changes.