[cfe-commits] [libcxx] r110724 - in /libcxx/trunk: include/__config include/cmath include/cstddef include/iterator include/memory include/string include/thread include/type_traits include/utility test/language.support/support.types/nullptr_t.pass.cpp
Howard Hinnant
hhinnant at apple.com
Tue Aug 10 13:48:29 PDT 2010
Author: hhinnant
Date: Tue Aug 10 15:48:29 2010
New Revision: 110724
URL: http://llvm.org/viewvc/llvm-project?rev=110724&view=rev
Log:
patch by Jesse Towner, and bug fix by Sebastian Redl
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/cmath
libcxx/trunk/include/cstddef
libcxx/trunk/include/iterator
libcxx/trunk/include/memory
libcxx/trunk/include/string
libcxx/trunk/include/thread
libcxx/trunk/include/type_traits
libcxx/trunk/include/utility
libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp
Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Aug 10 15:48:29 2010
@@ -73,31 +73,100 @@
#define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
-#define _LIBCPP_MOVE
+#if defined(__clang__)
+
+#if !(__has_feature(cxx_exceptions))
+#define _LIBCPP_NO_EXCEPTIONS
#endif
-#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#define _LIBCPP_HAS_NO_STRONG_USING
+#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+
+#define _LIBCPP_HAS_NO_DECLTYPE
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_STATIC_ASSERT
+#define _LIBCPP_HAS_NO_UNICODE_CHARS
+#define _LIBCPP_HAS_NO_VARIADICS
+
+#else
+
+#if __has_feature(cxx_rvalue_references)
+#define _LIBCPP_MOVE
#endif
+#if !(__has_feature(cxx_decltype))
+#define _LIBCPP_HAS_NO_DECLTYPE
+#endif
+
+#if !(__has_feature(cxx_deleted_functions))
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#endif
+
+#if !(__has_feature(cxx_nullptr))
#define _LIBCPP_HAS_NO_NULLPTR
+#endif
-#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
+#if !(__has_feature(cxx_static_assert))
+#define _LIBCPP_HAS_NO_STATIC_ASSERT
+#endif
+
+#if !(__has_feature(cxx_variadic_templates))
#define _LIBCPP_HAS_NO_VARIADICS
+#endif
+
+#endif
+
+#elif defined(__GNUC__)
+
+#if !__EXCEPTIONS
+#define _LIBCPP_NO_EXCEPTIONS
+#endif
+
+#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DECLTYPE
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_NULLPTR
+#define _LIBCPP_HAS_NO_STATIC_ASSERT
+#define _LIBCPP_HAS_NO_UNICODE_CHARS
+#define _LIBCPP_HAS_NO_VARIADICS
+
+#else
+
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
+#define _LIBCPP_MOVE
+#endif
+
+#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
+#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#define _LIBCPP_HAS_NO_DECLTYPE
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_UNICODE_CHARS
+#define _LIBCPP_HAS_NO_VARIADICS
#endif
-#if defined(__clang__)
-#define _LIBCPP_HAS_NO_STRONG_USING
+#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6)
+#define _LIBCPP_HAS_NO_NULLPTR
#endif
-#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#endif
+
+#endif
#ifdef _LIBCPP_HAS_NO_STRONG_USING
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
@@ -106,6 +175,7 @@
#else
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
#define _LIBCPP_END_NAMESPACE_STD } }
+#define _STD std::_LIBCPP_NAMESPACE
namespace std {
namespace _LIBCPP_NAMESPACE {
@@ -113,12 +183,11 @@
using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
}
-#define _STD std::_LIBCPP_NAMESPACE
#endif
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
- typedef unsigned short char16_t;
- typedef unsigned int char32_t;
+typedef unsigned short char16_t;
+typedef unsigned int char32_t;
#endif
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
@@ -133,13 +202,7 @@
#endif
#ifdef _LIBCPP_HAS_NO_DECLTYPE
-
#define decltype(x) __typeof__(x)
-
-#endif
-
-#if !__EXCEPTIONS
-#define _LIBCPP_NO_EXCEPTIONS
#endif
#endif // _LIBCPP_CONFIG
Modified: libcxx/trunk/include/cmath
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Tue Aug 10 15:48:29 2010
@@ -297,6 +297,12 @@
*/
+// FIXME: work around for Clang with -std=C++0x on OSX/iOS
+#if defined(__clang__) && defined(__APPLE__)
+# pragma push_macro("__STRICT_ANSI__")
+# undef __STRICT_ANSI__
+#endif
+
#include <__config>
#include <math.h>
#include <type_traits>
@@ -1641,4 +1647,9 @@
_LIBCPP_END_NAMESPACE_STD
+// FIXME: work around for Clang with -std=C++0x on OSX/iOS
+#if defined(__clang__) && defined(__APPLE__)
+# pragma pop_macro("__STRICT_ANSI__")
+#endif
+
#endif // _LIBCPP_CMATH
Modified: libcxx/trunk/include/cstddef
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Tue Aug 10 15:48:29 2010
@@ -78,6 +78,42 @@
friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;}
+
+ template <typename _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, _Tp* __p) {return 0 == __p;}
+
+ template <typename _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator==(_Tp* __p, nullptr_t) {return __p == 0;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, _Tp* __p) {return 0 != __p;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator!=(_Tp* __p, nullptr_t) {return __p != 0;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, _Tp* __p) {return 0 < __p;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator<(_Tp* __p, nullptr_t) {return __p < 0;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, _Tp* __p) {return 0 <= __p;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator<=(_Tp* __p, nullptr_t) {return __p <= 0;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, _Tp* __p) {return 0 > __p;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator>(_Tp* __p, nullptr_t) {return __p > 0;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, _Tp* __p) {return 0 >= __p;}
+
+ template <class _Tp>
+ friend _LIBCPP_ALWAYS_INLINE bool operator>=(_Tp* __p, nullptr_t) {return __p >= 0;}
};
inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}
Modified: libcxx/trunk/include/iterator
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Tue Aug 10 15:48:29 2010
@@ -1615,7 +1615,7 @@
#endif // _LIBCPP_DEBUG
-#ifdef _LIBCPP_MOVE
+#if defined(_LIBCPP_MOVE) && !defined(_LIBCPP_HAS_NO_DECLTYPE)
template <class _C>
inline
Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Aug 10 15:48:29 2010
@@ -1129,7 +1129,7 @@
{
};
-#ifdef _LIBCPP_MOVE
+#if defined(_LIBCPP_MOVE) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)
// uses-allocator construction
Modified: libcxx/trunk/include/string
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Tue Aug 10 15:48:29 2010
@@ -1259,8 +1259,6 @@
_LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const {return __r_.second();}
_LIBCPP_INLINE_VISIBILITY bool __is_long() const {return bool(__r_.first().__s.__size_ & __short_mask);}
- _LIBCPP_INLINE_VISIBILITY void __set_long() {__r_.first().__s.__size_ &= __short_mask;}
- _LIBCPP_INLINE_VISIBILITY void __set_short() {__r_.first().__s.__size_ |= ~__short_mask;}
_LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s)
#if _LIBCPP_BIG_ENDIAN
Modified: libcxx/trunk/include/thread
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Tue Aug 10 15:48:29 2010
@@ -178,9 +178,12 @@
{
pthread_t __t_;
-#ifndef _LIBCPP_MOVE
- thread(const thread&); // = delete;
- thread& operator=(const thread&); // = delete;
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+ thread(const thread&) = delete;
+ thread& operator=(const thread&) = delete;
+#else
+ thread(const thread&);
+ thread& operator=(const thread&);
#endif
public:
typedef __thread_id id;
@@ -201,9 +204,7 @@
~thread();
#ifdef _LIBCPP_MOVE
- thread(const thread&) = delete;
thread(thread&& __t) : __t_(__t.__t_) {__t.__t_ = 0;}
- thread& operator=(const thread&) = delete;
thread& operator=(thread&& __t);
#endif
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Aug 10 15:48:29 2010
@@ -1093,10 +1093,10 @@
#else
static _Tp __t();
static _Up __u();
- static bool __f();
#endif
+ static bool __f();
public:
- typedef __typeof__(__f() ? __t() : __u()) type;
+ typedef decltype(__f() ? __t() : __u()) type;
};
#else
@@ -1135,7 +1135,10 @@
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename remove_reference<_Tp>::type&&
-move(_Tp&& __t) {return __t;}
+move(_Tp&& __t)
+{
+ return static_cast<typename remove_reference<_Tp>::type&&>(__t);
+}
template <class _Tp, class _Up,
class = typename _STD::enable_if<
@@ -1148,8 +1151,7 @@
_Tp&&
forward(_Up&& __t)
{
- return __t; // to quiet spurious warning
-// return static_cast<_Tp&&>(__t);
+ return static_cast<_Tp&&>(__t);
}
#else // _LIBCPP_MOVE
Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Aug 10 15:48:29 2010
@@ -223,6 +223,8 @@
second(_STD::forward<_U2>(__u2))
{}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -233,7 +235,6 @@
typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))
{}
-#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args)
@@ -241,7 +242,6 @@
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type())
{}
-#endif
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
@@ -256,6 +256,8 @@
return *this;
}
+#endif
+
#else
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p)
Modified: libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp?rev=110724&r1=110723&r2=110724&view=diff
==============================================================================
--- libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp (original)
+++ libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp Tue Aug 10 15:48:29 2010
@@ -24,9 +24,10 @@
"sizeof(std::nullptr_t) == sizeof(void*)");
A* p = 0;
assert(p == nullptr);
+ assert(nullptr == p);
+#if !((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5))
+ // GCC 4.2 through 4.5 can't handle this
void (A::*pmf)() = 0;
-#ifdef __clang__
- // GCC 4.2 can't handle this
assert(pmf == nullptr);
#endif
int A::*pmd = 0;
@@ -41,4 +42,20 @@
assert(!(nullptr != nullptr));
assert(!(nullptr < nullptr));
assert(!(nullptr > nullptr));
+ assert(!(&a1 == nullptr));
+ assert(!(nullptr == &a1));
+ assert(&a1 != nullptr);
+ assert(nullptr != &a1);
+ assert(nullptr < &a1);
+ assert(nullptr <= &a1);
+ assert(!(nullptr < p));
+ assert(nullptr <= p);
+ assert(!(&a1 < nullptr));
+ assert(!(&a1 <= nullptr));
+ assert(!(p < nullptr));
+ assert(p <= nullptr);
+ assert(!(nullptr > &a1));
+ assert(!(nullptr >= &a1));
+ assert(!(nullptr > p));
+ assert(nullptr >= p);
}
More information about the cfe-commits
mailing list