sanitizer_common: Implement COMPILER_CHECK using static_assert

Since this is an internal header, we can just assume static_assert
exists.

If this doesn't upset any bots, I'll replace all uses of
COMPILER_CHECK in a follow-up.
This commit is contained in:
Nico Weber 2020-09-04 11:05:52 -04:00
parent dbf04aaade
commit fab60665eb
1 changed files with 1 additions and 5 deletions

View File

@ -333,14 +333,10 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
#define UNIMPLEMENTED() UNREACHABLE("unimplemented") #define UNIMPLEMENTED() UNREACHABLE("unimplemented")
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__) #define COMPILER_CHECK(pred) static_assert(pred, "")
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
#define IMPL_PASTE(a, b) a##b
#define IMPL_COMPILER_ASSERT(pred, line) \
typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
// Limits for integral types. We have to redefine it in case we don't // Limits for integral types. We have to redefine it in case we don't
// have stdint.h (like in Visual Studio 9). // have stdint.h (like in Visual Studio 9).
#undef __INT64_C #undef __INT64_C