|
8 | 8 |
|
9 | 9 | #if __cplusplus < 202000L
|
10 | 10 | #error "The Antithesis C++ API requires C++20 or higher"
|
11 |
| - #ifndef NO_ANTITHESIS_SDK |
12 |
| - #define NO_ANTITHESIS_SDK |
13 |
| - #endif |
| 11 | + #define NO_ANTITHESIS_SDK |
14 | 12 | #endif
|
15 | 13 |
|
16 | 14 | #if !defined(__clang__)
|
17 | 15 | #error "The Antithesis C++ API requires a clang compiler"
|
18 |
| - #ifndef NO_ANTITHESIS_SDK |
19 |
| - #define NO_ANTITHESIS_SDK |
20 |
| - #endif |
| 16 | + #define NO_ANTITHESIS_SDK |
21 | 17 | #endif
|
22 | 18 |
|
23 | 19 | #if __clang_major__ < 16
|
24 | 20 | #error "The Antithesis C++ API requires clang version 16 or higher"
|
25 |
| - #ifndef NO_ANTITHESIS_SDK |
26 |
| - #define NO_ANTITHESIS_SDK |
27 |
| - #endif |
| 21 | + #define NO_ANTITHESIS_SDK |
28 | 22 | #endif
|
29 | 23 |
|
30 | 24 | #else
|
@@ -879,21 +873,57 @@ namespace { // Anonymous namespace which is translation-unit-specific; certain s
|
879 | 873 |
|
880 | 874 | #ifdef NO_ANTITHESIS_SDK
|
881 | 875 |
|
882 |
| -#define ALWAYS(cond, message, ...) |
883 |
| -#define ALWAYS_OR_UNREACHABLE(cond, message, ...) |
884 |
| -#define SOMETIMES(cond, message, ...) |
885 |
| -#define REACHABLE(message, ...) |
886 |
| -#define UNREACHABLE(message, ...) |
887 |
| -#define ALWAYS_GREATER_THAN(val, threshold, message, ...) |
888 |
| -#define ALWAYS_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) |
889 |
| -#define SOMETIMES_GREATER_THAN(val, threshold, message, ...) |
890 |
| -#define SOMETIMES_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) |
891 |
| -#define ALWAYS_LESS_THAN(val, threshold, message, ...) |
892 |
| -#define ALWAYS_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) |
893 |
| -#define SOMETIMES_LESS_THAN(val, threshold, message, ...) |
894 |
| -#define SOMETIMES_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) |
895 |
| -#define ALWAYS_SOME(pairs, message, ...) |
896 |
| -#define SOMETIMES_ALL(pairs, message, ...) |
| 876 | +#ifndef ANTITHESIS_SDK_ALWAYS_POLYFILL |
| 877 | + #define ANTITHESIS_SDK_ALWAYS_POLYFILL(...) |
| 878 | +#endif |
| 879 | + |
| 880 | +#ifndef ANTITHESIS_SDK_SOMETIMES_POLYFILL |
| 881 | + #define ANTITHESIS_SDK_SOMETIMES_POLYFILL(...) |
| 882 | +#endif |
| 883 | + |
| 884 | +#ifndef ANTITHESIS_SDK_ALWAYS_OR_UNREACHABLE_POLYFILL |
| 885 | + #define ANTITHESIS_SDK_ALWAYS_OR_UNREACHABLE_POLYFILL(...) \ |
| 886 | + ANTITHESIS_SDK_ALWAYS_POLYFILL(__VA_ARGS__) |
| 887 | +#endif |
| 888 | + |
| 889 | +#define ALWAYS(cond, message, ...) \ |
| 890 | + ANTITHESIS_SDK_ALWAYS_POLYFILL(cond, message, __VA_ARGS__) |
| 891 | +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) \ |
| 892 | + ANTITHESIS_SDK_ALWAYS_OR_UNREACHABLE_POLYFILL(cond, message, __VA_ARGS__) |
| 893 | +#define SOMETIMES(cond, message, ...) \ |
| 894 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL(cond, message, __VA_ARGS__) |
| 895 | +#define REACHABLE(message, ...) \ |
| 896 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL(true, message, __VA_ARGS__) |
| 897 | +#define UNREACHABLE(message, ...) \ |
| 898 | + ANTITHESIS_SDK_ALWAYS_POLYFILL(false, message, __VA_ARGS__) |
| 899 | +#define ALWAYS_GREATER_THAN(val, threshold, message, ...) \ |
| 900 | + ANTITHESIS_SDK_ALWAYS_POLYFILL((val > threshold), message, __VA_ARGS__) |
| 901 | +#define ALWAYS_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) \ |
| 902 | + ANTITHESIS_SDK_ALWAYS_POLYFILL((val >= threshold), message, __VA_ARGS__) |
| 903 | +#define SOMETIMES_GREATER_THAN(val, threshold, message, ...) \ |
| 904 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL((val > threshold), message, __VA_ARGS__) |
| 905 | +#define SOMETIMES_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) \ |
| 906 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL((val >= threshold), message, __VA_ARGS__) |
| 907 | +#define ALWAYS_LESS_THAN(val, threshold, message, ...) \ |
| 908 | + ANTITHESIS_SDK_ALWAYS_POLYFILL((val < threshold), message, __VA_ARGS__) |
| 909 | +#define ALWAYS_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) \ |
| 910 | + ANTITHESIS_SDK_ALWAYS_POLYFILL((val <= threshold), message, __VA_ARGS__) |
| 911 | +#define SOMETIMES_LESS_THAN(val, threshold, message, ...) \ |
| 912 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL((val < threshold), message, __VA_ARGS__) |
| 913 | +#define SOMETIMES_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) \ |
| 914 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL((val <= threshold), message, __VA_ARGS__) |
| 915 | +#define ALWAYS_SOME(pairs, message, ...) \ |
| 916 | + ANTITHESIS_SDK_ALWAYS_POLYFILL(([&](){ \ |
| 917 | + std::initializer_list<std::pair<std::string, bool>> ps = pairs; \ |
| 918 | + for (auto const& pair : ps) \ |
| 919 | + if (pair.second) return true; \ |
| 920 | + return false; }()), message, __VA_ARGS__) |
| 921 | +#define SOMETIMES_ALL(pairs, message, ...) \ |
| 922 | + ANTITHESIS_SDK_SOMETIMES_POLYFILL(([&](){ \ |
| 923 | + std::initializer_list<std::pair<std::string, bool>> ps = pairs; \ |
| 924 | + for (auto const& pair : ps) \ |
| 925 | + if (!pair.second) return false; \ |
| 926 | + return true; }()), message, __VA_ARGS__) |
897 | 927 |
|
898 | 928 | #else
|
899 | 929 |
|
|
0 commit comments