This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Many any test fixes
AbandonedPublic

Authored by CaseyCarter on Oct 4 2016, 12:25 PM.

Details

Summary

Changes to non-portable behavior in <any> tests. Inline detailed description of each change is forthcoming. Changes are almost entirely in test code, with one behavioral change to <any> itself to fix self-swap behavior.

Diff Detail

Event Timeline

CaseyCarter retitled this revision from to [libc++] Many any test fixes.
CaseyCarter updated this object.
CaseyCarter added reviewers: EricWF, mclow.lists.
CaseyCarter added a subscriber: cfe-commits.

I'll push a revision with the whitespace changes reverted soon.

.gitignore
59

This is an editor byproduct, I suppose, not "MSVC libraries test harness". Let me know if anyone cares and I'll add a comment.

include/any
553

Don't blow up on self swap. This is the obvious (naive) fix; it's possible that someone who has looked at more of the implementation than this single function could devise a better fix.

test/libcxx/utilities/any/any.class/any.assign/value.pass.cpp
26

This behavior is not required by N4606, so I moved this test to the libcxx tree.

test/libcxx/utilities/any/any.class/any.cons/value.pass.cpp
24

Again, not required behavior (I am, of course, totally unbiased about whether this behavior is a good idea.)

test/libcxx/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
35

ibid.

test/std/utilities/any/any.class/any.assign/move.pass.cpp
43

Portability fix: don't rely on a moved-from any being empty. (Occurs more below)

93

Woops - I forgot to review the diff without -w. Will correct this unintended whitespace change.

test/std/utilities/any/any.class/any.assign/value.pass.cpp
69

Again, don't rely on any's moved-from state being empty.

123

Whitespace again (will fix).

172

I split out these non-portable tests into test/libcxx/utilities/any.class/any.assign/value.pass.cpp

test/std/utilities/any/any.class/any.cons/copy.pass.cpp
74

Typo in the original test.

test/std/utilities/any/any.class/any.cons/move.pass.cpp
80

More move behavior.

97

Another inadvertent whitespace change.

test/std/utilities/any/any.class/any.cons/value.pass.cpp
110

Non-portable behavior split into test/libcxx/utilities/any.class/any.cons/value.pass.cpp

143

Inadvertent whitespace change.

182

See above.

test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
132

Ensure that LargeThrows is large, regardless of how bloated std::any may become.

234

Inadvertent whitespace change.

test/std/utilities/any/any.class/any.modifiers/swap.pass.cpp
89

ibid.

92

New test: self-swap must have no effect.

test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
71–76

Possibly controversial: I'm going to propose that template<class T> any_cast(any&&) should require that T is not an lvalue reference type, so that it cannot return potentially dangling references. That means the portion of this test that performs any_cast<T>(any&&) must be conditioned on whether or not T is an lvalue reference type.

146

This code becomes ill-formed with the above proposed change.

198

Remove unused variable ca.

306

Non-standard behavior split out into test/libcxx/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp

test/std/utilities/any/any.nonmembers/make_any.pass.cpp
102

Again, ensure that LargeThrows is large independent of the size of any.

Fix inadvertent whitespace changes.

EricWF edited edge metadata.Oct 7 2016, 2:39 PM

@CaseyCarter Thank you for the patch. I fixed most of your issues in r283606 {as well as a bunch of libc++ bugs).

I'm still deciding what to do about the in_place SFINAE tests, but I'll follow up on that shortly. As for this patch please update it if there are any fixes I missed, otherwise please close it.

test/libcxx/utilities/any/any.class/any.assign/value.pass.cpp
26

I thought this behavior was subject to a LWG PR, but I can't seem to find one.

I'll either create a LWG issue to standardize this behavior or remove the tests and fix libc++.

test/libcxx/utilities/any/any.class/any.cons/value.pass.cpp
24

I'm removing these tests all together.

test/libcxx/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
35

I'm removing these tests all together.

test/std/utilities/any/any.class/any.assign/value.pass.cpp
172

Same comment as above in regards to the in_place SFINAE tests.

test/std/utilities/any/any.class/any.cons/copy.pass.cpp
74

Ack. Fixing.

test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp
146

I'm removing these tests.

EricWF added a comment.Oct 7 2016, 4:24 PM

Addressed the issues about in_place SFINAE constraints in an inline comment.

test/libcxx/utilities/any/any.class/any.assign/value.pass.cpp
26

OK, so the ValueType ctor was constrained by http://cplusplus.github.io/LWG/lwg-active.html#2744 but that didn't touch the assignment operator. I think that's a mistake, and I'll look into adjusting the PR for 2744.

CaseyCarter abandoned this revision.Oct 10 2016, 1:39 PM

Ignoring the assignment from in_place_t issue for now, r283606 is good modulo a couple of tiny things that I'll just email you directly.