[libc++] Reconsidering _LIBCPP_TYPE_VIS

Hi Eric, Marshall, Saleem (CC cfe-dev if anyone else has opinions on this),

Right now, libc++ annotates public classes with _LIBCPP_TYPE_VIS, which on
non-Windows platforms uses the __type_visibility__ attribute (where available)
to export only the typeinfo and vtable of the class. However, for many (if not
most) of these classes, we actually do want to export at least some of the
members as well, otherwise we get all sorts of missing symbol link errors when
compiling libc++ with hidden visibility.

One option would be to meticulously go through and annotate all members which
need to be exported with _LIBCPP_FUNC_VIS. I'm not a big fan of that option;
it's a lot of work, and I don't know of a good way to determine the exact set
of members to export; it would just be building against a bunch of large
codebases with hidden visibility and fixing whatever was broken, which of
course wouldn't be exhaustive.

Another option, and the one I'm proposing, is to switch _LIBCPP_TYPE_VIS to
always use the __visibility__ attribute, and leave _LIBCPP_TYPE_VIS_ONLY as
expanding to either __type_visibility__ or __visibility__ based on
availability. In other words, the macro definitions in include/__config would
change to the following:

#define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))

#if __has_attribute(__type_visibility__)
#define _LIBCPP_TYPE_VIS_ONLY __attribute__ ((__type_visibility__("default")))
#else
#define _LIBCPP_TYPE_VIS_ONLY __attribute__ ((__visibility__("default")))
#endif

This would probably over-export slightly, but it seems like the easiest path
forward for hidden visibility, and we can always fix the over-exporting later
as necessary. It would also make the semantics of _LIBCPP_TYPE_VIS be
consistent on all platforms, since it already expands to __declspec(dllexport)
on Windows, which will export all class members.

Thoughts?

Thanks,
Shoaib