This is an archive of the discontinued LLVM Phabricator instance.

[modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.
ClosedPublic

Authored by vsapsai on Jul 19 2022, 7:00 PM.

Details

Summary

Diagnostic for -Wauto-import shouldn't be a warning because it doesn't
represent a potential problem in code that should be fixed. And the
emitted fix-it is likely to trigger -Watimport-in-framework-header
which makes it challenging to have a warning-free codebase. But it is
still useful to see how include directives are translated into modular
imports and which module a header belongs to, that's why keep it as a remark.

Keep -Wauto-import for now to allow a gradual migration for codebases
using -Wno-auto-import, e.g., -Weverything -Wno-auto-import.

rdar://79594287

Diff Detail

Event Timeline

vsapsai created this revision.Jul 19 2022, 7:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 7:00 PM
Herald added a subscriber: ributzka. · View Herald Transcript
vsapsai requested review of this revision.Jul 19 2022, 7:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 7:00 PM
vsapsai added a subscriber: Restricted Project.Jul 19 2022, 7:01 PM

Not sure about the name of the flag -Rmodule-include-translation, seems to be verbose. So suggestions about the flag name are welcome. On the other hand, "auto-import" is expected to mean something else, for example, adding missing imports. And changing the name looks like an improvement.

iains added a subscriber: MaskRay.Jul 20 2022, 1:01 AM

makes sense to me...

I guess the name looks long at first, but it's specific (I find that easy-to-remember flag names are more important than short-to-type ones, but maybe that's just me) - I wonder if @MaskRay has any comments on the flag name,

For the record:
GCC uses : -flang-info-include-translate (-flang for flag-language, rather than 'flang', of course).
(which is a note, i.e. similar idea to the remark)

BTW.. (not for this patch, of course)
GCC also has
info-include-translate-not
Note #include directives not translated to import declarations, and not known to be textual.

Looks like GCC has some naming pattern there, thanks for sharing, Iain. So I want to share the pattern I'm aiming for. I'd like the flag to start with -Rmodule-... to be consistent with -Rmodule-build, -Rmodule-import, -Rmodule-lock.

makes sense to me...

I guess the name looks long at first, but it's specific (I find that easy-to-remember flag names are more important than short-to-type ones, but maybe that's just me) - I wonder if @MaskRay has any comments on the flag name,

For the record:
GCC uses : -flang-info-include-translate (-flang for flag-language, rather than 'flang', of course).
(which is a note, i.e. similar idea to the remark)

BTW.. (not for this patch, of course)
GCC also has
info-include-translate-not
Note #include directives not translated to import declarations, and not known to be textual.

Using remarks is suitable and the new name -Rmodule-include-translation looks good to me.

Thanks for mentioning similar options from GCC. The names feel a bit odd to me as I am thinking what "lang-info" means.

iains accepted this revision.Jul 20 2022, 11:45 PM

makes sense to me...

I guess the name looks long at first, but it's specific (I find that easy-to-remember flag names are more important than short-to-type ones, but maybe that's just me) - I wonder if @MaskRay has any comments on the flag name,

For the record:
GCC uses : -flang-info-include-translate (-flang for flag-language, rather than 'flang', of course).
(which is a note, i.e. similar idea to the remark)

BTW.. (not for this patch, of course)
GCC also has
info-include-translate-not
Note #include directives not translated to import declarations, and not known to be textual.

Using remarks is suitable and the new name -Rmodule-include-translation looks good to me.

Thanks for mentioning similar options from GCC. The names feel a bit odd to me as I am thinking what "lang-info" means.

GCC does not have the exact equivalent of 'remark' (so lang-info is something specific to the language being compiled).

This seems like something we should aim to get into llvm-15, so LGTM given the comments above.

This revision is now accepted and ready to land.Jul 20 2022, 11:45 PM

Thanks for the review!