[libc++] Simplify the visibility attributes
authorNikolas Klauser <nikolasklauser@berlin.de>
Wed, 22 Jun 2022 09:14:04 +0000 (11:14 +0200)
committerNikolas Klauser <nikolasklauser@berlin.de>
Wed, 22 Jun 2022 23:30:32 +0000 (01:30 +0200)
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D128007

libcxx/include/__config

index 6f02a3a..11f934c 100644 (file)
@@ -527,42 +527,31 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_TEMPLATE_DATA_VIS
 #    define _LIBCPP_ENUM_VIS
 
-#  endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
+#  else
 
-#  ifndef _LIBCPP_HIDDEN
 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_HIDDEN __attribute__((__visibility__("hidden")))
+#      define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
 #    else
-#      define _LIBCPP_HIDDEN
+#      define _LIBCPP_VISIBILITY(vis)
 #    endif
-#  endif
 
-#  ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
+#    define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
+#    define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
+#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+
 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 // The inline should be removed once PR32114 is resolved
 #      define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
 #    else
 #      define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 #    endif
-#  endif
-
-#  ifndef _LIBCPP_FUNC_VIS
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_FUNC_VIS __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_FUNC_VIS
-#    endif
-#  endif
 
-#  ifndef _LIBCPP_TYPE_VIS
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_TYPE_VIS __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_TYPE_VIS
-#    endif
-#  endif
-
-#  ifndef _LIBCPP_TEMPLATE_VIS
 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #      if __has_attribute(__type_visibility__)
 #        define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default")))
@@ -572,55 +561,14 @@ typedef __char32_t char32_t;
 #    else
 #      define _LIBCPP_TEMPLATE_VIS
 #    endif
-#  endif
 
-#  ifndef _LIBCPP_TEMPLATE_DATA_VIS
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_TEMPLATE_DATA_VIS __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_TEMPLATE_DATA_VIS
-#    endif
-#  endif
-
-#  ifndef _LIBCPP_EXPORTED_FROM_ABI
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_EXPORTED_FROM_ABI
-#    endif
-#  endif
-
-#  ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
-#    define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
-#  endif
-
-#  ifndef _LIBCPP_EXCEPTION_ABI
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_EXCEPTION_ABI __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_EXCEPTION_ABI
-#    endif
-#  endif
-
-#  ifndef _LIBCPP_ENUM_VIS
 #    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
 #      define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default")))
 #    else
 #      define _LIBCPP_ENUM_VIS
 #    endif
-#  endif
 
-#  ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-#    if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#      define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__((__visibility__("default")))
-#    else
-#      define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-#    endif
-#  endif
-
-#  ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-#    define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
-#  endif
+#  endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
 #  if __has_attribute(internal_linkage)
 #    define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage))