[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
Thu Nov 4 22:25:58 PDT 2021
Hi Aaron,
Your suggestion makes sense. I have posted a issue here: https://bugs.llvm.org/show_bug.cgi?id=52413.
It would be great if someone who is more familiar with clang driver would love to fix it.
If others are busy, I would try to fix it. I guess it might not be so hard to implement?
Thanks,
Chuanqi
------------------------------------------------------------------
From:Aaron Ballman <aaron at aaronballman.com>
Send Time:2021年11月4日(星期四) 21:21
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 10:00 PM chuanqi.xcq <yedeng.yd at linux.alibaba.com> wrote:
>
> 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.
Personally, I don't consider that to be a valid use case. If the user
wants C++20, they get modules because that's what it means to compile
against C++20
> 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?
I think I'd feel more comfortable if the user had to explicitly opt
*out* of the C++20 feature. e.g., `clang -std=c++20 -fno-cxx-modules
-fmodules` (though if we went this route, it might be a kindness to
consider renaming -fmodules to -fclang-modules). We have a similar
relationship with exceptions -- you get them by default, but you can
opt out of them if you need to (or opt into other exception models).
~Aaron
>
> 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/20211105/3f511c79/attachment-0001.html>
More information about the cfe-dev
mailing list