summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-16 10:51:21 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-16 10:55:54 +0200
commit76bcd284f9dddc93f975cccabae9dc4c040c5a53 (patch)
tree50f159d03b562be0d0919d61593b69b94e577f31 /AK
parent16c858d9f033d3b30bf978142e47a6bda564c618 (diff)
downloadserenity-76bcd284f9dddc93f975cccabae9dc4c040c5a53.zip
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. :/
Diffstat (limited to 'AK')
-rw-r--r--AK/NonnullOwnPtr.h17
-rw-r--r--AK/NonnullRefPtr.h23
-rw-r--r--AK/Optional.h14
-rw-r--r--AK/Platform.h13
4 files changed, 4 insertions, 63 deletions
diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h
index 5b9dc53e49..622290578a 100644
--- a/AK/NonnullOwnPtr.h
+++ b/AK/NonnullOwnPtr.h
@@ -42,25 +42,22 @@ template<typename T>
class WeakPtr;
template<typename T>
-class CONSUMABLE(unconsumed) NonnullOwnPtr {
+class NonnullOwnPtr {
public:
typedef T ElementType;
enum AdoptTag { Adopt };
- RETURN_TYPESTATE(unconsumed)
NonnullOwnPtr(AdoptTag, T& ptr)
: m_ptr(&ptr)
{
}
- RETURN_TYPESTATE(unconsumed)
NonnullOwnPtr(NonnullOwnPtr&& other)
: m_ptr(other.leak_ptr())
{
ASSERT(m_ptr);
}
template<typename U>
- RETURN_TYPESTATE(unconsumed)
NonnullOwnPtr(NonnullOwnPtr<U>&& other)
: m_ptr(other.leak_ptr())
{
@@ -97,7 +94,6 @@ public:
template<typename U>
NonnullOwnPtr& operator=(const WeakPtr<U>&) = delete;
- RETURN_TYPESTATE(unconsumed)
NonnullOwnPtr& operator=(NonnullOwnPtr&& other)
{
NonnullOwnPtr ptr(move(other));
@@ -106,7 +102,6 @@ public:
}
template<typename U>
- RETURN_TYPESTATE(unconsumed)
NonnullOwnPtr& operator=(NonnullOwnPtr<U>&& other)
{
NonnullOwnPtr ptr(move(other));
@@ -114,31 +109,21 @@ public:
return *this;
}
- CALLABLE_WHEN(unconsumed)
- SET_TYPESTATE(consumed)
T* leak_ptr()
{
return exchange(m_ptr, nullptr);
}
- CALLABLE_WHEN(unconsumed)
T* ptr() { return m_ptr; }
- CALLABLE_WHEN(unconsumed)
const T* ptr() const { return m_ptr; }
- CALLABLE_WHEN(unconsumed)
T* operator->() { return m_ptr; }
- CALLABLE_WHEN(unconsumed)
const T* operator->() const { return m_ptr; }
- CALLABLE_WHEN(unconsumed)
T& operator*() { return *m_ptr; }
- CALLABLE_WHEN(unconsumed)
const T& operator*() const { return *m_ptr; }
- CALLABLE_WHEN(unconsumed)
operator const T*() const { return m_ptr; }
- CALLABLE_WHEN(unconsumed)
operator T*() { return m_ptr; }
operator bool() const = delete;
diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h
index 3710f07534..30a33f66d4 100644
--- a/AK/NonnullRefPtr.h
+++ b/AK/NonnullRefPtr.h
@@ -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);
diff --git a/AK/Optional.h b/AK/Optional.h
index 37b4647e6b..db9ee7b014 100644
--- a/AK/Optional.h
+++ b/AK/Optional.h
@@ -34,12 +34,10 @@
namespace AK {
template<typename T>
-class CONSUMABLE(unknown) alignas(T) Optional {
+class alignas(T) Optional {
public:
- RETURN_TYPESTATE(unknown)
Optional() {}
- RETURN_TYPESTATE(unknown)
Optional(const T& value)
: m_has_value(true)
{
@@ -47,21 +45,18 @@ public:
}
template<typename U>
- RETURN_TYPESTATE(unknown)
Optional(const U& value)
: m_has_value(true)
{
new (&m_storage) T(value);
}
- RETURN_TYPESTATE(unknown)
Optional(T&& value)
: m_has_value(true)
{
new (&m_storage) T(move(value));
}
- RETURN_TYPESTATE(unknown)
Optional(Optional&& other)
: m_has_value(other.m_has_value)
{
@@ -71,7 +66,6 @@ public:
}
}
- RETURN_TYPESTATE(unknown)
Optional(const Optional& other)
: m_has_value(other.m_has_value)
{
@@ -80,7 +74,6 @@ public:
}
}
- RETURN_TYPESTATE(unknown)
Optional& operator=(const Optional& other)
{
if (this != &other) {
@@ -93,7 +86,6 @@ public:
return *this;
}
- RETURN_TYPESTATE(unknown)
Optional& operator=(Optional&& other)
{
if (this != &other) {
@@ -118,23 +110,19 @@ public:
}
}
- SET_TYPESTATE(consumed)
ALWAYS_INLINE bool has_value() const { return m_has_value; }
- CALLABLE_WHEN(consumed)
ALWAYS_INLINE T& value()
{
ASSERT(m_has_value);
return *reinterpret_cast<T*>(&m_storage);
}
- CALLABLE_WHEN(consumed)
ALWAYS_INLINE const T& value() const
{
return value_without_consume_state();
}
- CALLABLE_WHEN(consumed)
T release_value()
{
ASSERT(m_has_value);
diff --git a/AK/Platform.h b/AK/Platform.h
index df72a1cd09..b745e6a780 100644
--- a/AK/Platform.h
+++ b/AK/Platform.h
@@ -51,19 +51,6 @@
#endif
#define FLATTEN [[gnu::flatten]]
-// FIXME: Re-enable this when we can figure out why Clang gets confused about "unknown"
-#if 0
-# define CONSUMABLE(initial_state) __attribute__((consumable(initial_state)))
-# define CALLABLE_WHEN(...) __attribute__((callable_when(__VA_ARGS__)))
-# define SET_TYPESTATE(state) __attribute__((set_typestate(state)))
-# define RETURN_TYPESTATE(state) __attribute__((return_typestate(state)))
-#else
-# define CONSUMABLE(initial_state)
-# define CALLABLE_WHEN(...)
-# define SET_TYPESTATE(state)
-# define RETURN_TYPESTATE(state)
-#endif
-
#ifndef __serenity__
# define PAGE_SIZE sysconf(_SC_PAGESIZE)