[compiler-rt] fab6066 - sanitizer_common: Implement COMPILER_CHECK using static_assert

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 08:07:46 PDT 2020


Author: Nico Weber
Date: 2020-09-04T11:05:54-04:00
New Revision: fab60665ebc51b1b6c132e368fee00865d4d3942

URL: https://github.com/llvm/llvm-project/commit/fab60665ebc51b1b6c132e368fee00865d4d3942
DIFF: https://github.com/llvm/llvm-project/commit/fab60665ebc51b1b6c132e368fee00865d4d3942.diff

LOG: 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.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Removed: 
    


################################################################################
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


        


More information about the llvm-commits mailing list