-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Enable variant P0608R3 in C++17, update LLVM, overhaul variant/any/optional tests
#4713
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
Merged
StephanTLavavej
merged 30 commits into
microsoft:main
from
StephanTLavavej:variant-overhaul
Jun 18, 2024
Merged
Enable variant P0608R3 in C++17, update LLVM, overhaul variant/any/optional tests
#4713
StephanTLavavej
merged 30 commits into
microsoft:main
from
StephanTLavavej:variant-overhaul
Jun 18, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tructor/Assignment.
Use extended regular expressions (`sed -E`). Use `FI[X]ME` to avoid any literal occurrences in the repo. Filter out REQUIRES, UNSUPPORTED, and XFAIL, as they would affect the consolidated test. We don't need to use `-a` in `find`; logical AND is the default. We can skip `nothing_to_do` tests for all three. Improve `do ... done` style.
I renamed some of the namespaces to be more consistent. `ctor::in_place_type_args::run_test();` is now called in order.
With updated "no workaround" arrow comments.
…ted). Also appears in libcxx expected_results.txt: std/utilities/variant/variant.relops/three_way.pass.cpp
These also appear in libcxx expected_results.txt: std/utilities/variant/variant.relops/three_way.pass.cpp std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
…AS_CXX20`. We were previously guarding plain visit, which was unnecessary.
This significantly extends test coverage - we previously skipped all of the visit and visit::return_type tests for permissive mode, when only `has_visit<BadVariant>` was affected.
I renamed `ctor::in_place_type` to be more consistent. `not_literal::run_test()` has been removed.
…ct is not thread-safe
I renamed some of the namespaces to be more consistent. The run_test() calls are now exhaustive and ordered; e.g. `assign::const_optional_U` was previously missing.
With updated "no workaround" arrow comments.
…nclude.h>` preamble. x64 `/std:c++latest` compiler memory consumption: Test | Flavor | Before | After ---------------------|------------|--------|------- P0088R3_variant | Plain | 3.1 GB | 2.1 GB P0088R3_variant_msvc | Plain | N/A | 1.1 GB P0088R3_variant | `/analyze` | 4.9 GB | 3.4 GB P0088R3_variant_msvc | `/analyze` | N/A | 1.6 GB This improved total test runtime from 72.5s to 56.4s (1.29x speedup). Presumably this was caused by better parallelism (splitting up long-tail `/analyze` configurations) and won't significantly impact full test runs.
|
I'm speculatively mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
barcharcraz
approved these changes
Jun 18, 2024
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This updates
<variant>to make a C++20 behavioral change unconditional, updates our LLVM submodule yet again to pick up small improvements, and finally performs a large overhaul of our LLVM-derived tests forvariant,any, andoptional. This overhaul picks up newly-added test coverage (e.g. for spaceship comparisons), cleans up test coverage that was unintentionally missing, and splits the extremely largevarianttest into LLVM-derived and MSVC-specific parts.Product code
variant's Converting Constructor/Assignment.<variant>: Should we treat P0608R3 as a DR against C++17? #4412std::variant<bool> b(1)".I originally worried about the source-breaking impact of extending this C++20 behavioral change down to C++17. However, libc++ and libstdc++ have implemented this downlevel, the ecosystem has had some time to adapt (for projects that are portable, or compiled with MSVC C++20), and I think the remaining cleanup costs will be manageable.
I thought about guarding this with an escape hatch macro, but I'd like to try just ripping off the bandage. Unlike (for example) header-inclusion escape hatches, supporting both the old and new modes would require the old mode to be tested, and test coverage is what finally pushed me to make this change (as libc++'s tests started assuming this new behavior).
LLVM
__has_includeusage, expand condvarany and spaceship coverage llvm/llvm-project#94120optionaltest functions asTEST_CONSTEXPR_CXX20llvm/llvm-project#94172transform_llvm.sh
sed -E).FI[X]MEto avoid any literal occurrences in the repo.-ainfind; logical AND is the default.nothing_to_dotests for all three.do ... donestyle.P0088R3_variant
run_test()calls.ctor::in_place_type_args::run_test();is now called in order.std::hash,std::getspecializations./clrworkarounds.STL/tests/libcxx/expected_results.txt
Lines 304 to 305 in e36ee6c
STL/tests/libcxx/expected_results.txt
Lines 726 to 727 in e36ee6c
STL/tests/libcxx/expected_results.txt
Lines 1093 to 1094 in e36ee6c
relops::three_way,visit::return_typewith_HAS_CXX20.visit, which was unnecessary.visit.visit#3808is_permissive.is_permissiveallows us to detect the mode without needing the matrix to define macros.visitandvisit::return_typetests for permissive mode, when onlyhas_visit<BadVariant>was affected.P0220R1_any
run_test()calls.ctor::in_place_typeto be more consistent.not_literal::run_test()has been removed./clrworkaround, update instructions to record what we did.P0220R1_optional
run_test()calls.run_test()calls are now exhaustive and ordered; e.g.assign::const_optional_Uwas previously missing.std::hashspecialization._HAS_CXX20/_HAS_CXX23guards.Escape hatches
P0088R3_variant_msvc
<msvc_stdlib_force_include.h>preamble.x64
/std:c++latestcompiler memory consumption as reported by/d1reportMemorySummary:/analyze/analyzeThis improved total test runtime from 72.5s to 56.4s (1.29x speedup). Presumably this was caused by better parallelism (splitting up long-tail
/analyzeconfigurations) and won't significantly impact full test runs.