smeenai created this revision. smeenai added reviewers: mclow.lists, EricWF. smeenai added a subscriber: cfe-commits.
It's useful to be able to disable visibility annotations entirely; for example, if we're building libc++ static to include in another library, and we don't want any libc++ functions getting exported out of that library. This is a generalization of _LIBCPP_DISABLE_DLL_IMPORT_EXPORT. https://reviews.llvm.org/D26934 Files: include/__config
Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -510,7 +510,7 @@ #ifdef _WIN32 -#if defined(_LIBCPP_DISABLE_DLL_IMPORT_EXPORT) +#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS @@ -546,18 +546,30 @@ #endif // _WIN32 #ifndef _LIBCPP_HIDDEN +#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) +#else +#define _LIBCPP_HIDDEN +#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 __has_attribute(__type_visibility__) -# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# if __has_attribute(__type_visibility__) +# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default"))) +# else +# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) +# endif # else -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) +# define _LIBCPP_TYPE_VIS # endif #endif @@ -574,19 +586,23 @@ #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 __has_attribute(__type_visibility__) +# 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 __has_attribute(__type_visibility__) +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS @@ -598,15 +614,27 @@ #endif #ifndef _LIBCPP_INLINE_VISIBILITY +#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#else +#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) +#endif #endif #ifndef _LIBCPP_ALWAYS_INLINE +#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) +#else +#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +#endif #endif #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY -# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) +# else +# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__)) +# endif #endif #ifndef _LIBCPP_PREFERRED_OVERLOAD
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits