Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer consteval to _CONSTEVAL, enable <source_location> for Clang #3584

Merged
merged 3 commits into from
Mar 28, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Mar 21, 2023

And enable support for source_location for Clang.

I've observed that there're already some unprotected uses of consteval in C++20/23 modes, which should have proved that consteval gets well with MSVC and Clang. EDG is not well tested, but it is claimed that immediate functions are supported since 5.1. So I think consteval is also well supported.

I think _CONSTEVAL is still useful since there may be some other candidate functions for _CONSTEVAL that are needed for pre-C++20.

After this change, there'll be only one occurrence of _CONSTEVAL, which is in <random>:

_CONSTEVAL double _Cx_exp2(const int _Exp) noexcept {


Edit:

  • It seems that Clang15 doesn't define __cpp_consteval but accepts consteval without error.
  • I have to address the (possibly reasonable) implementation divergence on __builtin_COLUMN().
    • The results of __builtin_COLUMN() seem unchanged between Clang15 and 17 (Godbolt link).

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner March 21, 2023 15:12
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Mar 22, 2023
@StephanTLavavej StephanTLavavej self-assigned this Mar 22, 2023
#ifdef __clang__
const auto loc = source_location::current();
argument_test(__LINE__ - 1, 22, loc);
#else // ^^^ defined(__clang__) / !defined(__clang__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested: Missing vvv arrows. This isn't worth resetting testing, I'll clean it up later.

@StephanTLavavej StephanTLavavej removed their assignment Mar 25, 2023
@StephanTLavavej StephanTLavavej changed the title Prefer consteval to _CONSTEVAL whenever possible Prefer consteval to _CONSTEVAL, enable <source_location> for Clang Mar 25, 2023
@StephanTLavavej StephanTLavavej self-assigned this Mar 28, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit c0113f3 into microsoft:main Mar 28, 2023
@StephanTLavavej
Copy link
Member

Thanks for investigating this and enabling the feature! 🎉 😻 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants