[C++11] Replace LLVM_STATIC_ASSERT with static_assert, we now have
authorChandler Carruth <chandlerc@gmail.com>
Sun, 2 Mar 2014 13:10:45 +0000 (13:10 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 2 Mar 2014 13:10:45 +0000 (13:10 +0000)
access to it on all host toolchains.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202642 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Compiler.h
lib/Support/ThreadLocal.cpp
unittests/IR/ValueMapTest.cpp

index 9ac1ce9a3572b3cb51c5df224185635bd52bf464..1edcd45bc3bb61611af925aa48878de8d10afdaf 100644 (file)
 #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) || \
-    defined(__GXX_EXPERIMENTAL_CXX0X__) || LLVM_MSC_PREREQ(1600)
-# 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)
-#elif __has_extension(c_static_assert)
-# define LLVM_STATIC_ASSERT(expr, msg) LLVM_EXTENSION _Static_assert(expr, msg)
-#else
-# define LLVM_STATIC_ASSERT(expr, msg)
-#endif
-
 /// \brief Does the compiler support generalized initializers (using braced
 /// lists and std::initializer_list).  While clang may claim it supports general
 /// initializers, if we're using MSVC's headers, we might not have a usable
index 38ab29b7ffeff4dd50848dad453144805c1ec985..aebbcad25cdac17999793afb400cf7571f634d32 100644 (file)
@@ -27,7 +27,7 @@ using namespace sys;
 ThreadLocalImpl::ThreadLocalImpl() : data() { }
 ThreadLocalImpl::~ThreadLocalImpl() { }
 void ThreadLocalImpl::setInstance(const void* d) {
-  LLVM_STATIC_ASSERT(sizeof(d) <= sizeof(data), "size too big");
+  static_assert(sizeof(d) <= sizeof(data), "size too big");
   void **pd = reinterpret_cast<void**>(&data);
   *pd = const_cast<void*>(d);
 }
@@ -51,7 +51,7 @@ namespace llvm {
 using namespace sys;
 
 ThreadLocalImpl::ThreadLocalImpl() : data() {
-  LLVM_STATIC_ASSERT(sizeof(pthread_key_t) <= sizeof(data), "size too big");
+  static_assert(sizeof(pthread_key_t) <= sizeof(data), "size too big");
   pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
   int errorcode = pthread_key_create(key, NULL);
   assert(errorcode == 0);
index 5493e3e1e39d134b81fdaaf7aee8f2fdbfefeef7..4c8a4a9372dfccdbe16173ba1d8ef7e8bf8c07c4 100644 (file)
@@ -117,8 +117,7 @@ TYPED_TEST(ValueMapTest, OperationsWork) {
 
 template<typename ExpectedType, typename VarType>
 void CompileAssertHasType(VarType) {
-  LLVM_STATIC_ASSERT((is_same<ExpectedType, VarType>::value),
-                     "Not the same type");
+  static_assert((is_same<ExpectedType, VarType>::value), "Not the same type");
 }
 
 TYPED_TEST(ValueMapTest, Iteration) {