mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
AK: Remove experimental clang -Wconsumed stuff
This stopped working quite some time ago due to Clang losing track of typestates for some reason and everything becoming "unknown". Since we're primarily using GCC anyway, it doesn't seem worth it to try and maintain this non-working experiment for a secondary compiler. Also it doesn't look like the Clang team is actively maintaining this flag anyway. So good-bye, -Wconsumed. :/
This commit is contained in:
parent
16c858d9f0
commit
76bcd284f9
5 changed files with 5 additions and 66 deletions
|
@ -53,49 +53,42 @@ inline void unref_if_not_null(T* ptr)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
class CONSUMABLE(unconsumed) NonnullRefPtr {
|
||||
class NonnullRefPtr {
|
||||
public:
|
||||
typedef T ElementType;
|
||||
|
||||
enum AdoptTag { Adopt };
|
||||
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(const T& object)
|
||||
: m_ptr(const_cast<T*>(&object))
|
||||
{
|
||||
m_ptr->ref();
|
||||
}
|
||||
template<typename U>
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(const U& object)
|
||||
: m_ptr(&const_cast<U&>(object))
|
||||
{
|
||||
m_ptr->ref();
|
||||
}
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(AdoptTag, T& object)
|
||||
: m_ptr(&object)
|
||||
{
|
||||
}
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(NonnullRefPtr&& other)
|
||||
: m_ptr(&other.leak_ref())
|
||||
{
|
||||
}
|
||||
template<typename U>
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(NonnullRefPtr<U>&& other)
|
||||
: m_ptr(&other.leak_ref())
|
||||
{
|
||||
}
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(const NonnullRefPtr& other)
|
||||
: m_ptr(const_cast<T*>(other.ptr()))
|
||||
{
|
||||
m_ptr->ref();
|
||||
}
|
||||
template<typename U>
|
||||
RETURN_TYPESTATE(unconsumed)
|
||||
NonnullRefPtr(const NonnullRefPtr<U>& other)
|
||||
: m_ptr(const_cast<U*>(other.ptr()))
|
||||
{
|
||||
|
@ -162,73 +155,61 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] CALLABLE_WHEN(unconsumed)
|
||||
SET_TYPESTATE(consumed)
|
||||
T& leak_ref()
|
||||
[[nodiscard]] T& leak_ref()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *exchange(m_ptr, nullptr);
|
||||
}
|
||||
|
||||
CALLABLE_WHEN("unconsumed", "unknown")
|
||||
T* ptr()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
CALLABLE_WHEN("unconsumed", "unknown")
|
||||
const T* ptr() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
T* operator->()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
const T* operator->() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
T& operator*()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
const T& operator*() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
operator T*()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
operator const T*() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
operator T&()
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
return *m_ptr;
|
||||
}
|
||||
CALLABLE_WHEN(unconsumed)
|
||||
operator const T&() const
|
||||
{
|
||||
ASSERT(m_ptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue