mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Ignore -Wshadow in TRY() and MUST()
This makes the warning in CLion disappear when nesting them.
This commit is contained in:
parent
d2e143eec7
commit
5103e08b77
Notes:
sideshowbarker
2024-07-17 03:42:31 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/5103e08b77 Pull-request: https://github.com/SerenityOS/serenity/pull/16338 Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 17 additions and 11 deletions
28
AK/Try.h
28
AK/Try.h
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Diagnostics.h>
|
||||||
|
|
||||||
// NOTE: This macro works with any result type that has the expected APIs.
|
// NOTE: This macro works with any result type that has the expected APIs.
|
||||||
// It's designed with AK::Result and AK::Error in mind.
|
// It's designed with AK::Result and AK::Error in mind.
|
||||||
//
|
//
|
||||||
|
@ -14,17 +16,21 @@
|
||||||
// by at least clang and gcc.
|
// by at least clang and gcc.
|
||||||
// [1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
|
// [1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
|
||||||
|
|
||||||
#define TRY(expression) \
|
#define TRY(expression) \
|
||||||
({ \
|
({ \
|
||||||
auto _temporary_result = (expression); \
|
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||||
if (_temporary_result.is_error()) [[unlikely]] \
|
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||||
return _temporary_result.release_error(); \
|
auto _temporary_result = (expression)); \
|
||||||
_temporary_result.release_value(); \
|
if (_temporary_result.is_error()) [[unlikely]] \
|
||||||
|
return _temporary_result.release_error(); \
|
||||||
|
_temporary_result.release_value(); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define MUST(expression) \
|
#define MUST(expression) \
|
||||||
({ \
|
({ \
|
||||||
auto _temporary_result = (expression); \
|
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||||
VERIFY(!_temporary_result.is_error()); \
|
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||||
_temporary_result.release_value(); \
|
auto _temporary_result = (expression)); \
|
||||||
|
VERIFY(!_temporary_result.is_error()); \
|
||||||
|
_temporary_result.release_value(); \
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue