From fab60665ebc51b1b6c132e368fee00865d4d3942 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 4 Sep 2020 11:05:52 -0400 Subject: [PATCH] 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. --- compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h index d0ffc79b0610..84973eedda60 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h @@ -333,14 +333,10 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond, #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 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 // have stdint.h (like in Visual Studio 9). #undef __INT64_C