Changeset 242778 in webkit
- Timestamp:
- Mar 11, 2019, 11:04:22 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/Expected.h (modified) (6 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/Expected.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r242776 r242778 1 2019-03-11 Alex Christensen <achristensen@webkit.org> 2 3 WTF::Expected should use std::addressof instead of operator& 4 https://bugs.webkit.org/show_bug.cgi?id=195604 5 6 Reviewed by Myles Maxfield. 7 8 The latter was causing problems with types that do tricky things with constructors and operator&, 9 specifically UniqueRef but I made a reduced test case. When it used operator&, it would get the contained 10 type and call the constructor that takes a contained type instead of the move constructor. 11 12 * wtf/Expected.h: 13 (std::experimental::fundamentals_v3::__expected_detail::base::base): 14 (std::experimental::fundamentals_v3::expected::swap): 15 1 16 2019-03-11 Ross Kirsling <ross.kirsling@sony.com> 2 17 -
trunk/Source/WTF/wtf/Expected.h
r242776 r242778 335 335 { 336 336 if (has) 337 ::new ( &s.val) value_type(o.s.val);337 ::new (std::addressof(s.val)) value_type(o.s.val); 338 338 else 339 ::new ( &s.err) error_type(o.s.err);339 ::new (std::addressof(s.err)) error_type(o.s.err); 340 340 } 341 341 base(base&& o) … … 343 343 { 344 344 if (has) 345 ::new ( &s.val) value_type(std::move(o.s.val));345 ::new (std::addressof(s.val)) value_type(std::move(o.s.val)); 346 346 else 347 ::new ( &s.err) error_type(std::move(o.s.err));347 ::new (std::addressof(s.err)) error_type(std::move(o.s.err)); 348 348 } 349 349 ~base() … … 387 387 { 388 388 if (!has) 389 ::new ( &s.err) error_type(o.s.err);389 ::new (std::addressof(s.err)) error_type(o.s.err); 390 390 } 391 391 base(base&& o) … … 393 393 { 394 394 if (!has) 395 ::new ( &s.err) error_type(std::move(o.s.err));395 ::new (std::addressof(s.err)) error_type(std::move(o.s.err)); 396 396 } 397 397 ~base() … … 462 462 error_type e(std::move(o.s.err)); 463 463 __expected_detail::destroy(o.s.err); 464 ::new ( &o.s.val) value_type(std::move(base::s.val));464 ::new (std::addressof(o.s.val)) value_type(std::move(base::s.val)); 465 465 __expected_detail::destroy(base::s.val); 466 ::new ( &base::s.err) error_type(std::move(e));466 ::new (std::addressof(base::s.err)) error_type(std::move(e)); 467 467 swap(base::has, o.has); 468 468 } else if (!base::has && o.has) { 469 469 value_type v(std::move(o.s.val)); 470 470 __expected_detail::destroy(o.s.val); 471 ::new ( &o.s.err) error_type(std::move(base::s.err));471 ::new (std::addressof(o.s.err)) error_type(std::move(base::s.err)); 472 472 __expected_detail::destroy(base::s.err); 473 ::new ( &base::s.val) value_type(std::move(v));473 ::new (std::addressof(base::s.val)) value_type(std::move(v)); 474 474 swap(base::has, o.has); 475 475 } else … … 537 537 } else if (base::has && !o.has) { 538 538 error_type e(std::move(o.s.err)); 539 ::new ( &base::s.err) error_type(e);539 ::new (std::addressof(base::s.err)) error_type(e); 540 540 swap(base::has, o.has); 541 541 } else if (!base::has && o.has) { 542 ::new ( &o.s.err) error_type(std::move(base::s.err));542 ::new (std::addressof(o.s.err)) error_type(std::move(base::s.err)); 543 543 swap(base::has, o.has); 544 544 } else -
trunk/Tools/ChangeLog
r242776 r242778 1 2019-03-11 Alex Christensen <achristensen@webkit.org> 2 3 WTF::Expected should use std::addressof instead of operator& 4 https://bugs.webkit.org/show_bug.cgi?id=195604 5 6 Reviewed by Myles Maxfield. 7 8 * TestWebKitAPI/Tests/WTF/Expected.cpp: 9 (TestWebKitAPI::Unique::Unique): 10 (TestWebKitAPI::Unique::operator&): 11 (TestWebKitAPI::TEST): 12 1 13 2019-03-11 Ross Kirsling <ross.kirsling@sony.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WTF/Expected.cpp
r225499 r242778 473 473 } 474 474 475 class NeedsStdAddress { 476 public: 477 NeedsStdAddress(NeedsStdAddress&& other) 478 : m_ptr(WTFMove(other.m_ptr)) { } 479 NeedsStdAddress(int& other) 480 : m_ptr(&other) { } 481 int* operator&() { ASSERT_NOT_REACHED(); return nullptr; } 482 private: 483 std::unique_ptr<int> m_ptr; 484 }; 485 486 TEST(WTF_Expected, Address) 487 { 488 NeedsStdAddress a(*new int(3)); 489 Expected<NeedsStdAddress, float> b(WTFMove(a)); 490 Expected<NeedsStdAddress, float> c(WTFMove(b)); 491 (void)c; 492 } 493 475 494 } // namespace TestWebkitAPI
Note:
See TracChangeset
for help on using the changeset viewer.