Skip to content

Commit b101c35

Browse files
authored
[libc++] Remove conditional for attributes that are always available (#126879)
These attributes are available in all supported compilers, so the `#else` case of the conditional is dead code.
1 parent 324e27e commit b101c35

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

libcxx/include/__config

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,18 +1119,23 @@ typedef __char32_t char32_t;
11191119

11201120
// Optional attributes - these are useful for a better QoI, but not required to be available
11211121

1122+
# define _LIBCPP_NOALIAS __attribute__((__malloc__))
1123+
# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
1124+
# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1125+
# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1126+
# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1127+
__attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1128+
# define _LIBCPP_PACKED __attribute__((__packed__))
1129+
1130+
// Use a function like macro to imply that it must be followed by a semicolon
1131+
# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1132+
11221133
# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
11231134
# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
11241135
# else
11251136
# define _LIBCPP_NO_CFI
11261137
# endif
11271138

1128-
# if __has_attribute(__malloc__)
1129-
# define _LIBCPP_NOALIAS __attribute__((__malloc__))
1130-
# else
1131-
# define _LIBCPP_NOALIAS
1132-
# endif
1133-
11341139
# if __has_attribute(__using_if_exists__)
11351140
# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
11361141
# else
@@ -1149,15 +1154,6 @@ typedef __char32_t char32_t;
11491154
# define _LIBCPP_DIAGNOSE_WARNING(...)
11501155
# endif
11511156

1152-
// Use a function like macro to imply that it must be followed by a semicolon
1153-
# if __has_cpp_attribute(fallthrough)
1154-
# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1155-
# elif __has_attribute(__fallthrough__)
1156-
# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1157-
# else
1158-
# define _LIBCPP_FALLTHROUGH() ((void)0)
1159-
# endif
1160-
11611157
# if __has_cpp_attribute(_Clang::__lifetimebound__)
11621158
# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
11631159
# else
@@ -1170,8 +1166,6 @@ typedef __char32_t char32_t;
11701166
# define _LIBCPP_NOESCAPE
11711167
# endif
11721168

1173-
# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
1174-
11751169
# if __has_cpp_attribute(_Clang::__no_specializations__)
11761170
# define _LIBCPP_NO_SPECIALIZATIONS \
11771171
[[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
@@ -1191,33 +1185,6 @@ typedef __char32_t char32_t;
11911185
# define _LIBCPP_PREFERRED_NAME(x)
11921186
# endif
11931187

1194-
# if __has_attribute(__no_sanitize__)
1195-
# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1196-
# else
1197-
# define _LIBCPP_NO_SANITIZE(...)
1198-
# endif
1199-
1200-
# if __has_attribute(__init_priority__)
1201-
# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1202-
# else
1203-
# define _LIBCPP_INIT_PRIORITY_MAX
1204-
# endif
1205-
1206-
# if __has_attribute(__format__)
1207-
// The attribute uses 1-based indices for ordinary and static member functions.
1208-
// The attribute uses 2-based indices for non-static member functions.
1209-
# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1210-
__attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1211-
# else
1212-
# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
1213-
# endif
1214-
1215-
# if __has_attribute(__packed__)
1216-
# define _LIBCPP_PACKED __attribute__((__packed__))
1217-
# else
1218-
# define _LIBCPP_PACKED
1219-
# endif
1220-
12211188
# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
12221189
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
12231190
# else

0 commit comments

Comments
 (0)