[cfe-dev] What's the case if clang module and c++20 module are enabled at the same time?

chuanqi.xcq via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 3 19:00:14 PDT 2021


Hi

>> Personally, I think this was an oversight. It seems to me that trying
>> to be in both modules modes at the same time is not something we want
>> to support, so I'd be in favor of treating these as mutually exclusive
>> options and the user gets an error if they try.
>> 
>> ~Aaron
---

   I think so that we could avoid to support two modes at the same time. Another problem is that what's the behavior if user enabled '-std=c++20' and '-fmodules'.
I think an error may not be friendly enough since people may want to use other feature in C++20 and clang module. I wonder if it would be better when "-std=c++20"
and "-fmodules" occur at the same time, the compiler should emit a warning and disable c++20 modules by settting `CPlusPlusModules` to false. What's your opinion?

Thanks,
Chuanqi




------------------------------------------------------------------
From:Aaron Ballman <aaron at aaronballman.com>
Send Time:2021年11月3日(星期三) 20:34
To:chuanqi.xcq <yedeng.yd at linux.alibaba.com>
Cc:Clang Dev <cfe-dev at lists.llvm.org>; David Blaikie <dblaikie at gmail.com>; Richard Smith <richard at metafoo.co.uk>; Nathan Sidwell <nathan at acm.org>; "Keane, Erich" <erich.keane at intel.com>
Subject:Re: [cfe-dev] What's the case if clang module and c++20 module are enabled at the same time?

On Wed, Nov 3, 2021 at 7:51 AM chuanqi.xcq via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hi,
>
>    Recently I am developing C++20 semantics in clang. Then I met an interesting bug in
> compare-modules-cxx2a.cpp (https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/compare-modules-cxx2a.cpp).
>
>     The key point here is that the test uses `-std=c++2a` and `-fmodules` both. So my codes which is intended to work for C++20 module now tests for clang module. So here is the reason for the bug.
>
>     Beyond my personal work, it is weired for me that we could use clang module and c++20 module at the same time. (I know the implementation of c++20 is based on clang module).
> So I want to ask: do we have considered the case that we use clang module and c++20 module together? Is it neceesary? And what's the status after the user enable c++20 module and clang module?
>
>     For example, when we enter "clang -std=c++20 -fprebuilt-module-path=%t %s -c" to the command line, both `getLangOpts().CPlusPlusModules` and `getLangOpts().Modules` would evaluate to true, which is really weired.
> Is it intentional? Or is it a bug simply? Now I couldn't avoid the bug by `if (getLangOpts().CPlusPlusModules && !getLangOpts().Modules)`.

Personally, I think this was an oversight. It seems to me that trying
to be in both modules modes at the same time is not something we want
to support, so I'd be in favor of treating these as mutually exclusive
options and the user gets an error if they try.

~Aaron

>
>     I CCed people who looks like interested and related. Remind me if you feel uncomfortable.
>
> Thanks,
> Chuanqi
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20211104/e8dc9bb6/attachment.html>


More information about the cfe-dev mailing list