1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

Everywhere: Fully qualify IsLvalueReference in TRY() macros

If USING_AK_GLOBALLY is not defined, the name IsLvalueReference might
not be available in the global namespace. Follow the pattern established
in LibTest to fully qualify AK types in macros to avoid this problem.
This commit is contained in:
Andrew Kaster 2023-01-14 16:34:44 -07:00 committed by Linus Groh
parent 56512caa73
commit f5d253dcfa
11 changed files with 96 additions and 95 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Diagnostics.h>
#include <AK/StdLibExtras.h>
// NOTE: This macro works with any result type that has the expected APIs.
// It's designed with AK::Result and AK::Error in mind.
@ -25,7 +26,7 @@
/* Ignore -Wshadow to allow nesting the macro. */ \
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto _temporary_result = (expression)); \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
if (_temporary_result.is_error()) [[unlikely]] \
return _temporary_result.release_error(); \
@ -37,7 +38,7 @@
/* Ignore -Wshadow to allow nesting the macro. */ \
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
auto _temporary_result = (expression)); \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
VERIFY(!_temporary_result.is_error()); \
_temporary_result.release_value(); \

View file

@ -189,7 +189,7 @@ private:
auto result = (expression); \
if (result.is_error()) \
return set_so_error(result.release_error()); \
static_assert(!IsLvalueReference<decltype(result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(result.release_value())>, \
"Do not return a reference from a fallible expression"); \
result.release_value(); \
})

View file

@ -236,7 +236,7 @@ struct CLDR {
auto _temporary_result = (expression); \
if (_temporary_result.is_error()) \
return; \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -71,7 +71,7 @@ struct LoaderError {
auto _temporary_result = (expression); \
if (_temporary_result.is_error()) \
return LoaderError(_temporary_result.release_error()); \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -25,7 +25,7 @@ namespace JS {
VERIFY(_temporary_result.error().code() == ENOMEM); \
return vm.throw_completion<JS::InternalError>(JS::ErrorType::OutOfMemory); \
} \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -53,7 +53,7 @@ private:
return (capability)->promise(); \
} \
\
static_assert(!IsLvalueReference<decltype(_temporary_try_or_reject_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_try_or_reject_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
\
/* 2. Else if value is a Completion Record, set value to value.[[Value]]. */ \
@ -79,7 +79,7 @@ private:
return Value { (capability)->promise() }; \
} \
\
static_assert(!IsLvalueReference<decltype(_temporary_try_or_reject_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_try_or_reject_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
\
/* 2. Else if value is a Completion Record, set value to value.[[Value]]. */ \

View file

@ -85,7 +85,7 @@ private:
return DecoderError::from_source_location( \
((category)), _error_string, SourceLocation::current()); \
} \
static_assert(!IsLvalueReference<decltype(_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_result.release_value(); \
})

View file

@ -273,7 +273,7 @@ bool PlaybackManager::decode_and_queue_one_sample()
m_present_timer->start(0); \
return false; \
} \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -47,7 +47,7 @@ namespace Web::Fetch::Fetching {
auto _temporary_result = (expression); \
if (_temporary_result.is_error()) \
return; \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -36,7 +36,7 @@ namespace Web::WebDriver {
auto _temporary_result = (expression); \
if (_temporary_result.is_error()) [[unlikely]] \
return ExecuteScriptResultType::JavaScriptError; \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})

View file

@ -17,7 +17,7 @@
outln("Encountered a parsing error: {}", _temporary_result.error().string_literal()); \
return Error::from_string_literal("Failed to parse :("); \
} \
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
"Do not return a reference from a fallible expression"); \
_temporary_result.release_value(); \
})