This is an archive of the discontinued LLVM Phabricator instance.

[C++20][Modules][Driver][HU 3/N] Handle foo.h with -fmodule-header and/or C++ invocation.
ClosedPublic

Authored by iains on Mar 14 2022, 4:20 AM.

Details

Summary

Allow an invocation like clang -fmodule-header bar.h (which will be a C++
compilation, but using a header which will be recognised as a C one).

Also we do not want to produce:
"treating 'c-header' input as 'c++-header' when in C++ mode"
diagnostics when the user has been specific about the intent.

Diff Detail

Event Timeline

iains created this revision.Mar 14 2022, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 4:20 AM
iains published this revision for review.Mar 14 2022, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 4:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This looks a little bit odd. Is this consistent with GCC too?

iains added a comment.Mar 16 2022, 3:42 AM

This looks a little bit odd. Is this consistent with GCC too?

It is consistent, GCC does not warm for this - but that was not the primary motivation in this case.

This is simply a convenience feature - considering that there are many C++ projects that use ".h" headers it saves the user from having to add "-xc++-header" in each case.

(since it is a convenience feature, it is non-essential, of course - but IMO useful even now)

iains updated this revision to Diff 416855.Mar 21 2022, 1:40 AM

rebased.

urnathan accepted this revision.Mar 22 2022, 10:28 AM

looks resonable, 1 nit.

clang/lib/Driver/Driver.cpp
2462–2466

extra whitespace 'are[spc][spc]counted'

This revision is now accepted and ready to land.Mar 22 2022, 10:28 AM
iains updated this revision to Diff 418267.Mar 25 2022, 10:11 AM

rebased, addrssed review comment, amend testcase for windows.

iains marked an inline comment as done.Mar 25 2022, 10:11 AM
iains updated this revision to Diff 418268.Mar 25 2022, 10:19 AM

another testcase ajustment for windows.

This revision was landed with ongoing or failed builds.Apr 23 2022, 1:51 AM
This revision was automatically updated to reflect the committed changes.