Add WTF::PoisonedUniquePtr to replace std::unique_ptr when poisoning is desired.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Dec 2017 23:05:11 +0000 (23:05 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Dec 2017 23:05:11 +0000 (23:05 +0000)
commit9aa5f2d2b79ad47cbc3e23da96819b73a5415ee2
treeb806b5edd1834896364bf289fae919d763f06338
parent618fd6bd7ace2ed0179801e06b8b6a9ffc45fecb
Add WTF::PoisonedUniquePtr to replace std::unique_ptr when poisoning is desired.
https://bugs.webkit.org/show_bug.cgi?id=181062
<rdar://problem/36167040>

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* runtime/JSCPoisonedPtr.cpp:
- Added a needed #include.

Source/WTF:

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/PointerAsserts.cpp: Copied from Source/WTF/wtf/RefPtr.cpp.
- renamed file because we asserts all kinds of pointers in here, not just RefPtr.

* wtf/Poisoned.h:
- added a missing #include.
- make constexpr poison values more scrambled.
(WTF::makePoison):

* wtf/PoisonedUniquePtr.h: Added.
(WTF::PoisonedUniquePtr::PoisonedUniquePtr):
(WTF::PoisonedUniquePtr::~PoisonedUniquePtr):
(WTF::PoisonedUniquePtr::create):
(WTF::PoisonedUniquePtr::operator=):
(WTF::PoisonedUniquePtr::get const):
(WTF::PoisonedUniquePtr::operator[] const):
(WTF::PoisonedUniquePtr::clear):
(WTF::PoisonedUniquePtr::destroy):
(WTF::PoisonedUniquePtr::clearWithoutDestroy):
(WTF::makePoisonedUnique):
* wtf/RefPtr.cpp: Removed.

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:

* TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp:
- Removed an unneeded #include.

* TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp: Added.
(TestWebKitAPI::TEST):
(TestWebKitAPI::poisonedPtrFoo):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp: Added.
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp: Added.
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226247 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSCPoisonedPtr.cpp
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/PointerAsserts.cpp [moved from Source/WTF/wtf/RefPtr.cpp with 82% similarity]
Source/WTF/wtf/Poisoned.h
Source/WTF/wtf/PoisonedUniquePtr.h [new file with mode: 0644]
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp [new file with mode: 0644]