@@ -552,12 +552,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
552552# define _LIBCPP_USING_DEV_RANDOM
553553# endif
554554
555- # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
556- # define _LIBCPP_NO_CFI __attribute__ ((__no_sanitize__(" cfi" )))
557- # else
558- # define _LIBCPP_NO_CFI
559- # endif
560-
561555# ifndef _LIBCPP_CXX03_LANG
562556
563557# define _LIBCPP_ALIGNOF (_Tp ) alignof (_Tp)
@@ -629,11 +623,6 @@ typedef __char32_t char32_t;
629623# define _LIBCPP_HAS_NO_ASAN
630624# endif
631625
632- // Allow for build-time disabling of unsigned integer sanitization
633- # if __has_attribute(no_sanitize)
634- # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__ ((__no_sanitize__(" unsigned-integer-overflow" )))
635- # endif
636-
637626# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
638627
639628# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
@@ -857,18 +846,6 @@ typedef __char32_t char32_t;
857846# define _LIBCPP_HAS_NO_INT128
858847# endif
859848
860- # if __has_attribute(__malloc__)
861- # define _LIBCPP_NOALIAS __attribute__ ((__malloc__))
862- # else
863- # define _LIBCPP_NOALIAS
864- # endif
865-
866- # if __has_attribute(__using_if_exists__)
867- # define _LIBCPP_USING_IF_EXISTS __attribute__ ((__using_if_exists__))
868- # else
869- # define _LIBCPP_USING_IF_EXISTS
870- # endif
871-
872849# ifdef _LIBCPP_CXX03_LANG
873850# define _LIBCPP_DECLARE_STRONG_ENUM (x ) \
874851 struct _LIBCPP_EXPORTED_FROM_ABI x { \
@@ -1038,29 +1015,6 @@ typedef __char32_t char32_t;
10381015# define _LIBCPP_CONSTEXPR_SINCE_CXX23
10391016# endif
10401017
1041- # if __has_cpp_attribute(nodiscard)
1042- # define _LIBCPP_NODISCARD [[__nodiscard__]]
1043- # else
1044- // We can't use GCC's [[gnu::warn_unused_result]] and
1045- // __attribute__((warn_unused_result)), because GCC does not silence them via
1046- // (void) cast.
1047- # define _LIBCPP_NODISCARD
1048- # endif
1049-
1050- // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1051- // specified as such as an extension.
1052- # if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1053- # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1054- # else
1055- # define _LIBCPP_NODISCARD_EXT
1056- # endif
1057-
1058- # if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1059- # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1060- # else
1061- # define _LIBCPP_NODISCARD_AFTER_CXX17
1062- # endif
1063-
10641018# ifndef _LIBCPP_HAS_NO_ASAN
10651019 extern " C" _LIBCPP_EXPORTED_FROM_ABI void
10661020 __sanitizer_annotate_contiguous_container (const void *, const void *, const void *, const void *);
@@ -1196,10 +1150,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
11961150# endif
11971151# endif
11981152
1199- # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1200- # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1201- # endif
1202-
12031153# if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
12041154# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__ ((__no_thread_safety_analysis__))
12051155# else
@@ -1232,51 +1182,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
12321182# define _LIBCPP_CONSTINIT
12331183# endif
12341184
1235- # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1236- # define _LIBCPP_DIAGNOSE_WARNING (...) __attribute__((__diagnose_if__(__VA_ARGS__, " warning" )))
1237- # else
1238- # define _LIBCPP_DIAGNOSE_WARNING (...)
1239- # endif
1240-
1241- // Use a function like macro to imply that it must be followed by a semicolon
1242- # if __has_cpp_attribute(fallthrough)
1243- # define _LIBCPP_FALLTHROUGH () [[fallthrough]]
1244- # elif __has_attribute(__fallthrough__)
1245- # define _LIBCPP_FALLTHROUGH () __attribute__((__fallthrough__))
1246- # else
1247- # define _LIBCPP_FALLTHROUGH () ((void )0 )
1248- # endif
1249-
1250- # if __has_cpp_attribute(_Clang::__lifetimebound__)
1251- # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1252- # else
1253- # define _LIBCPP_LIFETIMEBOUND
1254- # endif
1255-
1256- # if __has_attribute(__nodebug__)
1257- # define _LIBCPP_NODEBUG __attribute__ ((__nodebug__))
1258- # else
1259- # define _LIBCPP_NODEBUG
1260- # endif
1261-
1262- # if __has_attribute(__standalone_debug__)
1263- # define _LIBCPP_STANDALONE_DEBUG __attribute__ ((__standalone_debug__))
1264- # else
1265- # define _LIBCPP_STANDALONE_DEBUG
1266- # endif
1267-
1268- # if __has_attribute(__preferred_name__)
1269- # define _LIBCPP_PREFERRED_NAME (x ) __attribute__((__preferred_name__(x)))
1270- # else
1271- # define _LIBCPP_PREFERRED_NAME (x )
1272- # endif
1273-
1274- # if __has_attribute(__no_sanitize__)
1275- # define _LIBCPP_NO_SANITIZE (...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1276- # else
1277- # define _LIBCPP_NO_SANITIZE (...)
1278- # endif
1279-
12801185// We often repeat things just for handling wide characters in the library.
12811186// When wide characters are disabled, it can be useful to have a quick way of
12821187// disabling it without having to resort to #if-#endif, which has a larger
@@ -1287,12 +1192,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
12871192# define _LIBCPP_IF_WIDE_CHARACTERS (...) __VA_ARGS__
12881193# endif
12891194
1290- # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1291- # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec (empty_bases)
1292- # else
1293- # define _LIBCPP_DECLSPEC_EMPTY_BASES
1294- # endif
1295-
12961195# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
12971196# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
12981197# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
@@ -1336,21 +1235,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
13361235# define _LIBCPP_FOPEN_CLOEXEC_MODE
13371236# endif
13381237
1339- # if __has_attribute(__init_priority__)
1340- # define _LIBCPP_INIT_PRIORITY_MAX __attribute__ ((__init_priority__(100 )))
1341- # else
1342- # define _LIBCPP_INIT_PRIORITY_MAX
1343- # endif
1344-
1345- # if __has_attribute(__format__)
1346- // The attribute uses 1-based indices for ordinary and static member functions.
1347- // The attribute uses 2-based indices for non-static member functions.
1348- # define _LIBCPP_ATTRIBUTE_FORMAT (archetype, format_string_index, first_format_arg_index ) \
1349- __attribute__ ((__format__(archetype, format_string_index, first_format_arg_index)))
1350- # else
1351- # define _LIBCPP_ATTRIBUTE_FORMAT (archetype, format_string_index, first_format_arg_index ) /* nothing */
1352- # endif
1353-
13541238# if __has_cpp_attribute(msvc::no_unique_address)
13551239// MSVC implements [[no_unique_address]] as a silent no-op currently.
13561240// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
@@ -1390,12 +1274,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
13901274# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED (str )
13911275# endif
13921276
1393- # if __has_attribute(__packed__)
1394- # define _LIBCPP_PACKED __attribute__ ((__packed__))
1395- # else
1396- # define _LIBCPP_PACKED
1397- # endif
1398-
13991277// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
14001278// functions is gradually being added to existing C libraries. The conditions
14011279// below check for known C library versions and conditions under which these
@@ -1484,6 +1362,134 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
14841362
14851363# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
14861364
1365+ // Optional attributes - these are useful for a better QoI, but not required to be available
1366+
1367+ # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
1368+ # define _LIBCPP_NO_CFI __attribute__ ((__no_sanitize__(" cfi" )))
1369+ # else
1370+ # define _LIBCPP_NO_CFI
1371+ # endif
1372+
1373+ # if __has_attribute(__malloc__)
1374+ # define _LIBCPP_NOALIAS __attribute__ ((__malloc__))
1375+ # else
1376+ # define _LIBCPP_NOALIAS
1377+ # endif
1378+
1379+ # if __has_attribute(__using_if_exists__)
1380+ # define _LIBCPP_USING_IF_EXISTS __attribute__ ((__using_if_exists__))
1381+ # else
1382+ # define _LIBCPP_USING_IF_EXISTS
1383+ # endif
1384+
1385+ # if __has_cpp_attribute(nodiscard)
1386+ # define _LIBCPP_NODISCARD [[__nodiscard__]]
1387+ # else
1388+ // We can't use GCC's [[gnu::warn_unused_result]] and
1389+ // __attribute__((warn_unused_result)), because GCC does not silence them via
1390+ // (void) cast.
1391+ # define _LIBCPP_NODISCARD
1392+ # endif
1393+
1394+ // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1395+ // specified as such as an extension.
1396+ # if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1397+ # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1398+ # else
1399+ # define _LIBCPP_NODISCARD_EXT
1400+ # endif
1401+
1402+ # if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1403+ # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1404+ # else
1405+ # define _LIBCPP_NODISCARD_AFTER_CXX17
1406+ # endif
1407+
1408+ # if __has_attribute(__no_destroy__)
1409+ # define _LIBCPP_NO_DESTROY __attribute__ ((__no_destroy__))
1410+ # else
1411+ # define _LIBCPP_NO_DESTROY
1412+ # endif
1413+
1414+ # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1415+ # define _LIBCPP_DIAGNOSE_WARNING (...) __attribute__((__diagnose_if__(__VA_ARGS__, " warning" )))
1416+ # else
1417+ # define _LIBCPP_DIAGNOSE_WARNING (...)
1418+ # endif
1419+
1420+ // Use a function like macro to imply that it must be followed by a semicolon
1421+ # if __has_cpp_attribute(fallthrough)
1422+ # define _LIBCPP_FALLTHROUGH () [[fallthrough]]
1423+ # elif __has_attribute(__fallthrough__)
1424+ # define _LIBCPP_FALLTHROUGH () __attribute__((__fallthrough__))
1425+ # else
1426+ # define _LIBCPP_FALLTHROUGH () ((void )0 )
1427+ # endif
1428+
1429+ # if __has_cpp_attribute(_Clang::__lifetimebound__)
1430+ # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1431+ # else
1432+ # define _LIBCPP_LIFETIMEBOUND
1433+ # endif
1434+
1435+ # if __has_attribute(__nodebug__)
1436+ # define _LIBCPP_NODEBUG __attribute__ ((__nodebug__))
1437+ # else
1438+ # define _LIBCPP_NODEBUG
1439+ # endif
1440+
1441+ # if __has_attribute(__standalone_debug__)
1442+ # define _LIBCPP_STANDALONE_DEBUG __attribute__ ((__standalone_debug__))
1443+ # else
1444+ # define _LIBCPP_STANDALONE_DEBUG
1445+ # endif
1446+
1447+ # if __has_attribute(__preferred_name__)
1448+ # define _LIBCPP_PREFERRED_NAME (x ) __attribute__((__preferred_name__(x)))
1449+ # else
1450+ # define _LIBCPP_PREFERRED_NAME (x )
1451+ # endif
1452+
1453+ # if __has_attribute(__no_sanitize__)
1454+ # define _LIBCPP_NO_SANITIZE (...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1455+ # else
1456+ # define _LIBCPP_NO_SANITIZE (...)
1457+ # endif
1458+
1459+ # if __has_attribute(__init_priority__)
1460+ # define _LIBCPP_INIT_PRIORITY_MAX __attribute__ ((__init_priority__(100 )))
1461+ # else
1462+ # define _LIBCPP_INIT_PRIORITY_MAX
1463+ # endif
1464+
1465+ # if __has_attribute(__format__)
1466+ // The attribute uses 1-based indices for ordinary and static member functions.
1467+ // The attribute uses 2-based indices for non-static member functions.
1468+ # define _LIBCPP_ATTRIBUTE_FORMAT (archetype, format_string_index, first_format_arg_index ) \
1469+ __attribute__ ((__format__(archetype, format_string_index, first_format_arg_index)))
1470+ # else
1471+ # define _LIBCPP_ATTRIBUTE_FORMAT (archetype, format_string_index, first_format_arg_index ) /* nothing */
1472+ # endif
1473+
1474+ # if __has_attribute(__packed__)
1475+ # define _LIBCPP_PACKED __attribute__ ((__packed__))
1476+ # else
1477+ # define _LIBCPP_PACKED
1478+ # endif
1479+
1480+ # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1481+ # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec (empty_bases)
1482+ # else
1483+ # define _LIBCPP_DECLSPEC_EMPTY_BASES
1484+ # endif
1485+
1486+ // Allow for build-time disabling of unsigned integer sanitization
1487+ # if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
1488+ # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__ ((__no_sanitize__(" unsigned-integer-overflow" )))
1489+ # else
1490+ # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1491+ # endif
1492+
14871493#endif // __cplusplus
14881494
14891495#endif // _LIBCPP___CONFIG
0 commit comments