Skip to content

Commit 3a0dba9

Browse files
[libc++] __uglify [[clang::noescape]]
Identifiers `clang` and `noescape` are not reserved by the C++ standard, so perhaps we need to use the equivalent reserved forms. Also changes the occurrences of that attribute to a macro, following the convention for `[[_Clang::__lifetimebound__]]`.
1 parent c0c36aa commit 3a0dba9

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

libcxx/include/__charconv/from_chars_floating_point.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ struct __from_chars_result {
3737

3838
template <class _Fp>
3939
_LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point(
40-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt);
40+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
4141

4242
extern template __from_chars_result<float> __from_chars_floating_point(
43-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt);
43+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
4444

4545
extern template __from_chars_result<double> __from_chars_floating_point(
46-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt);
46+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
4747

4848
template <class _Fp>
4949
_LIBCPP_HIDE_FROM_ABI from_chars_result

libcxx/include/__config

+6
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,12 @@ typedef __char32_t char32_t;
11671167
# define _LIBCPP_LIFETIMEBOUND
11681168
# endif
11691169

1170+
# if __has_cpp_attribute(_Clang::__noescape__)
1171+
# define _LIBCPP_NOESCAPE [[_Clang::__noescape__]]
1172+
# else
1173+
# define _LIBCPP_NOESCAPE
1174+
# endif
1175+
11701176
# if __has_attribute(__nodebug__)
11711177
# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
11721178
# else

libcxx/src/charconv.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ to_chars_result to_chars(char* __first, char* __last, long double __value, chars
7777

7878
template <class _Fp>
7979
__from_chars_result<_Fp> __from_chars_floating_point(
80-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt) {
80+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt) {
8181
return std::__from_chars_floating_point_impl<_Fp>(__first, __last, __fmt);
8282
}
8383

8484
template __from_chars_result<float> __from_chars_floating_point(
85-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt);
85+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
8686

8787
template __from_chars_result<double> __from_chars_floating_point(
88-
[[clang::noescape]] const char* __first, [[clang::noescape]] const char* __last, chars_format __fmt);
88+
_LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
8989
_LIBCPP_END_NAMESPACE_STD

libcxx/test/libcxx/system_reserved_names.gen.py

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@
154154
#define Xp SYSTEM_RESERVED_NAME
155155
#define Xs SYSTEM_RESERVED_NAME
156156
157+
// These attribute-tokens are not reserved, so the user can macro-define them.
158+
#define lifetimebound SYSTEM_RESERVED_NAME
159+
#define noescape SYSTEM_RESERVED_NAME
160+
157161
// The classic Windows min/max macros
158162
#define min SYSTEM_RESERVED_NAME
159163
#define max SYSTEM_RESERVED_NAME

0 commit comments

Comments
 (0)