Fix char_traits functions for GCC compatibility.
GCC 4.9 fails to inline these functions at -O1 because they are used indirectly. Declare them as inline instead of always_inline. Discussion in GCC bugreport: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63220 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@217961 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
01c6bbd947
commit
6d9505ad8a
156
include/string
156
include/string
@ -509,14 +509,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
@ -526,20 +523,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
@ -636,51 +628,37 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return (unsigned char)__c1 < (unsigned char)__c2;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return memcmp(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_t length(const char_type* __s) {return strlen(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
static inline size_t length(const char_type* __s) {return strlen(__s);}
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{return (const char_type*)memchr(__s, to_int_type(__a), __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return (char_type*)memmove(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return (char_type*)memcpy(__s1, __s2, __n);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
{return (char_type*)memset(__s, to_int_type(__a), __n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type((unsigned char)__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
@ -695,52 +673,38 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return wmemcmp(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_t length(const char_type* __s)
|
||||
static inline size_t length(const char_type* __s)
|
||||
{return wcslen(__s);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{return (const char_type*)wmemchr(__s, __a, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return (char_type*)wmemmove(__s1, __s2, __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return (char_type*)wmemcpy(__s1, __s2, __n);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
|
||||
{return (char_type*)wmemset(__s, __a, __n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(WEOF);}
|
||||
};
|
||||
|
||||
@ -755,14 +719,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
|
||||
typedef u16streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
@ -772,20 +733,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xDFFF);}
|
||||
};
|
||||
|
||||
@ -876,14 +832,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
|
||||
typedef u32streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
|
||||
{__c1 = __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
@ -893,20 +846,15 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xFFFFFFFF);}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user