Index: libcxx/CMakeLists.txt =================================================================== --- libcxx/CMakeLists.txt +++ libcxx/CMakeLists.txt @@ -589,6 +589,10 @@ # library. target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY) + if (LIBCXX_ENABLE_DEBUG_MODE_SUPPORT) + target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_DEBUG_MODE_SUPPORT) + endif() + if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() Index: libcxx/include/string =================================================================== --- libcxx/include/string +++ libcxx/include/string @@ -4515,6 +4515,7 @@ _LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr); +#if _LIBCPP_DEBUG_LEVEL != 2 _LIBCPP_FUNC_VIS string to_string(int __val); _LIBCPP_FUNC_VIS string to_string(unsigned __val); _LIBCPP_FUNC_VIS string to_string(long __val); @@ -4524,6 +4525,84 @@ _LIBCPP_FUNC_VIS string to_string(float __val); _LIBCPP_FUNC_VIS string to_string(double __val); _LIBCPP_FUNC_VIS string to_string(long double __val); +#else +inline namespace debug +{ +_LIBCPP_FUNC_VIS string __to_string(int __val); +_LIBCPP_FUNC_VIS string __to_string(unsigned __val); +_LIBCPP_FUNC_VIS string __to_string(long __val); +_LIBCPP_FUNC_VIS string __to_string(unsigned long __val); +_LIBCPP_FUNC_VIS string __to_string(long long __val); +_LIBCPP_FUNC_VIS string __to_string(unsigned long long __val); +_LIBCPP_FUNC_VIS string __to_string(float __val); +_LIBCPP_FUNC_VIS string __to_string(double __val); +_LIBCPP_FUNC_VIS string __to_string(long double __val); + +inline _LIBCPP_HIDE_FROM_ABI string to_string(int __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(unsigned __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(long __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(unsigned long __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(long long __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(unsigned long long __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(float __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(double __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI string to_string(long double __val) +{ + string __s = __to_string(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +} +#endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10); @@ -4536,6 +4615,7 @@ _LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr); +#if _LIBCPP_DEBUG_LEVEL != 2 _LIBCPP_FUNC_VIS wstring to_wstring(int __val); _LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); _LIBCPP_FUNC_VIS wstring to_wstring(long __val); @@ -4545,6 +4625,84 @@ _LIBCPP_FUNC_VIS wstring to_wstring(float __val); _LIBCPP_FUNC_VIS wstring to_wstring(double __val); _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); +#else +inline namespace debug +{ +_LIBCPP_FUNC_VIS wstring __to_wstring(int __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(long __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned long __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(long long __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned long long __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(float __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(double __val); +_LIBCPP_FUNC_VIS wstring __to_wstring(long double __val); + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(int __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(unsigned __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(long __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(unsigned long __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(long long __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(unsigned long long __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(float __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(double __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +inline _LIBCPP_HIDE_FROM_ABI wstring to_wstring(long double __val) +{ + wstring __s = __to_wstring(__val); + std::__debug_db_insert_c(&__s); + return __s; +} + +} +#endif #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template Index: libcxx/src/string.cpp =================================================================== --- libcxx/src/string.cpp +++ libcxx/src/string.cpp @@ -511,4 +511,35 @@ wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string()(), L"%Lf", val); } #endif +#ifdef _LIBCPP_BUILDING_DEBUG_MODE_SUPPORT +inline namespace debug +{ +_LIBCPP_FUNC_VIS string __to_string (int val) { return i_to_string< string>(val); } +_LIBCPP_FUNC_VIS string __to_string (long val) { return i_to_string< string>(val); } +_LIBCPP_FUNC_VIS string __to_string (long long val) { return i_to_string< string>(val); } +_LIBCPP_FUNC_VIS string __to_string (unsigned val) { return i_to_string< string>(val); } +_LIBCPP_FUNC_VIS string __to_string (unsigned long val) { return i_to_string< string>(val); } +_LIBCPP_FUNC_VIS string __to_string (unsigned long long val) { return i_to_string< string>(val); } + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +_LIBCPP_FUNC_VIS wstring __to_wstring(int val) { return i_to_string(val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(long val) { return i_to_string(val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(long long val) { return i_to_string(val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned val) { return i_to_string(val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned long val) { return i_to_string(val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(unsigned long long val) { return i_to_string(val); } +#endif + +_LIBCPP_FUNC_VIS string __to_string (float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); } +_LIBCPP_FUNC_VIS string __to_string (double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); } +_LIBCPP_FUNC_VIS string __to_string (long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); } + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +_LIBCPP_FUNC_VIS wstring __to_wstring(float val) { return as_string(get_swprintf(), initial_string()(), L"%f", val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(double val) { return as_string(get_swprintf(), initial_string()(), L"%f", val); } +_LIBCPP_FUNC_VIS wstring __to_wstring(long double val) { return as_string(get_swprintf(), initial_string()(), L"%Lf", val); } +#endif +} +#endif + _LIBCPP_END_NAMESPACE_STD