[llvm] r177699 - Introduce LLVM_STATIC_ASSERT macro, which expands to C/C++'s static_assert on compilers which support it.

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Mar 21 20:10:51 PDT 2013


Author: akirtzidis
Date: Thu Mar 21 22:10:51 2013
New Revision: 177699

URL: http://llvm.org/viewvc/llvm-project?rev=177699&view=rev
Log:
Introduce LLVM_STATIC_ASSERT macro, which expands to C/C++'s static_assert on compilers which support it.

Modified:
    llvm/trunk/include/llvm/Support/Compiler.h

Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=177699&r1=177698&r2=177699&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Thu Mar 21 22:10:51 2013
@@ -351,4 +351,14 @@
 #define LLVM_EXPLICIT
 #endif
 
+/// \macro LLVM_STATIC_ASSERT
+/// \brief Expands to C/C++'s static_assert on compilers which support it.
+#if __has_feature(cxx_static_assert)
+# define LLVM_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
+#elif __has_feature(c_static_assert)
+# define LLVM_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
+#else
+# define LLVM_STATIC_ASSERT(expr, msg)
+#endif
+
 #endif





More information about the llvm-commits mailing list