This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Prepare string.{access, capacity, cons} tests for constexpr
ClosedPublic

Authored by philnik on Feb 7 2022, 2:42 AM.

Diff Detail

Event Timeline

philnik created this revision.Feb 7 2022, 2:42 AM
philnik requested review of this revision.Feb 7 2022, 2:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 2:42 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik updated this revision to Diff 406372.Feb 7 2022, 2:57 AM
  • Comment out static_assert
ldionne requested changes to this revision.Feb 7 2022, 12:44 PM

My expectation is that the commit that will actually implement constexpr string should then only uncomment those static_asserts and also should make the necessary changes in std::basic_string. That's exactly how this should be done, so this is great, however I am left wondering if that's really all the test changes that are going to be necessary.

libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp
27–28

Missing TEST_CONSTEXPR_CXX20.

libcxx/test/std/strings/basic.string/string.capacity/empty.verify.cpp
21

Missing TEST_CONSTEXPR_CXX20.

libcxx/test/std/strings/basic.string/string.capacity/length.pass.cpp
26–27

Missing TEST_CONSTEXPR_CXX20. I think several other functions below are missing it too, so I'll stop here.

libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
104

All of those should be

#if TEST_STD_VER > 17
  // static_assert(test());
#endif
This revision now requires changes to proceed.Feb 7 2022, 12:44 PM
philnik updated this revision to Diff 406582.Feb 7 2022, 12:57 PM
philnik marked 3 inline comments as done.
  • Add version guards

@ldionne No, they aren't all the changes, but most of them. I first want to make these very easy to verify changes and then the actual behavioral changes.
I think most of the rest are ignoring exception tests during constant evaluation, but I think it will be easier for everybody if I put all the else if (!TEST_IS_CONSTANT_EVALUATED) into a single PR.

libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp
27–28

The problem is that clang will warn on these. They aren't templates, so they have to be made constexpr with the functional changes.

ldionne accepted this revision.Feb 8 2022, 2:24 PM
ldionne added inline comments.
libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp
27–28

Oh, of course. Otherwise Clang complains about a constexpr function never being constexpr-friendly.

This revision is now accepted and ready to land.Feb 8 2022, 2:24 PM