This is an archive of the discontinued LLVM Phabricator instance.

[C++20] [Modules] Implement AllAdditionalTUReachable
AbandonedPublic

Authored by ChuanqiXu on Jun 7 2022, 1:02 AM.

Details

Reviewers
iains
rsmith
MaskRay
Group Reviewers
Restricted Project
Summary

[module.reach]p2 gives vendors freedom to decide whether or not additional TU is reachable:

All translation units that are necessarily reachable are reachable. Additional translation units on which the point within the program has an interface dependency may be considered reachable, but it is unspecified which are and under what circumstances.

And @rsmith suggested:

The default should probably be that we enforce reachability as strictly as we can, for portability and to help users enforce an "import what you use" hygiene rule, but in any case, we should give users the choice.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Jun 7 2022, 1:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 1:02 AM
ChuanqiXu requested review of this revision.Jun 7 2022, 1:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 1:02 AM
ChuanqiXu added a reviewer: MaskRay.

Rebasing.

The direction is approved in https://reviews.llvm.org/D113545. @MaskRay might you help to review the style?

Hi @ChuanqiXu,
I have no comment on the technical content of the patch (it looks reasonable to me).

However, I wonder if we should be supplying this option at all because in:
https://eel.is/c++draft/module#reach-2
note2 says "[Note 2: It is advisable to avoid depending on the reachability of any additional translation units in programs intending to be portable. — end note]"

So by providing the option, we are effectively giving users an easy mechanism to make non-portable programs (and I'm fairly sure that would mean that they would not have the same characteristics between clang and GCC with this);
So I'd like to know what (preferably real-world) code motivates the addition of this option.

ChuanqiXu abandoned this revision.Jul 14 2022, 12:07 AM

Hi @ChuanqiXu,
I have no comment on the technical content of the patch (it looks reasonable to me).

However, I wonder if we should be supplying this option at all because in:
https://eel.is/c++draft/module#reach-2
note2 says "[Note 2: It is advisable to avoid depending on the reachability of any additional translation units in programs intending to be portable. — end note]"

So by providing the option, we are effectively giving users an easy mechanism to make non-portable programs (and I'm fairly sure that would mean that they would not have the same characteristics between clang and GCC with this);
So I'd like to know what (preferably real-world) code motivates the addition of this option.

Oh, I see. In fact, I didn't meet any motivated case before. The motivation of the revision is that we feel like it might be better to add an option in D113545. But now I feel like the option is not good indeed. And this one is relatively easy to implement. So we could re-land this if we find it is useful someday.