[libcxx-commits] [libcxx] [libc++] Switch a few attribute to use the C++11 syntax (PR #133293)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 27 11:26:20 PDT 2025


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/133293

Using the C++11 attribute syntax makes it more strict where attributes can be applied, reducing the number of possible positions an attribute can appear in.


>From 81f9e21289108ee75df435d2522cf37010f9c888 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 27 Mar 2025 19:25:09 +0100
Subject: [PATCH] [libc++] Switch a few attribute to use the C++11 syntax

---
 libcxx/include/__config | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 070298301b0d3..30fe0ef6a3b53 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1157,8 +1157,8 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_USING_IF_EXISTS
 #  endif
 
-#  if __has_attribute(__no_destroy__)
-#    define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
+#  if __has_cpp_attribute(_Clang::__no_destroy__)
+#    define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]]
 #  else
 #    define _LIBCPP_NO_DESTROY
 #  endif
@@ -1188,14 +1188,14 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_NO_SPECIALIZATIONS
 #  endif
 
-#  if __has_attribute(__standalone_debug__)
-#    define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
+#  if __has_cpp_attribute(_Clang::__standalone_debug__)
+#    define _LIBCPP_STANDALONE_DEBUG [[_Clang::__standalone_debug__]]
 #  else
 #    define _LIBCPP_STANDALONE_DEBUG
 #  endif
 
-#  if __has_attribute(__preferred_name__)
-#    define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+#  if __has_cpp_attribute(_Clang::__preferred_name__)
+#    define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]]
 #  else
 #    define _LIBCPP_PREFERRED_NAME(x)
 #  endif



More information about the libcxx-commits mailing list