[libc++][NFC] split <charconv>.
This move the helper types `chars_format`, `to_chars_result` and `from_chars_result` to a separate header. The first two are needed for D70631 the third for consistency. The header `__charconv/ryu.h` uses these types and it can't depend on the types in `<charconv>` in a modular build. Moving them to the ryu header would be an odd place and doesn't work since the header is included in the middle of `<charconv>`. Reviewed By: #libc, ldionne, Quuxplusone Differential Revision: https://reviews.llvm.org/D108927
This commit is contained in:
@@ -97,6 +97,9 @@ set(files
|
||||
__bits
|
||||
__bsd_locale_defaults.h
|
||||
__bsd_locale_fallbacks.h
|
||||
__charconv/chars_format.h
|
||||
__charconv/from_chars_result.h
|
||||
__charconv/to_chars_result.h
|
||||
__compare/common_comparison_category.h
|
||||
__compare/compare_three_way_result.h
|
||||
__compare/ordering.h
|
||||
|
||||
77
libcxx/include/__charconv/chars_format.h
Normal file
77
libcxx/include/__charconv/chars_format.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___CHARCONV_CHARS_FORMAT_H
|
||||
#define _LIBCPP___CHARCONV_CHARS_FORMAT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__utility/to_underlying.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS chars_format
|
||||
{
|
||||
scientific = 0x1,
|
||||
fixed = 0x2,
|
||||
hex = 0x4,
|
||||
general = fixed | scientific
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator~(chars_format __x) {
|
||||
return chars_format(~_VSTD::__to_underlying(__x));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator&(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) &
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator|(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) |
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator^(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) ^
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator&=(chars_format& __x, chars_format __y) {
|
||||
__x = __x & __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator|=(chars_format& __x, chars_format __y) {
|
||||
__x = __x | __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator^=(chars_format& __x, chars_format __y) {
|
||||
__x = __x ^ __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H
|
||||
34
libcxx/include/__charconv/from_chars_result.h
Normal file
34
libcxx/include/__charconv/from_chars_result.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H
|
||||
#define _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__errc>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
struct _LIBCPP_TYPE_VIS from_chars_result
|
||||
{
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H
|
||||
34
libcxx/include/__charconv/to_chars_result.h
Normal file
34
libcxx/include/__charconv/to_chars_result.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
|
||||
#define _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__errc>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
struct _LIBCPP_TYPE_VIS to_chars_result
|
||||
{
|
||||
char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
|
||||
@@ -75,9 +75,11 @@ namespace std {
|
||||
|
||||
#include <__availability>
|
||||
#include <__bits>
|
||||
#include <__charconv/chars_format.h>
|
||||
#include <__charconv/from_chars_result.h>
|
||||
#include <__charconv/to_chars_result.h>
|
||||
#include <__config>
|
||||
#include <__errc>
|
||||
#include <__utility/to_underlying.h>
|
||||
#include <cmath> // for log2f
|
||||
#include <cstdint>
|
||||
#include <cstdlib> // for _LIBCPP_UNREACHABLE
|
||||
@@ -103,67 +105,6 @@ _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value,
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS chars_format
|
||||
{
|
||||
scientific = 0x1,
|
||||
fixed = 0x2,
|
||||
hex = 0x4,
|
||||
general = fixed | scientific
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator~(chars_format __x) {
|
||||
return chars_format(~_VSTD::__to_underlying(__x));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator&(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) &
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator|(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) |
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
|
||||
operator^(chars_format __x, chars_format __y) {
|
||||
return chars_format(_VSTD::__to_underlying(__x) ^
|
||||
_VSTD::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator&=(chars_format& __x, chars_format __y) {
|
||||
__x = __x & __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator|=(chars_format& __x, chars_format __y) {
|
||||
__x = __x | __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
|
||||
operator^=(chars_format& __x, chars_format __y) {
|
||||
__x = __x ^ __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
struct _LIBCPP_TYPE_VIS to_chars_result
|
||||
{
|
||||
char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS from_chars_result
|
||||
{
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
void to_chars(char*, char*, bool, int = 10) = delete;
|
||||
void from_chars(const char*, const char*, bool, int = 10) = delete;
|
||||
|
||||
|
||||
@@ -346,6 +346,13 @@ module std [system] {
|
||||
module charconv {
|
||||
header "charconv"
|
||||
export *
|
||||
|
||||
module __charconv {
|
||||
module chars_format { private header "__charconv/chars_format.h" }
|
||||
module from_chars_result { private header "__charconv/from_chars_result.h" }
|
||||
module to_chars_result { private header "__charconv/to_chars_result.h" }
|
||||
}
|
||||
|
||||
}
|
||||
module chrono {
|
||||
header "chrono"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: modules-build
|
||||
|
||||
// WARNING: This test was generated by 'generate_private_header_tests.py'
|
||||
// and should not be edited manually.
|
||||
|
||||
// expected-error@*:* {{use of private header from outside its module: '__charconv/chars_format.h'}}
|
||||
#include <__charconv/chars_format.h>
|
||||
@@ -0,0 +1,16 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: modules-build
|
||||
|
||||
// WARNING: This test was generated by 'generate_private_header_tests.py'
|
||||
// and should not be edited manually.
|
||||
|
||||
// expected-error@*:* {{use of private header from outside its module: '__charconv/from_chars_result.h'}}
|
||||
#include <__charconv/from_chars_result.h>
|
||||
@@ -0,0 +1,16 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: modules-build
|
||||
|
||||
// WARNING: This test was generated by 'generate_private_header_tests.py'
|
||||
// and should not be edited manually.
|
||||
|
||||
// expected-error@*:* {{use of private header from outside its module: '__charconv/to_chars_result.h'}}
|
||||
#include <__charconv/to_chars_result.h>
|
||||
Reference in New Issue
Block a user