Simply, we think it is weird to support c++20 module and clang module at the same time.
Further more, there was no way to judge if the compiler was running in clang module instead of c++20 module. Both in clang module and c++20 module, LangOpts::Modules would be true. So it makes it hard to implement c++20 semantics.
Main change in this patch:
- Emit an error if the driver/frontend detect that the input implies that it want to use clang module and c++20 module at the same time.
- Add variable LangOpts::ClangModules. LangOpts::ClangModules would be true only if the user specified -fmodules.
- Remove variable LangOpts::Modules. Add member function LangOpts::hasModules(). Replace all the uses of LangOpts::Modules with LangOpts::hasModules(). LangOpts::hasModules() would return true in case clang modules or c++20 modules are enabled.
And the thing confuses me is the wanted behavior of clang/Modules/ms-enums.cpp. See the inline comments for details.
Another thing Aaron proposed in the mailing list is to rename '-fmodules' to '-fclang-modules'. It sounds good. But this patch didn't contain this change since I think change the command line option may be a break change and need more discussion. Especially clang modules are used broadly.
Test-Plan: check-all (except clang/Modules/ms-enums.cpp)