llvm-project/libcxx/test/support
Eric Fiselier 128af31595 Add option to disable variant narrowing conversion changes.
The paper P0608R3 - "A sane variant converting constructor" disallows
narrowing conversions in variant. It was meant to address this
surprising problem:

  std::variant<std::string, bool> v = "abc";
  assert(v.index() == 1); // constructs a bool.

However, it also disables every potentially narrowing conversion. For
example:

  variant<unsigned> v = 0; // ill-formed
  variant<string, double> v2 = 42; // ill-formed (int -> double narrows)

These latter changes break code. A lot of code. Within Google it broke
on the order of a hundred thousand target with thousands of root causes
responsible for the breakages.

Of the breakages related to the narrowing restrictions, none of them
exposed outstanding bugs. However, the breakages caused by boolean
conversions (~13 root causes), all but one of them were bugs.

For this reasons, I am adding a flag to disable the narrowing conversion
changes but not the boolean conversions one.

One purpose of this flag is to allow users to opt-out of breaking changes
in variant until the offending code can be cleaned up. For non-trivial
variant usages the amount of cleanup may be significant.

This flag is also required to support automated tooling, such as
clang-tidy, that can automatically fix code broken by this change.
In order for clang-tidy to know the correct alternative to construct,
it must know what alternative was being constructed previously, which
means running it over the old version of std::variant.

Because this change breaks so much code, I will be implementing the
aforementioned clang-tidy check in the very near future.

Additionally I'm plan present this new information to the committee so they can
re-consider if this is a breaking change we want to make.

I think libc++ should very seriously consider pulling this change
before the 9.0 release branch is cut. But that's a separate discussion
that I will start on the lists.

For now this is the minimal first step.

llvm-svn: 365960
2019-07-12 21:32:11 +00:00
..
test.support Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended. 2019-05-31 18:35:30 +00:00
test.workarounds Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended. 2019-05-31 18:35:30 +00:00
Counter.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
DefaultOnly.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
MoveOnly.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
allocators.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
any_helpers.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
archetypes.hpp [pair] Mark constructors as conditionally noexcept 2018-12-11 14:22:28 +00:00
archetypes.ipp [pair] Mark constructors as conditionally noexcept 2018-12-11 14:22:28 +00:00
asan_testing.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
assert_checkpoint.h Add checkpoint diagnostics to help diagnose buildbot failures. 2016-07-18 03:00:09 +00:00
charconv_test_helpers.h Make to_chars/from_chars work back to C++11. This means that we can use them to implement to_string as well. Reviewed as https://reviews.llvm.org/D59598. 2019-03-20 18:13:23 +00:00
cmpxchg_loop.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
constexpr_char_traits.hpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
container_debug_tests.hpp Remove unused try catch blocks from old debug tests 2019-03-19 00:00:30 +00:00
container_test_types.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
controlled_allocators.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
coroutine_types.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
count_new.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
counting_predicates.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
debug_mode_helper.h Fix test failures after debug mode changes 2019-03-18 22:12:09 +00:00
deleter_types.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
demangle.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
disable_missing_braces_warning.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
emplace_constructible.h fix shadowing warnings in new tests, try 2 2017-10-17 16:06:42 +00:00
experimental_any_helpers.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
external_threads.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
filesystem_dynamic_test_helper.py [test] [support] Use socket()+bind() to create unix sockets portably 2018-12-16 15:12:06 +00:00
filesystem_include.hpp Implement <filesystem> 2018-07-27 03:07:09 +00:00
filesystem_test_helper.hpp Add large file support to create_file for 32-bit. 2019-01-15 19:14:15 +00:00
format_string.hpp Fix missing includes in format_string.hpp helper 2018-07-25 04:21:59 +00:00
fp_compare.h Implement midpoint for floating point types. Reviewed as https://reviews.llvm.org/D61014. 2019-04-25 12:11:43 +00:00
hexfloat.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
is_transparent.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
min_allocator.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
msvc_stdlib_force_include.hpp [libc++] [test] Silence C++20 deprecation warnings in the MSVC STL 2019-04-19 20:39:41 +00:00
nasty_containers.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
nasty_macros.hpp Avoid name conflict with kernel headers 2019-04-24 09:43:44 +00:00
nothing_to_do.pass.cpp Support tests in freestanding 2019-02-04 20:31:13 +00:00
platform_support.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
poisoned_hash_helper.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
private_constructor.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
propagate_const_helpers.h
rapid-cxx-test.hpp Implement a better copy_file. 2018-07-22 02:00:53 +00:00
set_windows_crt_report_mode.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
template_cost_testing.h add header to help with template testing 2019-06-15 21:16:57 +00:00
test_allocator.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
test_comparisons.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
test_convertible.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
test_iterators.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
test_macros.h [WebAssembly] WASI support for libcxx 2019-05-01 16:47:30 +00:00
test_memory_resource.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
test_workarounds.h [libc++][test] Fix noexcept assertions in variant's get tests 2019-04-25 18:36:29 +00:00
tracked_value.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
truncate_fp.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
type_id.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
unique_ptr_test_helper.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
user_defined_integral.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
uses_alloc_types.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
variant_test_helpers.hpp Add option to disable variant narrowing conversion changes. 2019-07-12 21:32:11 +00:00
verbose_assert.h Implement filesystem NB comments, relative paths, and related issues. 2018-04-02 23:03:41 +00:00