This is an archive of the discontinued LLVM Phabricator instance.

Allow constant static members to be used with 'this'
Needs ReviewPublic

Authored by usaxena95 on Aug 22 2022, 10:36 AM.

Details

Reviewers
aaron.ballman
Group Reviewers
Restricted Project
Summary

Diff Detail

Event Timeline

usaxena95 created this revision.Aug 22 2022, 10:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 10:36 AM
usaxena95 requested review of this revision.Aug 22 2022, 10:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 10:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
usaxena95 edited the summary of this revision. (Show Details)Aug 22 2022, 10:37 AM
usaxena95 updated this revision to Diff 454942.Aug 23 2022, 1:36 PM

only allow static members with this.

usaxena95 updated this revision to Diff 454946.Aug 23 2022, 1:44 PM

Add constexpr tests.

usaxena95 retitled this revision from Allow static consteval member functions to be used in const expressions. to Allow constant static members to be used with 'this'.Aug 23 2022, 1:44 PM
usaxena95 edited the summary of this revision. (Show Details)
aaron.ballman added reviewers: aaron.ballman, Restricted Project.Aug 26 2022, 12:29 PM
aaron.ballman removed a subscriber: aaron.ballman.

Thanks for this! Can you add some more details to the patch description so it's more clear from there why the patch is necessary? Also, can you add a release note for the fix?

I'm pretty sure the changes here are correct, but I want to take another run at the standards wording to be sure.

clang/lib/AST/ExprConstant.cpp
931

Add the docs?

8741–8743
clang/test/SemaCXX/cxx2a-consteval.cpp
925

You should add a new line back to the end of the file.

erichkeane added inline comments.
clang/lib/AST/ExprConstant.cpp
8458

When not in a constant-context, what should we be doing here? Why doesn't that set the variable?

8460

Will this visit end up looking into OTHER things here? I guess I'm concerned about something like:

this->get_some_other_type().static_func() and us skipping the this-> for THAT, despite it not being a static call in that context.

Given this has not made progress in a while, I think we should try to implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html instead of this approach, as I'm not sure if that's strictly conforming, and a more holistic approach is likely to lead to better results.
What do people think?

Given this has not made progress in a while, I think we should try to implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html instead of this approach, as I'm not sure if that's strictly conforming, and a more holistic approach is likely to lead to better results.
What do people think?

P2280R4 was adopted for C++23, so I think we'll need to do the work eventually. It likely makes sense to explore doing that work now, at the very least so we don't make it harder to implement in the future.

keryell added a subscriber: Tyker.Feb 28 2023, 4:19 PM
keryell added a subscriber: keryell.