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:
Dan Albert 2014-09-17 16:34:29 +00:00
parent 01c6bbd947
commit 6d9505ad8a

View File

@ -509,14 +509,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
typedef streampos pos_type; typedef streampos pos_type;
typedef mbstate_t state_type; typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
{__c1 = __c2;} {__c1 = __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;} {return __c1 < __c2;}
static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 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* copy(char_type* __s1, const char_type* __s2, size_t __n);
static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type* assign(char_type* __s, size_t __n, char_type __a);
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;} {return eq_int_type(__c, eof()) ? ~eof() : __c;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);} {return char_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);} {return int_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(EOF);} {return int_type(EOF);}
}; };
@ -636,51 +628,37 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
typedef streampos pos_type; typedef streampos pos_type;
typedef mbstate_t state_type; typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
{__c1 = __c2;} {__c1 = __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return (unsigned char)__c1 < (unsigned char)__c2;} {return (unsigned char)__c1 < (unsigned char)__c2;}
_LIBCPP_INLINE_VISIBILITY static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
{return memcmp(__s1, __s2, __n);} {return memcmp(__s1, __s2, __n);}
_LIBCPP_INLINE_VISIBILITY static inline size_t length(const char_type* __s) {return strlen(__s);}
static 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)
_LIBCPP_INLINE_VISIBILITY
static 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);} {return (const char_type*)memchr(__s, to_int_type(__a), __n);}
_LIBCPP_INLINE_VISIBILITY static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
{return (char_type*)memmove(__s1, __s2, __n);} {return (char_type*)memmove(__s1, __s2, __n);}
_LIBCPP_INLINE_VISIBILITY static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
static 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"); _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return (char_type*)memcpy(__s1, __s2, __n); return (char_type*)memcpy(__s1, __s2, __n);
} }
_LIBCPP_INLINE_VISIBILITY static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
static char_type* assign(char_type* __s, size_t __n, char_type __a)
{return (char_type*)memset(__s, to_int_type(__a), __n);} {return (char_type*)memset(__s, to_int_type(__a), __n);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;} {return eq_int_type(__c, eof()) ? ~eof() : __c;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);} {return char_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type((unsigned char)__c);} {return int_type((unsigned char)__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(EOF);} {return int_type(EOF);}
}; };
@ -695,52 +673,38 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
typedef streampos pos_type; typedef streampos pos_type;
typedef mbstate_t state_type; typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
{__c1 = __c2;} {__c1 = __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;} {return __c1 < __c2;}
_LIBCPP_INLINE_VISIBILITY static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
{return wmemcmp(__s1, __s2, __n);} {return wmemcmp(__s1, __s2, __n);}
_LIBCPP_INLINE_VISIBILITY static inline size_t length(const char_type* __s)
static size_t length(const char_type* __s)
{return wcslen(__s);} {return wcslen(__s);}
_LIBCPP_INLINE_VISIBILITY static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
{return (const char_type*)wmemchr(__s, __a, __n);} {return (const char_type*)wmemchr(__s, __a, __n);}
_LIBCPP_INLINE_VISIBILITY static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
{return (char_type*)wmemmove(__s1, __s2, __n);} {return (char_type*)wmemmove(__s1, __s2, __n);}
_LIBCPP_INLINE_VISIBILITY static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
static 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"); _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return (char_type*)wmemcpy(__s1, __s2, __n); return (char_type*)wmemcpy(__s1, __s2, __n);
} }
_LIBCPP_INLINE_VISIBILITY static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
static char_type* assign(char_type* __s, size_t __n, char_type __a)
{return (char_type*)wmemset(__s, __a, __n);} {return (char_type*)wmemset(__s, __a, __n);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;} {return eq_int_type(__c, eof()) ? ~eof() : __c;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);} {return char_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);} {return int_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(WEOF);} {return int_type(WEOF);}
}; };
@ -755,14 +719,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
typedef u16streampos pos_type; typedef u16streampos pos_type;
typedef mbstate_t state_type; typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
{__c1 = __c2;} {__c1 = __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;} {return __c1 < __c2;}
static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 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* copy(char_type* __s1, const char_type* __s2, size_t __n);
static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type* assign(char_type* __s, size_t __n, char_type __a);
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;} {return eq_int_type(__c, eof()) ? ~eof() : __c;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);} {return char_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);} {return int_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(0xDFFF);} {return int_type(0xDFFF);}
}; };
@ -876,14 +832,11 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
typedef u32streampos pos_type; typedef u32streampos pos_type;
typedef mbstate_t state_type; typedef mbstate_t state_type;
_LIBCPP_INLINE_VISIBILITY static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
{__c1 = __c2;} {__c1 = __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;} {return __c1 < __c2;}
static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 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* copy(char_type* __s1, const char_type* __s2, size_t __n);
static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type* assign(char_type* __s, size_t __n, char_type __a);
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;} {return eq_int_type(__c, eof()) ? ~eof() : __c;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);} {return char_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);} {return int_type(__c);}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;} {return __c1 == __c2;}
_LIBCPP_INLINE_VISIBILITY static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(0xFFFFFFFF);} {return int_type(0xFFFFFFFF);}
}; };