mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
AK: Allow calling ASSERT
and VERIFY
on list-initializers
List initializers may contain commas without surrounding parenthesis, causing them to be passed as multiple macro arguments.
This commit is contained in:
parent
0de15264ab
commit
f617127772
Notes:
github-actions[bot]
2024-12-04 16:48:01 +00:00
Author: https://github.com/yyny
Commit: f617127772
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2454
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 7 additions and 7 deletions
|
@ -12,9 +12,9 @@ extern "C" __attribute__((noreturn)) void ak_trap(void);
|
||||||
extern "C" __attribute__((noreturn)) void ak_verification_failed(char const*);
|
extern "C" __attribute__((noreturn)) void ak_verification_failed(char const*);
|
||||||
#define __stringify_helper(x) #x
|
#define __stringify_helper(x) #x
|
||||||
#define __stringify(x) __stringify_helper(x)
|
#define __stringify(x) __stringify_helper(x)
|
||||||
#define VERIFY(expr) \
|
#define VERIFY(...) \
|
||||||
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(expr), 0) \
|
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(__VA_ARGS__), 0) \
|
||||||
? ak_verification_failed(#expr " at " __FILE__ ":" __stringify(__LINE__)) \
|
? ak_verification_failed(#__VA_ARGS__ " at " __FILE__ ":" __stringify(__LINE__)) \
|
||||||
: (void)0)
|
: (void)0)
|
||||||
#define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
#define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
||||||
static constexpr bool TODO = false;
|
static constexpr bool TODO = false;
|
||||||
|
@ -26,12 +26,12 @@ static constexpr bool TODO = false;
|
||||||
|
|
||||||
extern "C" __attribute__((noreturn)) void ak_assertion_failed(char const*);
|
extern "C" __attribute__((noreturn)) void ak_assertion_failed(char const*);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
# define ASSERT(expr) \
|
# define ASSERT(...) \
|
||||||
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(expr), 0) \
|
(__builtin_expect(/* NOLINT(readability-simplify-boolean-expr) */ !(__VA_ARGS__), 0) \
|
||||||
? ak_assertion_failed(#expr " at " __FILE__ ":" __stringify(__LINE__)) \
|
? ak_assertion_failed(#__VA_ARGS__ " at " __FILE__ ":" __stringify(__LINE__)) \
|
||||||
: (void)0)
|
: (void)0)
|
||||||
# define ASSERT_NOT_REACHED ASSERT(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
# define ASSERT_NOT_REACHED ASSERT(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
|
||||||
#else
|
#else
|
||||||
# define ASSERT(expr)
|
# define ASSERT(...)
|
||||||
# define ASSERT_NOT_REACHED() __builtin_unreachable()
|
# define ASSERT_NOT_REACHED() __builtin_unreachable()
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue