[llvm] r202642 - [C++11] Replace LLVM_STATIC_ASSERT with static_assert, we now have

Chandler Carruth chandlerc at gmail.com
Sun Mar 2 05:10:46 PST 2014


Author: chandlerc
Date: Sun Mar  2 07:10:45 2014
New Revision: 202642

URL: http://llvm.org/viewvc/llvm-project?rev=202642&view=rev
Log:
[C++11] Replace LLVM_STATIC_ASSERT with static_assert, we now have
access to it on all host toolchains.

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

Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=202642&r1=202641&r2=202642&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Sun Mar  2 07:10:45 2014
@@ -333,19 +333,6 @@
 #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

Modified: llvm/trunk/lib/Support/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ThreadLocal.cpp?rev=202642&r1=202641&r2=202642&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ThreadLocal.cpp (original)
+++ llvm/trunk/lib/Support/ThreadLocal.cpp Sun Mar  2 07:10:45 2014
@@ -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);

Modified: llvm/trunk/unittests/IR/ValueMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/ValueMapTest.cpp?rev=202642&r1=202641&r2=202642&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/ValueMapTest.cpp (original)
+++ llvm/trunk/unittests/IR/ValueMapTest.cpp Sun Mar  2 07:10:45 2014
@@ -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) {





More information about the llvm-commits mailing list