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
llvm-svn: 217961
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 353f358d241330971b9f67f7d02d4b1f59c72951
diff --git a/include/string b/include/string
index fe72e9d..12f541e 100644
--- a/include/string
+++ b/include/string
@@ -509,14 +509,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);}
};