[PATCH] [libcxx] Create internal namespace that hides all symbols.

Eric Fiselier eric at efcs.ca
Thu Mar 26 23:23:37 PDT 2015


Hi mclow.lists, danalbert, chandlerc, rsmith,

Currently functions and types that are pure implementation must be individually annotated with a DSO visibility attribute. This requires tedious repetition and is prone to errors.

As it stands there are a number of symbols within libc++ that do not have a visibility attribute. These symbols may or may be compiled into the DSO depending on the compilation flags. This leads to the DSO providing an unstable and unmanageable set of symbols.

This patch creates a nested namespace `__libcpp_internal` that sets the visibility to "hidden" for all symbols within it. Classes and functions that are pure implementation details should live within this namespace. This way the symbols don't have to be individually annotated. 

Slowly but surely symbols should be moved to this namespace. Migrating code into this namespace will be tricky. We will have to ensure that no platform already ships a DSO that contains the candidate symbols.

http://reviews.llvm.org/D8652

Files:
  include/__config

Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -554,6 +554,15 @@
 
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
+#define _LIBCPP_BEGIN_NAMESPACE_INTERNAL namespace __libcpp_internal _LIBCPP_HIDDEN {
+#define _LIBCPP_END_NAMESPACE_INTERNAL }
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+  _LIBCPP_BEGIN_NAMESPACE_INTERNAL
+  _LIBCPP_END_NAMESPACE_INTERNAL
+  using namespace __libcpp_internal;
+_LIBCPP_END_NAMESPACE_STD
+
 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
 typedef unsigned short char16_t;
 typedef unsigned int   char32_t;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8652.22777.patch
Type: text/x-patch
Size: 620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150327/cf7f810a/attachment.bin>


More information about the cfe-commits mailing list