AK: Allow NonnullRefPtr::ptr() when in "unknown" typestate.

Clang loses the typestate when passing NonnullRefPtr's via lambda captures.
This is unfortunate, but not much we can do about it. Allowing ptr() makes
it possible to use captured NonnullRefPtrs as you'd expect.
This commit is contained in:
Andreas Kling 2019-07-25 11:51:24 +02:00
parent f46a1377ac
commit afc638c3ab
Notes: sideshowbarker 2024-07-19 13:03:54 +09:00
2 changed files with 7 additions and 3 deletions

View file

@ -148,13 +148,13 @@ public:
return *leakedPtr;
}
CALLABLE_WHEN(unconsumed)
CALLABLE_WHEN("unconsumed","unknown")
T* ptr()
{
ASSERT(m_ptr);
return m_ptr;
}
CALLABLE_WHEN(unconsumed)
CALLABLE_WHEN("unconsumed","unknown")
const T* ptr() const
{
ASSERT(m_ptr);

View file

@ -17,7 +17,11 @@
# define RETURN_TYPESTATE(state) __attribute__((return_typestate(state)))
#else
# define CONSUMABLE(initial_state)
# define CALLABLE_WHEN(state)
# define CALLABLE_WHEN(...)
# define SET_TYPESTATE(state)
# define RETURN_TYPESTATE(state)
#endif
#ifndef __serenity__
#define PAGE_SIZE sysconf(_SC_PAGESIZE)
#endif