This is an archive of the discontinued LLVM Phabricator instance.

[clang][cli] Expose -fno-cxx-modules in cc1
ClosedPublic

Authored by jansvoboda11 on Jul 27 2021, 5:13 AM.

Details

Summary

For some use-cases, it might be useful to be able to turn off modules for C++ in -cc1. (The feature is implied by -std=C++20.)

This patch exposes the -fno-cxx-modules option in -cc1.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Jul 27 2021, 5:13 AM
jansvoboda11 requested review of this revision.Jul 27 2021, 5:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2021, 5:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 added inline comments.Jul 27 2021, 5:16 AM
clang/test/Modules/cxx20-disable.cpp
2

I'm not sure how to best test this. Checking the error messages is not that useful, since they don't make the intent here any clearer:

<path>/llvm-project/clang/test/Modules/cxx20-disable.cpp:4:8: error: expected template
export module Foo;
       ^
<path>/llvm-project/clang/test/Modules/cxx20-disable.cpp:4:8: error: unknown type name 'module'
2 errors generated.
arphaman added inline comments.Jul 29 2021, 8:15 AM
clang/test/Modules/cxx20-disable.cpp
2

You could still check the errors with -verify but add a comment that expressed the intent of why these errors are verified. Also it might make sense to add an inverse test case that doesn't use the -fno-cxx-modules flag, where this will just work.

Add negative test, check error messages.

clang/test/Modules/cxx20-disable.cpp
2

Addressed in the latest revision.

arphaman accepted this revision.Aug 2 2021, 12:48 PM

Thanks, LGTM

This revision is now accepted and ready to land.Aug 2 2021, 12:48 PM
This revision was automatically updated to reflect the committed changes.