-
Notifications
You must be signed in to change notification settings - Fork 139
/
Assert.h
38 lines (33 loc) · 1.32 KB
/
Assert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <Debug.h>
// Uncomment the following line to enable expensive assertions.
// #define MT_ENABLE_EXPENSIVE_ASSERT
#define mt_assert(condition) always_assert(condition)
#define mt_assert_log(condition, message, ...) \
always_assert_log(condition, message, ##__VA_ARGS__)
#define mt_unreachable() \
do { \
always_assert(false); \
__builtin_unreachable(); \
} while (true)
#define mt_unreachable_log(message, ...) \
do { \
always_assert_log(false, message, ##__VA_ARGS__); \
__builtin_unreachable(); \
} while (true)
#ifdef MT_ENABLE_EXPENSIVE_ASSERT
#define mt_expensive_assert(condition) always_assert(condition)
#define mt_expensive_assert_log(condition, message, ...) \
always_assert_log(condition, message, ##__VA_ARGS__)
#define mt_if_expensive_assert(statement) statement
#else
#define mt_expensive_assert(condition) static_cast<void>(0)
#define mt_expensive_assert_log(condition, message, ...) static_cast<void>(0)
#define mt_if_expensive_assert(statement) static_cast<void>(0)
#endif